Class: Strobe::Addons::Social

Inherits:
Object
  • Object
show all
Defined in:
lib/strobe/addons/social.rb,
lib/strobe/addons/social/twitter.rb,
lib/strobe/addons/social/facebook.rb

Defined Under Namespace

Classes: Facebook, Twitter

Constant Summary collapse

ADDON_PATH =
%r[/([^/]+)(/.*)?]i

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ Social

Returns a new instance of Social.



6
7
8
# File 'lib/strobe/addons/social.rb', line 6

def initialize(settings)
  @settings = settings
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/strobe/addons/social.rb', line 10

def call(env)
  if env["PATH_INFO"] =~ ADDON_PATH
    addon, path = $1, $2

    env = env.merge("SCRIPT_NAME" => "/_strobe/social/#{addon}", "PATH_INFO" => path || "")

    if addon_class = find_addon(addon)
      addon_class.new(@settings).call(env)
    else
      [404, {}, ["Not found"]]
    end
  else
    [404, {}, ["Not found"]]
  end
end