rack_phantom 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/examples/rack_app/Gemfile +4 -0
- data/examples/rack_app/README.md +15 -0
- data/examples/rack_app/app.rb +8 -0
- data/lib/rack_phantom.rb +2 -1
- data/lib/rack_phantom/version.rb +1 -1
- data/spec/rack_phantom_spec.rb +2 -4
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebb02e8354733ee6342887c0e9f145e22b2fd218
|
4
|
+
data.tar.gz: f05f9240c4f8ac532c89a69223b257b3391824d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab119eb22401043356fbecd77b85657482ab961c2bf7851281f8b25de3ba7bd6d81ce44e49feefa842d93900472c75591b36e377df54f2812504845e605585be
|
7
|
+
data.tar.gz: f6510e5a33ec5a48a818cbbacfbe52916849be1245f923fd6581d02317c1eb577a860f54e7bc7718eeec09bc76d75008e8a49df3631cde4fa97a661f614e8d21
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# RackPhantom Sinatra Example
|
2
|
+
|
3
|
+
## Run
|
4
|
+
|
5
|
+
```bash
|
6
|
+
bundle install
|
7
|
+
bundle exec ruby app.rb
|
8
|
+
```
|
9
|
+
|
10
|
+
## Demo
|
11
|
+
|
12
|
+
```bash
|
13
|
+
curl http://localtest.me:4567/ # regular request
|
14
|
+
curl -A "Googlebot" http://localtest.me:4567/ # request as google bot
|
15
|
+
```
|
data/lib/rack_phantom.rb
CHANGED
@@ -21,7 +21,8 @@ module RackPhantom
|
|
21
21
|
|
22
22
|
return [status, headers, response] unless render?(headers, env)
|
23
23
|
|
24
|
-
|
24
|
+
response = response.join("\n").gsub("\"", "\\\"")
|
25
|
+
html = Phantomjs.run(render_js, %["#{response}"]).strip
|
25
26
|
headers['Content-Length'] = html.length.to_s
|
26
27
|
|
27
28
|
[status, headers, [html]]
|
data/lib/rack_phantom/version.rb
CHANGED
data/spec/rack_phantom_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe RackPhantom do
|
4
4
|
|
5
|
-
let(:html) { %q{<html><head><script>document.write("Hello World");</script></head><body></body></html>} }
|
5
|
+
let(:html) { %q{<html><head><script>document.write("Hello' World");</script></head><body></body></html>} }
|
6
6
|
let(:real_app) { ->(env) { [200, {'Content-Type' => 'text/html'}, [html]] } }
|
7
7
|
let(:app) { RackPhantom::Middleware.new(real_app) }
|
8
8
|
|
@@ -19,10 +19,8 @@ describe RackPhantom do
|
|
19
19
|
last_response.headers['Content-Length'].should == evaluated_html.length.to_s
|
20
20
|
end
|
21
21
|
|
22
|
-
it 'escapes the single quotes'
|
23
|
-
|
24
22
|
def evaluated_html
|
25
|
-
%q{<html><head><script>document.write("Hello World");</script></head><body>Hello World</body></html>}
|
23
|
+
%q{<html><head><script>document.write("Hello' World");</script></head><body>Hello' World</body></html>}
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack_phantom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Selva
|
@@ -110,6 +110,9 @@ files:
|
|
110
110
|
- LICENSE.txt
|
111
111
|
- README.md
|
112
112
|
- Rakefile
|
113
|
+
- examples/rack_app/Gemfile
|
114
|
+
- examples/rack_app/README.md
|
115
|
+
- examples/rack_app/app.rb
|
113
116
|
- js/render.js
|
114
117
|
- lib/rack_phantom.rb
|
115
118
|
- lib/rack_phantom/railtie.rb
|