prerender_rails 0.1.14 → 0.1.15
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 +6 -4
- data/prerender_rails.gemspec +1 -1
- data/test/lib/prerender_rails.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c5a0e13a7ff92ef76e7f5ff2deb051f59813548
|
4
|
+
data.tar.gz: 51e0c17346bb5edf7cb1cc9c386fd6cdb75243b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f56d9caa703f77b84fa2b875545e57fc6689529bb37a5a539a74a9ea5cbe17dc0badcd80064d4dc6196931a59afef112b8247de07c73b46e34fa4fd75902f83f
|
7
|
+
data.tar.gz: 2b3b92b91d2c8f9bc65c69826c122983206363618584019a49a4529760db02aab6b7b48ed6cb0550f71ac039dcb19b962ffabd15ebb561cdcc902aa58bd9ee56
|
data/lib/prerender_rails.rb
CHANGED
@@ -89,15 +89,17 @@ module Rack
|
|
89
89
|
|
90
90
|
def should_show_prerendered_page(env)
|
91
91
|
user_agent = env['HTTP_USER_AGENT']
|
92
|
+
is_requesting_prerendered_page = false
|
93
|
+
|
92
94
|
return false if !user_agent
|
93
95
|
return false if env['REQUEST_METHOD'] != 'GET'
|
94
96
|
|
95
97
|
request = Rack::Request.new(env)
|
96
98
|
|
97
|
-
|
99
|
+
is_requesting_prerendered_page = true if Rack::Utils.parse_query(request.query_string).has_key?('_escaped_fragment_')
|
98
100
|
|
99
|
-
#if it is
|
100
|
-
|
101
|
+
#if it is a bot...show prerendered page
|
102
|
+
is_requesting_prerendered_page = true if @crawler_user_agents.any? { |crawler_user_agent| user_agent.downcase.include?(crawler_user_agent.downcase) }
|
101
103
|
|
102
104
|
#if it is a bot and is requesting a resource...dont prerender
|
103
105
|
return false if @extensions_to_ignore.any? { |extension| request.path.include? extension }
|
@@ -119,7 +121,7 @@ module Rack
|
|
119
121
|
return false
|
120
122
|
end
|
121
123
|
|
122
|
-
return
|
124
|
+
return is_requesting_prerendered_page
|
123
125
|
end
|
124
126
|
|
125
127
|
|
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.15"
|
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
@@ -67,7 +67,7 @@ describe Rack::Prerender do
|
|
67
67
|
|
68
68
|
|
69
69
|
it "should continue to app routes if the url is not part of the regex specific whitelist" do
|
70
|
-
request = Rack::MockRequest.env_for "/saved/search/blah", "HTTP_USER_AGENT" => bot
|
70
|
+
request = Rack::MockRequest.env_for "/saved/search/blah?_escaped_fragment_=", "HTTP_USER_AGENT" => bot
|
71
71
|
response = Rack::Prerender.new(@app, whitelist: ['^/search', '/help']).call(request)
|
72
72
|
|
73
73
|
assert_equal "", response[2]
|
@@ -75,7 +75,7 @@ describe Rack::Prerender do
|
|
75
75
|
|
76
76
|
|
77
77
|
it "should return a prerendered response if the url is part of the regex specific whitelist" do
|
78
|
-
request = Rack::MockRequest.env_for "/search/things/123/page", "HTTP_USER_AGENT" => bot
|
78
|
+
request = Rack::MockRequest.env_for "/search/things/123/page?_escaped_fragment_=", "HTTP_USER_AGENT" => bot
|
79
79
|
stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
|
80
80
|
response = Rack::Prerender.new(@app, whitelist: ['^/search.*page', '/help']).call(request)
|
81
81
|
|