Sha256: 7f6dff59812336a525a6ff3ebaa47dcdd6ef17ae964f5de0291db7b166c0296d
Contents?: true
Size: 1.58 KB
Versions: 1
Compression:
Stored size: 1.58 KB
Contents
# MIT License module Rack class XSLView def initialize(app, options) @my_path_info = String.new @app = app @myhash = {} @options = {:myxsl => nil}.merge(options) if @options[:myxsl] == nil @xslt = XML::XSLT.new() @xslt.xsl = File.join(File.dirname(__FILE__), 'output.xhtml10.xsl') else @xslt = @options[:myxsl] end end def call(env) if checknoxsl(env) @app.call(env) else unless @options[:passenv] == nil @options[:passenv].each { |envkey| if (mp = env[envkey]) @myhash[envkey] = "#{mp}" end } @xslt.parameters = @myhash end status, headers, body = @app.call(env) # Obtain entire request body parts = '' body.each { |part| parts << part.to_s } # TODO Refactor if ((parts.include? "<html") || !(parts.include? "<")) [status, headers, body] else headers.delete('Content-Length') @xslt.xml = parts newbody = @xslt.serve headers['Content-Length'] = newbody.length.to_s [status, headers, newbody] end end end private def choosesheet(env) @options[:xslhash].each_key { |path| if env["PATH_INFO"].index(path) return @options[:xslhash][path] end } return false end def checknoxsl(env) @options[:noxsl].each { |path| if env["PATH_INFO"].index(path) return true end } return false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rack-xslview-0.1.0 | lib/rack-xslview.rb |