Class: FbChannelFileApp

Inherits:
Object
  • Object
show all
Defined in:
lib/fb-channel-file/engine.rb

Class Method Summary collapse

Class Method Details

.call(env) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/fb-channel-file/engine.rb', line 12

def call(env)
  puts I18n.locale
  [
    200,
    { "Pragma" => "public", "Cache-Control" => "max-age=#{60*60*24*365}", "Expires" => CGI.rfc1123_date(1.year.from_now), "Content-Type" => "text/html" },
    ["<script src='//connect.facebook.net/#{locale}/all.js'></script>"]
  ]
end

.configObject



3
4
5
# File 'lib/fb-channel-file/engine.rb', line 3

def config
  @@config ||= default_config.dup
end

.default_configObject



7
8
9
10
# File 'lib/fb-channel-file/engine.rb', line 7

def default_config
  { :locale => "en_US",
    :infer_locale => true }
end

.infer_localeObject



25
26
27
28
29
30
# File 'lib/fb-channel-file/engine.rb', line 25

def infer_locale
  # a list of supported locales are here https://www.facebook.com/translations/FacebookLocales.xml
  # default to en_US if locale not set with language
  locale = I18n.locale.to_s.sub(/-/, "_")
  locale.index(/_/) ? locale : default_config[:locale]
end

.localeObject



21
22
23
# File 'lib/fb-channel-file/engine.rb', line 21

def locale
  config[:infer_locale] ? infer_locale : config[:locale]
end