grover 1.1.11 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/grover/configuration.rb +4 -2
- data/lib/grover/js/processor.cjs +6 -0
- data/lib/grover/middleware.rb +7 -2
- data/lib/grover/processor.rb +1 -1
- data/lib/grover/version.rb +1 -1
- metadata +4 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1123f5ad0b72c13278999e8898b76407182df98c27e63061b5cbeeb8618b590
|
4
|
+
data.tar.gz: 49f20ea08de4248f4e5b28f7a8437831ae2cd25c0135b86cfbf51cb75c7bd26f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 985f49e244a7cfcc269b2240327f8da6639419a1343ced83cf119a0c5061cb04f2611d6672183ebd779b1f00f281db3a81aa7b6a1872ad49acfe89c5be75c2ed
|
7
|
+
data.tar.gz: 34eb183e68ab09b523acecb65e60be51131e518a54a6d0d6ea00ab70c2229070c842caf5326fd789d22ab0b990109b57fa742c1ff70bdf0b3ae6af6d2bf8ede1
|
data/lib/grover/configuration.rb
CHANGED
@@ -7,9 +7,10 @@ class Grover
|
|
7
7
|
class Configuration
|
8
8
|
attr_accessor :options, :meta_tag_prefix, :ignore_path, :ignore_request,
|
9
9
|
:root_url, :use_pdf_middleware, :use_png_middleware,
|
10
|
-
:use_jpeg_middleware, :
|
10
|
+
:use_jpeg_middleware, :js_runtime_bin,
|
11
|
+
:node_env_vars, :allow_file_uris
|
11
12
|
|
12
|
-
def initialize
|
13
|
+
def initialize # rubocop:disable Metrics/MethodLength
|
13
14
|
@options = {}
|
14
15
|
@meta_tag_prefix = 'grover-'
|
15
16
|
@ignore_path = nil
|
@@ -18,6 +19,7 @@ class Grover
|
|
18
19
|
@use_pdf_middleware = true
|
19
20
|
@use_png_middleware = false
|
20
21
|
@use_jpeg_middleware = false
|
22
|
+
@js_runtime_bin = ['node']
|
21
23
|
@node_env_vars = {}
|
22
24
|
@allow_file_uris = false
|
23
25
|
end
|
data/lib/grover/js/processor.cjs
CHANGED
@@ -184,6 +184,12 @@ const _processPage = (async (convertAction, uriOrHtml, options) => {
|
|
184
184
|
await page.setGeolocation(geolocation);
|
185
185
|
}
|
186
186
|
|
187
|
+
// If specified, add script to evaluate before the page loads
|
188
|
+
const evaluateOnNewDocument = options.evaluateOnNewDocument; delete options.evaluateOnNewDocument;
|
189
|
+
if (evaluateOnNewDocument !== undefined) {
|
190
|
+
await page.evaluateOnNewDocument(evaluateOnNewDocument);
|
191
|
+
}
|
192
|
+
|
187
193
|
const raiseOnRequestFailure = options.raiseOnRequestFailure; delete options.raiseOnRequestFailure;
|
188
194
|
if (raiseOnRequestFailure) {
|
189
195
|
page.on('requestfinished', (request) => {
|
data/lib/grover/middleware.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'combine_pdf'
|
4
|
-
|
5
3
|
class Grover
|
6
4
|
#
|
7
5
|
# Rack middleware for catching PDF requests and returning the upstream HTML as a PDF
|
@@ -132,12 +130,19 @@ class Grover
|
|
132
130
|
end
|
133
131
|
|
134
132
|
def add_cover_content(grover)
|
133
|
+
load_combine_pdf
|
135
134
|
pdf = CombinePDF.parse grover.to_pdf
|
136
135
|
pdf >> fetch_cover_pdf(grover.front_cover_path) if grover.show_front_cover?
|
137
136
|
pdf << fetch_cover_pdf(grover.back_cover_path) if grover.show_back_cover?
|
138
137
|
pdf.to_pdf
|
139
138
|
end
|
140
139
|
|
140
|
+
def load_combine_pdf
|
141
|
+
require 'combine_pdf'
|
142
|
+
rescue ::LoadError
|
143
|
+
raise Grover::Error, 'Please add/install the "combine_pdf" gem to use the front/back cover page feature'
|
144
|
+
end
|
145
|
+
|
141
146
|
def fetch_cover_pdf(path)
|
142
147
|
temp_env = env.deep_dup
|
143
148
|
scrub_env! temp_env
|
data/lib/grover/processor.rb
CHANGED
@@ -33,7 +33,7 @@ class Grover
|
|
33
33
|
def spawn_process
|
34
34
|
@stdin, @stdout, @stderr, @wait_thr = Open3.popen3(
|
35
35
|
Grover.configuration.node_env_vars,
|
36
|
-
|
36
|
+
*Grover.configuration.js_runtime_bin,
|
37
37
|
File.expand_path(File.join(__dir__, 'js/processor.cjs')),
|
38
38
|
chdir: app_root
|
39
39
|
)
|
data/lib/grover/version.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Bromwich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: combine_pdf
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: nokogiri
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - "~>"
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
19
|
+
version: '1'
|
34
20
|
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - "~>"
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1
|
26
|
+
version: '1'
|
41
27
|
description: Transform HTML into PDF/PNG/JPEG using Google Puppeteer/Chromium
|
42
28
|
email:
|
43
29
|
- abromwich@studiosity.com
|