prerender_rails 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/prerender_rails.rb +3 -1
- data/prerender_rails.gemspec +1 -1
- data/test/lib/prerender_rails.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f6ccf511a4930229738289e20a58cd4563699b9
|
4
|
+
data.tar.gz: bd43962bf1bb2388b622903626cae2d7f0f6c86a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78c2a53a69a90f6b39b3cf72b456d74880376af05e73503c82603c8988ee5a79116d0264a555e302c05c1b0c91177ffd9876dc0ebbd594e93b8f42a52a3f06d0
|
7
|
+
data.tar.gz: e23f7ab089d525a29f7d6c902722147722c6fabad1cf4d8caf90bc81aac6985012aa0b085402a5b433919b9fba5aeaf976db9b9484ae1eb8a5735297670cd0ad
|
data/lib/prerender_rails.rb
CHANGED
@@ -110,7 +110,9 @@ module Rack
|
|
110
110
|
|
111
111
|
def get_prerendered_page_response(env)
|
112
112
|
begin
|
113
|
-
|
113
|
+
url = URI.parse(build_api_url(env))
|
114
|
+
req = Net::HTTP::Get.new(url.request_uri, { 'User-Agent' => env['HTTP_USER_AGENT'] })
|
115
|
+
response = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
|
114
116
|
rescue
|
115
117
|
nil
|
116
118
|
end
|
data/prerender_rails.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "prerender_rails"
|
5
|
-
spec.version = "0.1.
|
5
|
+
spec.version = "0.1.5"
|
6
6
|
spec.authors = ["Todd Hooper"]
|
7
7
|
spec.email = ["todd@collectiveip.com"]
|
8
8
|
spec.description = %q{Rails middleware to prerender your javascript heavy pages on the fly by a phantomjs service}
|
data/test/lib/prerender_rails.rb
CHANGED
@@ -15,7 +15,7 @@ describe Rack::Prerender do
|
|
15
15
|
|
16
16
|
it "should return a prerendered response for a crawler with the returned status code" do
|
17
17
|
request = Rack::MockRequest.env_for "/", "HTTP_USER_AGENT" => bot
|
18
|
-
stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>", :status => 201)
|
18
|
+
stub_request(:get, @prerender.build_api_url(request)).with(:headers => { 'User-Agent' => bot }).to_return(:body => "<html></html>", :status => 201)
|
19
19
|
response = Rack::Prerender.new(@app).call(request)
|
20
20
|
|
21
21
|
assert_equal response[2].body, ["<html></html>"]
|
@@ -24,7 +24,7 @@ describe Rack::Prerender do
|
|
24
24
|
|
25
25
|
it "should return a prerendered reponse if user is a bot by checking for _escaped_fragment_" do
|
26
26
|
request = Rack::MockRequest.env_for "/path?_escaped_fragment_=", "HTTP_USER_AGENT" => user
|
27
|
-
stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
|
27
|
+
stub_request(:get, @prerender.build_api_url(request)).with(:headers => { 'User-Agent' => user }).to_return(:body => "<html></html>")
|
28
28
|
response = Rack::Prerender.new(@app).call(request)
|
29
29
|
|
30
30
|
assert_equal response[2].body, ["<html></html>"]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prerender_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Hooper
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|