grover 1.1.11 → 1.2.0
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/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: 50a8ec2a93d7be70d77b4aefd45f6a87296cbd0201f3fba5a2d962fce511f4b7
|
4
|
+
data.tar.gz: 340a18b36da574c7cf57c897c3d767e890385279b681e345e2ba29cc5bf3430e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13124e1d70416020c29695bbf59f2618015def0d46d4d194c5ba514b4f4c48a2622adc6238c32254717601b50acaadc3beac5065fb19ffbdf864b5d8f4bda868
|
7
|
+
data.tar.gz: dae49b29ab27b64b990f8f71f7571afb00e01c18a7a3b94571af2a1b74bd578248db4b712241e571674683052b196a8b4164095db449058a95d9e8f2509d9119
|
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/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.
|
4
|
+
version: 1.2.0
|
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-19 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
|