Class: Ixtlan::CmsScript

Inherits:
Object
  • Object
show all
Defined in:
lib/ixtlan/cms_script.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, rootpath = "/ixtlan") ⇒ CmsScript

Returns a new instance of CmsScript.



3
4
5
6
# File 'lib/ixtlan/cms_script.rb', line 3

def initialize(app, rootpath = "/ixtlan")
  @app = app
  @rootpath = rootpath
end

Instance Method Details

#_call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/ixtlan/cms_script.rb', line 12

def _call(env)
  if(env['REQUEST_PATH'] =~ /^#{@rootpath}\//)

    file = Rails.public_path.to_s + env['REQUEST_PATH'].sub(/^#{@rootpath}/, '')
    @file = File.open(file)
    [@status, {}, self]
  else
    @app.call(env)
  end
end

#call(env) ⇒ Object



8
9
10
# File 'lib/ixtlan/cms_script.rb', line 8

def call(env)
  dup._call(env)
end

#each(&block) ⇒ Object



23
24
25
26
27
# File 'lib/ixtlan/cms_script.rb', line 23

def each(&block)
  @file.each do |line|
    block.call(line.sub(/<\/head>/, "<link type='text/css' rel='stylesheet' href='#{@rootpath}/embed.css'></link><script type='text/javascript' language='javascript' src='#{@rootpath}/embed.nocache.js'></script></head>"))
  end
end