prerender_rails 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -1
- data/README.md +3 -1
- data/lib/prerender_rails.rb +2 -2
- data/prerender_rails.gemspec +1 -1
- data/test/lib/prerender_rails.rb +6 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ae62eb11cd28b731ae1fcbe0c737748e6efb9ab
|
4
|
+
data.tar.gz: 1f5227b5f8aebdb0d6af3dfd13571d456b6a6175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21aa10c6a922512f53d23d08acc7bd5f288926a14e880f49552f65a363c6ed2d2075acb64f67e3434a48dc79b9bf96056d6ed69fe3bee7368b3cd73c4a8021f8
|
7
|
+
data.tar.gz: 5e5ff5959804c54bca5f483862b10641b57eaea17ccbd360b5e41f0da4d4f5ab75a9b05e2d78c053c56b6ab3a3e5de8537cb6eef75a799421192c917cbebbae7
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,7 +3,9 @@ Prerender Rails [![Build Status](https://travis-ci.org/collectiveip/prerender_ra
|
|
3
3
|
|
4
4
|
Are you using backbone, angular, emberjs, etc, but you're unsure about the SEO implications?
|
5
5
|
|
6
|
-
Use this gem to install rails middleware that prerenders a javascript-rendered page and returns the HTML to the search engine crawler for SEO.
|
6
|
+
Use this gem to install rails middleware that prerenders a javascript-rendered page using an external service and returns the HTML to the search engine crawler for SEO.
|
7
|
+
|
8
|
+
`Note:` Make sure you have more than one webserver thread/process running because the prerender service will make a request to your server to render the HTML.
|
7
9
|
|
8
10
|
Add this line to your application's Gemfile:
|
9
11
|
|
data/lib/prerender_rails.rb
CHANGED
@@ -49,13 +49,13 @@ module Rack
|
|
49
49
|
request = Rack::Request.new(env)
|
50
50
|
|
51
51
|
#if it is not a bot...dont prerender
|
52
|
-
return false if
|
52
|
+
return false if @crawler_user_agents.all? { |crawler_user_agent| !user_agent.downcase.include?(crawler_user_agent.downcase) }
|
53
53
|
|
54
54
|
#if it is a bot and is requesting a resource...dont prerender
|
55
55
|
return false if @extensions_to_ignore.any? { |extension| request.path.include? extension }
|
56
56
|
|
57
57
|
#if it is a bot and not requesting a resource and is not whitelisted...dont prerender
|
58
|
-
return false if @options[:whitelist].is_a?(Array) && @options[:whitelist].all? { |whitelisted|
|
58
|
+
return false if @options[:whitelist].is_a?(Array) && @options[:whitelist].all? { |whitelisted| !Regexp.new(whitelisted).match(request.path) }
|
59
59
|
|
60
60
|
#if it is a bot and not requesting a resource and is not blacklisted(url or referer)...dont prerender
|
61
61
|
if @options[:blacklist].is_a?(Array) && @options[:blacklist].any? { |blacklisted|
|
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.0.
|
5
|
+
spec.version = "0.0.6"
|
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
@@ -44,13 +44,13 @@ describe Rack::Prerender do
|
|
44
44
|
|
45
45
|
it "should continue to app routes if the url is not part of the regex specific whitelist" do
|
46
46
|
request = Rack::MockRequest.env_for "/saved/search/blah", "HTTP_USER_AGENT" => bot
|
47
|
-
response = Rack::Prerender.new(@app, whitelist: ['
|
47
|
+
response = Rack::Prerender.new(@app, whitelist: ['^/search', '/help']).call(request)
|
48
48
|
|
49
49
|
assert_equal response[2], ""
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should return a prerendered response if the url is part of the whitelist" do
|
53
|
-
request = Rack::MockRequest.env_for "/search/things
|
53
|
+
request = Rack::MockRequest.env_for "/search/things/123/page", "HTTP_USER_AGENT" => bot
|
54
54
|
stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
|
55
55
|
response = Rack::Prerender.new(@app, whitelist: ['/search', '/help']).call(request)
|
56
56
|
|
@@ -58,22 +58,22 @@ describe Rack::Prerender do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should return a prerendered response if the url is part of the regex specific whitelist" do
|
61
|
-
request = Rack::MockRequest.env_for "/search/things
|
61
|
+
request = Rack::MockRequest.env_for "/search/things/123/page", "HTTP_USER_AGENT" => bot
|
62
62
|
stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
|
63
|
-
response = Rack::Prerender.new(@app, whitelist: ['^/search.*
|
63
|
+
response = Rack::Prerender.new(@app, whitelist: ['^/search.*page', '/help']).call(request)
|
64
64
|
|
65
65
|
assert_equal response[2].body, ["<html></html>"]
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should continue to app routes if the url is part of the blacklist" do
|
69
|
-
request = Rack::MockRequest.env_for "/search/things
|
69
|
+
request = Rack::MockRequest.env_for "/search/things/123/page", "HTTP_USER_AGENT" => bot
|
70
70
|
response = Rack::Prerender.new(@app, blacklist: ['/search', '/help']).call(request)
|
71
71
|
|
72
72
|
assert_equal response[2], ""
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should continue to app routes if the url is part of the regex specific blacklist" do
|
76
|
-
request = Rack::MockRequest.env_for "/search/things
|
76
|
+
request = Rack::MockRequest.env_for "/search/things/123/page", "HTTP_USER_AGENT" => bot
|
77
77
|
response = Rack::Prerender.new(@app, blacklist: ['^/search', '/help']).call(request)
|
78
78
|
|
79
79
|
assert_equal response[2], ""
|
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.0.
|
4
|
+
version: 0.0.6
|
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-
|
11
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
106
|
rubyforge_project:
|
107
|
-
rubygems_version: 2.
|
107
|
+
rubygems_version: 2.1.5
|
108
108
|
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Prerender your backbone/angular/javascript rendered application on the fly
|