grover 0.12.1 → 0.12.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grover/html_preprocessor.rb +2 -2
- data/lib/grover/js/processor.js +7 -0
- data/lib/grover/middleware.rb +8 -2
- data/lib/grover/processor.rb +1 -1
- data/lib/grover/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7376874743ddb5f08d3fc68c02f84a72eb6cbe98c63306b2ce2a5f57d37867c9
|
4
|
+
data.tar.gz: 546007fe354d88c117f70469c8cf80ba88fd22415ebb350aa79512c64592be3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 010bb2d49e78af9cfe56cc0480d803f217dd1f644d99d36640fad060e8a70a2be7b4d422057a761a5d0710347649dd44d3da9efde553b4ff23bff62838973af0
|
7
|
+
data.tar.gz: 5879e39b9d00a6b1c5904a4e71cdf00fc695caa29de7b85ca4dbcbf7ec857d87822c2be42ded362efd3ef2466f8c5db338182e8115cbe6b4b822a6114d5e50d8
|
@@ -17,13 +17,13 @@ class Grover
|
|
17
17
|
|
18
18
|
def self.translate_relative_paths(html, root_url)
|
19
19
|
# Try out this regexp using rubular http://rubular.com/r/hiAxBNX7KE
|
20
|
-
html.gsub(%r{(href|src)=(['"])/([^/"']([
|
20
|
+
html.gsub(%r{(href|src)=(['"])/([^/"']([^"']*|[^"']*))?['"]}, "\\1=\\2#{root_url}\\3\\2")
|
21
21
|
end
|
22
22
|
private_class_method :translate_relative_paths
|
23
23
|
|
24
24
|
def self.translate_relative_protocols(body, protocol)
|
25
25
|
# Try out this regexp using rubular http://rubular.com/r/0Ohk0wFYxV
|
26
|
-
body.gsub(%r{(href|src)=(['"])//([
|
26
|
+
body.gsub(%r{(href|src)=(['"])//([^"']*|[^"']*)['"]}, "\\1=\\2#{protocol}://\\3\\2")
|
27
27
|
end
|
28
28
|
private_class_method :translate_relative_protocols
|
29
29
|
end
|
data/lib/grover/js/processor.js
CHANGED
@@ -107,6 +107,13 @@ const _processPage = (async (convertAction, urlOrHtml, options) => {
|
|
107
107
|
await page.evaluate(executeScript);
|
108
108
|
}
|
109
109
|
|
110
|
+
// If specified, wait for selector
|
111
|
+
const waitForSelector = options.waitForSelector; delete options.waitForSelector;
|
112
|
+
const waitForSelectorOptions = options.waitForSelectorOptions; delete options.waitForSelectorOptions;
|
113
|
+
if (waitForSelector !== undefined) {
|
114
|
+
await page.waitForSelector(waitForSelector, waitForSelectorOptions)
|
115
|
+
}
|
116
|
+
|
110
117
|
// If we're running puppeteer in headless mode, return the converted PDF
|
111
118
|
if (debug === undefined || (typeof debug === 'object' && (debug.headless === undefined || debug.headless))) {
|
112
119
|
return await page[convertAction](options);
|
data/lib/grover/middleware.rb
CHANGED
@@ -97,9 +97,15 @@ class Grover
|
|
97
97
|
def create_grover_for_response(response)
|
98
98
|
body = response.respond_to?(:body) ? response.body : response.join
|
99
99
|
body = body.join if body.is_a?(Array)
|
100
|
-
|
101
100
|
body = HTMLPreprocessor.process body, root_url, protocol
|
102
|
-
|
101
|
+
|
102
|
+
options = { display_url: request_url }
|
103
|
+
cookies = Rack::Utils.parse_cookies(env).map do |name, value|
|
104
|
+
{ name: name, value: Rack::Utils.escape(value), domain: env['HTTP_HOST'] }
|
105
|
+
end
|
106
|
+
options[:cookies] = cookies if cookies.any?
|
107
|
+
|
108
|
+
Grover.new(body, options)
|
103
109
|
end
|
104
110
|
|
105
111
|
def add_cover_content(grover)
|
data/lib/grover/processor.rb
CHANGED
data/lib/grover/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Bromwich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: combine_pdf
|