Sha256: 19f0d17ccb16ee9c011fd6be119f40383b0724e2acc34448ff2a8a83640d2155

Contents?: true

Size: 750 Bytes

Versions: 10

Compression:

Stored size: 750 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

10 entries across 10 versions & 1 rubygems

Version Path
ixtlan-0.4.3 lib/ixtlan/cms_script.rb
ixtlan-0.4.2 lib/ixtlan/cms_script.rb
ixtlan-0.4.1 lib/ixtlan/cms_script.rb
ixtlan-0.4.0 lib/ixtlan/cms_script.rb
ixtlan-0.4.0.pre5 lib/ixtlan/cms_script.rb
ixtlan-0.4.0.pre4 lib/ixtlan/cms_script.rb
ixtlan-0.4.0.pre3 lib/ixtlan/cms_script.rb
ixtlan-0.4.0.pre2 lib/ixtlan/cms_script.rb
ixtlan-0.4.0.pre lib/ixtlan/cms_script.rb
ixtlan-0.3.0 lib/ixtlan/cms_script.rb