grover 0.12.1 → 0.12.2
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: eca69ef126018fb963db3b2ee4e17a4773971e1bd941c40deb461a656b06a0f7
|
4
|
+
data.tar.gz: dee3ebaaf0803fed402a3a5406c3584b431c1addddc1547582e31cbb2f47b6d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18f211457a4a08cc875ab3ce744d34b2c2cb8a0d31ff351b6cddec27433443e33f666d9693d6520112ac6f66c262c8e521e098e57245ab8b9691b03957f27c54
|
7
|
+
data.tar.gz: 13b8f5759db9786e3a98a3fbc9e2c2564b2d21c3a6f95d3d24e056b34c19325c1b647b7f2fa80b9138634808ad0472f9746c5f6a2be04afe95ad7284e3cb3438
|
@@ -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: 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.2
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: combine_pdf
|