rack-xslview 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/rack-xslview.rb +19 -16
- data/test/rack-xslview_test.rb +1 -0
- metadata +2 -2
data/README.md
CHANGED
@@ -27,14 +27,13 @@ xslhash.default("/path/to/output.xhtml10.xsl")
|
|
27
27
|
|
28
28
|
# Use the middleware
|
29
29
|
use Rack::XSLView, :myxsl => default_xsl, :noxsl => noxsl, :xslhash => xslhash
|
30
|
-
|
31
|
-
|
32
30
|
</pre>
|
33
31
|
|
34
32
|
|
35
33
|
Resources
|
36
34
|
---------
|
37
35
|
|
36
|
+
* <http://www.docunext.com/wiki/Rack-XSLView>
|
38
37
|
* <http://github.com/docunext/Rack-XSLView>
|
39
38
|
|
40
39
|
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/rack-xslview.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# MIT License
|
1
2
|
module Rack
|
2
3
|
class XSLView
|
3
4
|
def initialize(app, options)
|
@@ -6,7 +7,7 @@ module Rack
|
|
6
7
|
@myhash = {}
|
7
8
|
@options = {:myxsl => nil}.merge(options)
|
8
9
|
if @options[:myxsl] == nil
|
9
|
-
@xslt =
|
10
|
+
@xslt = XML::XSLT.new()
|
10
11
|
@xslt.xsl = File.join(File.dirname(__FILE__), 'output.xhtml10.xsl')
|
11
12
|
else
|
12
13
|
@xslt = @options[:myxsl]
|
@@ -25,23 +26,25 @@ module Rack
|
|
25
26
|
}
|
26
27
|
@xslt.parameters = @myhash
|
27
28
|
end
|
28
|
-
status, headers,
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
29
|
+
status, headers, body = @app.call(env)
|
30
|
+
|
31
|
+
# Obtain entire request body
|
32
|
+
parts = ''
|
33
|
+
body.each { |part| parts << part.to_s }
|
34
|
+
|
35
|
+
# TODO Refactor
|
36
|
+
if ((parts.include? "<html") || !(parts.include? "<"))
|
37
|
+
[status, headers, body]
|
38
|
+
else
|
39
|
+
headers.delete('Content-Length')
|
40
|
+
@xslt.xml = parts
|
41
|
+
newbody = @xslt.serve
|
42
|
+
headers['Content-Length'] = newbody.length.to_s
|
43
|
+
[status, headers, newbody]
|
44
|
+
end
|
43
45
|
end
|
44
46
|
end
|
47
|
+
|
45
48
|
private
|
46
49
|
def choosesheet(env)
|
47
50
|
@options[:xslhash].each_key { |path|
|
data/test/rack-xslview_test.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-xslview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Albert Lash
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2010-02-19 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|