Sha256: c0cf8b24e27694c9ccbea6ae828f4d6ce151f7e7788b61a1b39513c3b805bb71

Contents?: true

Size: 770 Bytes

Versions: 5

Compression:

Stored size: 770 Bytes

Contents

module Ixtlan
  class CmsScript
    def initialize(app, rootpath = "/ixtlan")
      @app = app
      @rootpath = rootpath
    end
    
    def call(env)
      dup._call(env)
    end
    
    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
    
    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
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ixtlan-0.2.4 lib/ixtlan/cms_script.rb
ixtlan-0.2.3 lib/ixtlan/cms_script.rb
ixtlan-0.2.2 lib/ixtlan/cms_script.rb
ixtlan-0.2.1 lib/ixtlan/cms_script.rb
ixtlan-0.2.0 lib/ixtlan/cms_script.rb