2014-02-13 18:27:38 +00:00
|
|
|
module ClientHelper
|
|
|
|
|
|
|
|
|
|
# is this the native client (or browser emulating native client with CTRL+SHIFT+0), or browser?
|
|
|
|
|
def is_native_client?
|
|
|
|
|
# is this the native client or browser?
|
|
|
|
|
user_agent = request.env["HTTP_USER_AGENT"]
|
|
|
|
|
is_native_client = !user_agent.blank? && user_agent.downcase.include?("jamkazam")
|
|
|
|
|
|
|
|
|
|
# allow override of the client type if configured to so, and if we find the override cookie in place
|
|
|
|
|
if Rails.application.config.allow_force_native_client
|
|
|
|
|
unless cookies[:act_as_native_client].nil?
|
|
|
|
|
is_native_client = (cookies[:act_as_native_client] == "true") ? true : false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
is_native_client
|
|
|
|
|
end
|
2014-05-19 21:57:08 +00:00
|
|
|
|
|
|
|
|
def gon_setup
|
|
|
|
|
|
|
|
|
|
gon.root_url = root_url
|
2014-06-30 20:44:28 +00:00
|
|
|
gon.client_path = client_path
|
2014-05-19 21:57:08 +00:00
|
|
|
# use gon to pass variables into javascript
|
|
|
|
|
if Rails.env == "development"
|
|
|
|
|
# if in development mode, we assume you are running websocket-gateway
|
|
|
|
|
# on the same host as you hit your server.
|
2015-05-11 22:25:37 +00:00
|
|
|
if request.headers['X-Forwarded-Proto'] == 'https'
|
|
|
|
|
gon.websocket_gateway_uri = "wss://" + request.host + ":6443/websocket";
|
|
|
|
|
else
|
|
|
|
|
gon.websocket_gateway_uri = "ws://" + request.host + ":6767/websocket";
|
|
|
|
|
end
|
|
|
|
|
|
2014-05-19 21:57:08 +00:00
|
|
|
else
|
|
|
|
|
# but in any other mode, just use config
|
2015-05-11 22:25:37 +00:00
|
|
|
if request.headers['X-Forwarded-Proto'] == 'https'
|
|
|
|
|
gon.websocket_gateway_uri = Rails.application.config.websocket_gateway_uri_ssl
|
|
|
|
|
else
|
|
|
|
|
gon.websocket_gateway_uri = Rails.application.config.websocket_gateway_uri
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2014-05-19 21:57:08 +00:00
|
|
|
end
|
|
|
|
|
|
2014-05-19 13:46:03 +00:00
|
|
|
if Rails.env == "development"
|
|
|
|
|
# if in development mode, we assume you are running websocket-gateway
|
|
|
|
|
# on the same host as you hit your server.
|
2015-05-11 22:25:37 +00:00
|
|
|
if request.headers['X-Forwarded-Proto'] == 'https'
|
|
|
|
|
gon.websocket_gateway_trusted_uri = "wss://" + request.host + ":6444/websocket";
|
|
|
|
|
else
|
|
|
|
|
gon.websocket_gateway_trusted_uri = "ws://" + request.host + ":6768/websocket";
|
|
|
|
|
end
|
2014-05-19 13:46:03 +00:00
|
|
|
else
|
|
|
|
|
# but in any other mode, just use config
|
2015-05-11 22:25:37 +00:00
|
|
|
if request.headers['X-Forwarded-Proto'] == 'https'
|
|
|
|
|
gon.websocket_gateway_trusted_uri = Rails.application.config.websocket_gateway_trusted_uri_ssl
|
|
|
|
|
else
|
|
|
|
|
gon.websocket_gateway_trusted_uri = Rails.application.config.websocket_gateway_trusted_uri
|
|
|
|
|
end
|
2014-05-19 13:46:03 +00:00
|
|
|
end
|
|
|
|
|
|
2014-05-19 21:57:08 +00:00
|
|
|
gon.check_for_client_updates = Rails.application.config.check_for_client_updates
|
|
|
|
|
gon.fp_apikey = Rails.application.config.filepicker_rails.api_key
|
|
|
|
|
gon.fp_upload_dir = Rails.application.config.filepicker_upload_dir
|
|
|
|
|
gon.allow_force_native_client = Rails.application.config.allow_force_native_client
|
2014-05-13 13:20:41 +00:00
|
|
|
gon.ftue_io_wait_time = Rails.application.config.ftue_io_wait_time
|
2014-05-29 20:34:19 +00:00
|
|
|
gon.ftue_packet_rate_treshold = Rails.application.config.ftue_packet_rate_treshold
|
|
|
|
|
gon.ftue_network_test_duration = Rails.application.config.ftue_network_test_duration
|
|
|
|
|
gon.ftue_network_test_max_clients = Rails.application.config.ftue_network_test_max_clients
|
|
|
|
|
gon.ftue_maximum_gear_latency = Rails.application.config.ftue_maximum_gear_latency
|
2015-05-18 04:00:12 +00:00
|
|
|
gon.musician_search_meta = MusicianSearch.search_filter_meta
|
|
|
|
|
gon.band_search_meta = BandSearch.search_filter_meta
|
2015-12-09 17:32:24 +00:00
|
|
|
gon.session_stat_thresholds = Rails.application.config.session_stat_thresholds
|
2015-12-11 12:45:30 +00:00
|
|
|
gon.midi_enabled = Rails.application.config.midi_enabled
|
2016-02-08 12:56:54 +00:00
|
|
|
gon.chat_blast = Rails.application.config.chat_blast
|
2016-05-16 16:39:20 +00:00
|
|
|
gon.jamclass_enabled = Rails.application.config.jamclass_enabled
|
2014-05-19 21:57:08 +00:00
|
|
|
|
|
|
|
|
# is this the native client or browser?
|
|
|
|
|
@nativeClient = is_native_client?
|
|
|
|
|
|
|
|
|
|
# let javascript have access to the server's opinion if this is a native client
|
|
|
|
|
gon.isNativeClient = @nativeClient
|
|
|
|
|
|
|
|
|
|
gon.use_cached_session_scores = Rails.application.config.use_cached_session_scores
|
|
|
|
|
gon.allow_both_find_algos = Rails.application.config.allow_both_find_algos
|
2016-04-21 14:23:29 +00:00
|
|
|
gon.stripe_publishable_key = Rails.application.config.stripe[:publishable_key]
|
2025-01-24 02:40:27 +00:00
|
|
|
gon.spa_origin_url = Rails.application.config.spa_origin_url
|
2014-05-19 21:57:08 +00:00
|
|
|
end
|
2015-03-12 04:39:20 +00:00
|
|
|
end
|