prerender_rails 0.1.1 → 0.1.2
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 +1 -1
- data/prerender_rails.gemspec +1 -1
- data/test/lib/prerender_rails.rb +8 -1
- 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: fffaf338614d81a13df75539ed9de2fc2f63fcea
|
4
|
+
data.tar.gz: 94b5487d1000a7caaec217c920a5ec0c9a56a5d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d75bdcd348a45c45502d0d7632329717185b730ecae77f536c304421fc8777fcd64a5c392df13d2f1e7b32303a9fb93265f377594bd0cc30d4cea8cf47176d5
|
7
|
+
data.tar.gz: 82898b819d8bcc33a2e04f5da1f05da53641c5a1c3d4bcadbfc614286989f063a8a3ad85d0d5b3705b1ed105ed72415c73b36c5103c7282065552ab6b1de3011
|
data/lib/prerender_rails.rb
CHANGED
@@ -79,7 +79,7 @@ module Rack
|
|
79
79
|
|
80
80
|
request = Rack::Request.new(env)
|
81
81
|
|
82
|
-
return true if request.query_string.
|
82
|
+
return true if Rack::Utils.parse_query(request.query_string).has_key?('_escaped_fragment_')
|
83
83
|
|
84
84
|
#if it is not a bot...dont prerender
|
85
85
|
return false if @crawler_user_agents.all? { |crawler_user_agent| !user_agent.downcase.include?(crawler_user_agent.downcase) }
|
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.2"
|
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
@@ -22,13 +22,20 @@ describe Rack::Prerender do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should return a prerendered reponse if user is a bot by checking for _escaped_fragment_" do
|
25
|
-
request = Rack::MockRequest.env_for "/path?_escaped_fragment_=
|
25
|
+
request = Rack::MockRequest.env_for "/path?_escaped_fragment_=", "HTTP_USER_AGENT" => user
|
26
26
|
stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
|
27
27
|
response = Rack::Prerender.new(@app).call(request)
|
28
28
|
|
29
29
|
assert_equal response[2].body, ["<html></html>"]
|
30
30
|
end
|
31
31
|
|
32
|
+
it "should continue to app routes if the url is a bad url with _escaped_fragment_" do
|
33
|
+
request = Rack::MockRequest.env_for "/path?query=string?_escaped_fragment_=", "HTTP_USER_AGENT" => user
|
34
|
+
response = Rack::Prerender.new(@app).call(request)
|
35
|
+
|
36
|
+
assert_equal response[2], ""
|
37
|
+
end
|
38
|
+
|
32
39
|
it "should continue to app routes if user is not a bot by checking agent string" do
|
33
40
|
request = Rack::MockRequest.env_for "/", "HTTP_USER_AGENT" => user
|
34
41
|
response = Rack::Prerender.new(@app).call(request)
|
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.2
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|