prerender_rails 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0dab2fb1c0fb1a232b5901dde71f986ca4000c65
4
- data.tar.gz: 675b2dfbdede57ad5f448377aa964e304f5fea30
3
+ metadata.gz: d43e85db62f63e2851dd12ae260c62183fd9d15d
4
+ data.tar.gz: e2d6b324f559ee75823216fdf975b4b82a640c5b
5
5
  SHA512:
6
- metadata.gz: 748be26bea44cae70d7c0f5197f1e54aeede93c8951868e70d5acc7d6a620fb86deac649a8a71b4bd07c81e26ab73af9b79c09316e5362ec8a0d60afaa35bfc2
7
- data.tar.gz: e34eb14973e15ec46bbbf9214aaad0bc688a8d9edc58b4148ec8828d2d447d55700bd7b0ebf7f8c8af56138340d1510a8d070bc7eba6379dd3dbc3b6e4293b5c
6
+ metadata.gz: 6dcf5e1db1abfe34f98ddde47d8ffa7fb66cebe19e4080555c5a77d068ed626bbad0c44249e4745a8af2cc4e57797944ac47ccb00aa96b3e19dae31ce821343a
7
+ data.tar.gz: ed2c1c3ba07f330f589f2c15b09bb3822dae1a4e438a851587adfd7b6199830a47b0d6634a69f0da18385c11a3b6bb75a72e314b0dac69d10e4b75ca1ecd04b4
data/.travis.yml CHANGED
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.0.0
3
+ - 2.2.2
data/README.md CHANGED
@@ -32,6 +32,8 @@ or if you have an account on [prerender.io](http://prerender.io) and want to use
32
32
 
33
33
  ## Testing
34
34
 
35
+ When testing make sure you're not using a single threaded application server like default WEBrick one, use Puma or Unicorn.
36
+
35
37
  If your URLs use a hash-bang:
36
38
 
37
39
  If you want to see `http://localhost:5000/#!/profiles/1234`
@@ -23,11 +23,13 @@ module Rack
23
23
  'outbrain',
24
24
  'pinterest',
25
25
  'developers.google.com/+/web/snippet',
26
+ 'www.google.com/webmasters/tools/richsnippets',
26
27
  'slackbot',
27
28
  'vkShare',
28
29
  'W3C_Validator',
29
30
  'redditbot',
30
- 'Applebot'
31
+ 'Applebot',
32
+ 'Qwantify'
31
33
  ]
32
34
 
33
35
  @extensions_to_ignore = [
@@ -126,7 +128,7 @@ module Rack
126
128
  #if it is a bot and not requesting a resource and is not whitelisted...dont prerender
127
129
  return false if @options[:whitelist].is_a?(Array) && @options[:whitelist].all? { |whitelisted| !Regexp.new(whitelisted).match(request.fullpath) }
128
130
 
129
- #if it is a bot and not requesting a resource and is not blacklisted(url or referer)...dont prerender
131
+ #if it is a bot and not requesting a resource and is blacklisted(url or referer)...dont prerender
130
132
  if @options[:blacklist].is_a?(Array) && @options[:blacklist].any? { |blacklisted|
131
133
  blacklistedUrl = false
132
134
  blacklistedReferer = false
@@ -155,7 +157,9 @@ module Rack
155
157
  headers['X-Prerender-Token'] = @options[:prerender_token] if @options[:prerender_token]
156
158
  req = Net::HTTP::Get.new(url.request_uri, headers)
157
159
  req.basic_auth(ENV['PRERENDER_USERNAME'], ENV['PRERENDER_PASSWORD']) if @options[:basic_auth]
158
- response = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
160
+ http = Net::HTTP.new(url.host, url.port)
161
+ http.use_ssl = true if url.scheme == 'https'
162
+ response = http.request(req)
159
163
  if response['Content-Encoding'] == 'gzip'
160
164
  response.body = ActiveSupport::Gzip.decompress(response.body)
161
165
  response['Content-Length'] = response.body.length
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prerender_rails"
5
- spec.version = "1.3.0"
5
+ spec.version = "1.4.0"
6
6
  spec.authors = ["Todd Hooper"]
7
7
  spec.email = ["todd@prerender.io"]
8
8
  spec.description = %q{Rails middleware to prerender your javascript heavy pages on the fly by a phantomjs service}
@@ -74,6 +74,17 @@ describe Rack::Prerender do
74
74
  end
75
75
 
76
76
 
77
+ it "should set use_ssl to true for https prerender_service_url" do
78
+ @prerender = Rack::Prerender.new(@app, prerender_service_url: 'https://service.prerender.io/')
79
+
80
+ request = Rack::MockRequest.env_for "/search/things/123/page?_escaped_fragment_=", "HTTP_USER_AGENT" => bot
81
+ stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
82
+ response = @prerender.call(request)
83
+
84
+ assert_equal ["<html></html>"], response[2].body
85
+ end
86
+
87
+
77
88
  it "should return a prerendered response if the url is part of the regex specific whitelist" do
78
89
  request = Rack::MockRequest.env_for "/search/things/123/page?_escaped_fragment_=", "HTTP_USER_AGENT" => bot
79
90
  stub_request(:get, @prerender.build_api_url(request)).to_return(:body => "<html></html>")
@@ -164,6 +175,13 @@ describe Rack::Prerender do
164
175
  end
165
176
 
166
177
 
178
+ it "should build the correct https api url with an initialization variable url" do
179
+ @prerender = Rack::Prerender.new(@app, prerender_service_url: 'https://prerenderurl.com')
180
+ request = Rack::MockRequest.env_for "https://google.com/search?q=javascript"
181
+ assert_equal 'https://prerenderurl.com/https://google.com/search?q=javascript', @prerender.build_api_url(request)
182
+ end
183
+
184
+
167
185
  # Check CF-Visitor header in order to Work behind CloudFlare with Flexible SSL (https://support.cloudflare.com/hc/en-us/articles/200170536)
168
186
  it "should build the correct api url for the Cloudflare Flexible SSL support" do
169
187
  request = Rack::MockRequest.env_for "http://google.com/search?q=javascript", { 'CF-VISITOR' => '"scheme":"https"'}
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: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Hooper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2017-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.0.14
121
+ rubygems_version: 2.0.14.1
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Prerender your backbone/angular/javascript rendered application on the fly