abstract out faye
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
//= require jquery-ui
|
||||
//= require twitter/bootstrap
|
||||
//= require mustache
|
||||
//= require faye
|
||||
//= require_directory .
|
||||
//= require_self
|
||||
var path_mapping = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
root = exports ? this
|
||||
root.Qsupplier=
|
||||
watch_events: ->
|
||||
faye = new Faye.Client('http://localhost:9292/faye')
|
||||
faye = new Faye.Client(event_host)
|
||||
faye.subscribe "/supplier/"+supplier_id, (e)=>
|
||||
if(e.event == 'new_order')
|
||||
body = $('#active-orders-table tbody')
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
//= require qwaiter
|
||||
//= require supplier/order
|
||||
//= require mustache
|
||||
//= require faye
|
||||
//= require_directory .
|
||||
//= require_self
|
||||
var path_mapping = {
|
||||
|
||||
@@ -10,7 +10,7 @@ class Quser
|
||||
formatted += utc.substr(11, 5)
|
||||
formatted
|
||||
watch_events: ->
|
||||
faye = new Faye.Client('http://localhost:9292/faye')
|
||||
faye = new Faye.Client(event_host)
|
||||
faye.subscribe "/user/"+QMobile.user_id(), (e)=>
|
||||
if(e.event == 'list_closed')
|
||||
#redirect_to 'user_root', {list_closed: 'true'}
|
||||
|
||||
@@ -9,12 +9,12 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def broadcast_user(uid, event, data = {})
|
||||
message = {channel: "/user/#{uid}", data: {event: event, data: data}}
|
||||
uri = URI.parse("http://localhost:9292/faye")
|
||||
uri = URI.parse(event_host)
|
||||
Net::HTTP.post_form(uri, :message => message.to_json)
|
||||
end
|
||||
def broadcast_supplier(sid, event, data = {})
|
||||
message = {channel: "/supplier/#{sid}", data: {event: event, data: data}}
|
||||
uri = URI.parse("http://localhost:9292/faye")
|
||||
uri = URI.parse(event_host)
|
||||
Net::HTTP.post_form(uri, :message => message.to_json)
|
||||
end
|
||||
def set_locale
|
||||
@@ -23,14 +23,10 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def layout_by_resource
|
||||
if devise_controller?
|
||||
case session[:user_return_to]
|
||||
when /\/user\// then 'obtain_token'
|
||||
when /obtain_token/ then 'obtain_token'
|
||||
else 'theme1'
|
||||
end
|
||||
else
|
||||
"application"
|
||||
return 'obtain_token' if session[:user_return_to].present?
|
||||
return 'theme1' if session[:supplier_return_to].present?
|
||||
end
|
||||
"theme1"
|
||||
end
|
||||
def check_active_list_state
|
||||
if current_user.try(:active_list_id)
|
||||
@@ -60,4 +56,10 @@ class ApplicationController < ActionController::Base
|
||||
{ok: true, message: message}.merge(options).to_json
|
||||
end
|
||||
|
||||
# Return the hostname of the event server
|
||||
def event_host
|
||||
#TODO: do not do and environment check, its ugly!
|
||||
"http://#{Rails.env.production? ? 'events.qwaiter.com' : 'localhost'}:9296/faye"
|
||||
end
|
||||
helper_method :event_host
|
||||
end
|
||||
|
||||
@@ -76,4 +76,5 @@ module ApplicationHelper
|
||||
def twitter_link
|
||||
link_to 'Twitter', 'https://www.twitter.com/Qwaiter', target: :_blank
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -11,7 +11,6 @@ html lang="en"
|
||||
/[if lt IE 9]
|
||||
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
||||
= stylesheet_link_tag "user/application", :media => "all"
|
||||
= javascript_include_tag 'http://localhost:9292/faye.js'
|
||||
link href="/images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"
|
||||
link href="/images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
|
||||
link href="/images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
|
||||
@@ -20,6 +19,7 @@ html lang="en"
|
||||
javascript:
|
||||
var data_host = '#{Rails.env == 'development' ? 'http://qwaiter.dev' : 'http://data.qwaiter.com' }';
|
||||
var data_host = 'http://localhost:3000';
|
||||
var event_host = '#{event_host}';
|
||||
//data_host = 'http://192.168.1.148:3000';
|
||||
var $locale = 'en';
|
||||
var $url_vars = null;
|
||||
|
||||
@@ -11,7 +11,6 @@ html lang="en"
|
||||
/[if lt IE 9]
|
||||
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
||||
= stylesheet_link_tag "supplier/application", :media => "all"
|
||||
= javascript_include_tag 'http://localhost:9292/faye.js'
|
||||
link href="/images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144"
|
||||
link href="/images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114"
|
||||
link href="/images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72"
|
||||
@@ -20,7 +19,8 @@ html lang="en"
|
||||
|
||||
javascript:
|
||||
var supplier_id = '#{current_supplier.id}';
|
||||
var data_host = ''
|
||||
var data_host = '';
|
||||
var event_host = '#{event_host}';
|
||||
|
||||
= yield :head
|
||||
|
||||
|
||||
Reference in New Issue
Block a user