prerender_rails 0.0.4 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5013e7eaea9bbf3be69499894144a70bf904911
4
- data.tar.gz: a25e41c1f16f935222447687ff1e85f49e357f34
3
+ metadata.gz: 6ae62eb11cd28b731ae1fcbe0c737748e6efb9ab
4
+ data.tar.gz: 1f5227b5f8aebdb0d6af3dfd13571d456b6a6175
5
5
  SHA512:
6
- metadata.gz: 4e4005a4509b94bda2ec6783f7b0a2ba5bc6c3203257cb5cb57cbda056c5c52a92f6e0758fcc252eb8fbf0fab5016a2725d0aa29bccafd2518f4ded7954a72bd
7
- data.tar.gz: 85ce4274d97f7148160fdba543e7c8c3784d47e48f7c2183d9d040e4b08593158802d8d6c2d5fd2b31b64b1773bf5a41b04c4842d44761e70459c4ed5c04bd5c
6
+ metadata.gz: 21aa10c6a922512f53d23d08acc7bd5f288926a14e880f49552f65a363c6ed2d2075acb64f67e3434a48dc79b9bf96056d6ed69fe3bee7368b3cd73c4a8021f8
7
+ data.tar.gz: 5e5ff5959804c54bca5f483862b10641b57eaea17ccbd360b5e41f0da4d4f5ab75a9b05e2d78c053c56b6ab3a3e5de8537cb6eef75a799421192c917cbebbae7
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
- source 'https://rubygems.org'
1
+ # source 'https://rubygems.org'
2
+ source 'https://s3.amazonaws.com/production.s3.rubygems.org/'
2
3
 
3
4
  # Specify your gem's dependencies in prerender_rails.gemspec
4
5
  gemspec
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
 
@@ -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 !@crawler_user_agents.include?(user_agent.downcase)
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| !!Regexp.new(whitelisted).match(request.path) }
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|
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prerender_rails"
5
- spec.version = "0.0.4"
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}
@@ -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: ['/search', '/help']).call(request)
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?query=blah", "HTTP_USER_AGENT" => bot
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?query=blah", "HTTP_USER_AGENT" => bot
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.*query', '/help']).call(request)
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?query=blah", "HTTP_USER_AGENT" => bot
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?query=blah", "HTTP_USER_AGENT" => bot
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
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-09-29 00:00:00.000000000 Z
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.0.6
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