wicked_pdf 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/CHANGELOG.md +12 -1
- data/README.md +10 -1
- data/generators/wicked_pdf/templates/wicked_pdf.rb +6 -0
- data/lib/wicked_pdf.rb +15 -1
- data/lib/wicked_pdf/version.rb +1 -1
- data/lib/wicked_pdf/wicked_pdf_helper/assets.rb +10 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a1ed5bc6831790ca7a345a234788f25c80fa9cf9ce29cd6059c4f3e2b95899b
|
4
|
+
data.tar.gz: 8403943792fa00a8d6103227d9c64d1235d7bc15fd1c1dc0b1c5b781595d1129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91ff0d2567e0aff820cc482da2c76df3823fdb3be007229236907c0d4f8e2caf50a14e18f49a52f18d748f23f1c71f9010002417726c319a9064158cddd66ccd
|
7
|
+
data.tar.gz: 259d606917744373d121f6c4c1a84fa80411b326f92f45c049ad5cd4950adb4121befd0b7f765400594fed8b292670b0f32b8916632b1dc5727524877e046e0c
|
data/.rubocop.yml
CHANGED
@@ -10,6 +10,11 @@ Metrics/BlockLength:
|
|
10
10
|
Exclude:
|
11
11
|
- 'wicked_pdf.gemspec'
|
12
12
|
|
13
|
+
Metrics/ModuleLength:
|
14
|
+
Exclude:
|
15
|
+
# Excluding to keep the logic in one module for the time being.
|
16
|
+
- 'lib/wicked_pdf/wicked_pdf_helper/assets.rb'
|
17
|
+
|
13
18
|
# I'd like wicked_pdf to keep Ruby 1.8 compatibility for now
|
14
19
|
Style/HashSyntax:
|
15
20
|
EnforcedStyle: hash_rockets
|
data/CHANGELOG.md
CHANGED
@@ -10,6 +10,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
10
10
|
### Fixes
|
11
11
|
- None
|
12
12
|
|
13
|
+
## [2.1.0] - 2020-06-14
|
14
|
+
### Fixes
|
15
|
+
- [Document no_stop_slow_scripts in README](https://github.com/mileszs/wicked_pdf/pull/905)
|
16
|
+
- [Document how to use locals in README](https://github.com/mileszs/wicked_pdf/pull/915)
|
17
|
+
|
18
|
+
### New Features
|
19
|
+
- [Improved support for Webpacker assets with `wicked_pdf_asset_pack_path`](https://github.com/mileszs/wicked_pdf/pull/896)
|
20
|
+
- [Support enabling/disabling local file access compatible with wkhtmltopdf 0.12.6](https://github.com/mileszs/wicked_pdf/pull/920)
|
21
|
+
- [Add option `use_xvfb` to emulate an X server](https://github.com/mileszs/wicked_pdf/pull/909)
|
22
|
+
|
13
23
|
## [2.0.2] - 2020-03-17
|
14
24
|
### Fixes
|
15
25
|
- [Force UTF-8 encoding in assets helper](https://github.com/mileszs/wicked_pdf/pull/894)
|
@@ -149,7 +159,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
149
159
|
- Asset helpers no longer add a file extension if it already is specified with one
|
150
160
|
|
151
161
|
# Compare Releases
|
152
|
-
- [2.0
|
162
|
+
- [2.1.0...HEAD (unreleased changes)](https://github.com/mileszs/wicked_pdf/compare/2.1.0...HEAD)
|
163
|
+
- [2.0.2...2.1.0](https://github.com/mileszs/wicked_pdf/compare/2.0.2...2.1.0)
|
153
164
|
- [2.0.0...2.0.2](https://github.com/mileszs/wicked_pdf/compare/2.0.0...2.0.2)
|
154
165
|
- [1.4.0...2.0.0](https://github.com/mileszs/wicked_pdf/compare/1.4.0...2.0.0)
|
155
166
|
- [1.3.0...1.4.0](https://github.com/mileszs/wicked_pdf/compare/1.3.0...1.4.0)
|
data/README.md
CHANGED
@@ -109,11 +109,13 @@ Using wicked_pdf_helpers with asset pipeline raises `Asset names passed to helpe
|
|
109
109
|
|
110
110
|
#### Webpacker usage
|
111
111
|
|
112
|
-
wicked_pdf supports webpack
|
112
|
+
wicked_pdf supports webpack assets.
|
113
113
|
|
114
114
|
Use `wicked_pdf_stylesheet_pack_tag` for stylesheets
|
115
115
|
Use `wicked_pdf_javascript_pack_tag` for javascripts
|
116
116
|
|
117
|
+
Use `wicked_pdf_asset_pack_path` to access an asset directly, for example: `image_tag wicked_pdf_asset_pack_path("media/images/foobar.png")`
|
118
|
+
|
117
119
|
#### Asset pipeline usage
|
118
120
|
|
119
121
|
It is best to precompile assets used in PDF views. This will help avoid issues when it comes to deploying, as Rails serves asset files differently between development and production (`config.assets.compile = false`), which can make it look like your PDFs work in development, but fail to load assets in production.
|
@@ -144,6 +146,7 @@ class ThingsController < ApplicationController
|
|
144
146
|
render pdf: 'file_name',
|
145
147
|
disposition: 'attachment', # default 'inline'
|
146
148
|
template: 'things/show',
|
149
|
+
locals: {foo: @bar},
|
147
150
|
file: "#{Rails.root}/files/foo.erb",
|
148
151
|
inline: '<!doctype html><html><head></head><body>INLINE HTML</body></html>',
|
149
152
|
layout: 'pdf', # for a pdf.pdf.erb file
|
@@ -183,10 +186,16 @@ class ThingsController < ApplicationController
|
|
183
186
|
disable_internal_links: true,
|
184
187
|
disable_external_links: true,
|
185
188
|
print_media_type: true,
|
189
|
+
|
190
|
+
# define as true the key 'disable_local_file_access' or 'enable_local_file_access', not both
|
191
|
+
disable_local_file_access: true,
|
192
|
+
enable_local_file_access: false,
|
193
|
+
|
186
194
|
disable_smart_shrinking: true,
|
187
195
|
use_xserver: true,
|
188
196
|
background: false, # background needs to be true to enable background colors to render
|
189
197
|
no_background: true,
|
198
|
+
no_stop_slow_scripts: false,
|
190
199
|
viewport_size: 'TEXT', # available only with use_xserver or patched QT
|
191
200
|
extra: '', # directly inserted into the command to wkhtmltopdf
|
192
201
|
raise_on_all_errors: nil, # raise error for any stderr output. Such as missing media, image assets
|
@@ -18,4 +18,10 @@ WickedPdf.config = {
|
|
18
18
|
# Layout file to be used for all PDFs
|
19
19
|
# (but can be overridden in `render :pdf` calls)
|
20
20
|
# layout: 'pdf.html',
|
21
|
+
|
22
|
+
# Using wkhtmltopdf without an X server can be achieved by enabling the
|
23
|
+
# 'use_xvfb' flag. This will wrap all wkhtmltopdf commands around the
|
24
|
+
# 'xvfb-run' command, in order to simulate an X server.
|
25
|
+
#
|
26
|
+
# use_xvfb: true,
|
21
27
|
}
|
data/lib/wicked_pdf.rb
CHANGED
@@ -57,6 +57,7 @@ class WickedPdf
|
|
57
57
|
options.merge!(WickedPdf.config) { |_key, option, _config| option }
|
58
58
|
generated_pdf_file = WickedPdfTempfile.new('wicked_pdf_generated_file.pdf', options[:temp_path])
|
59
59
|
command = [@exe_path]
|
60
|
+
command.unshift(find_xvfb_run_binary_path) if options[:use_xvfb]
|
60
61
|
command += parse_options(options)
|
61
62
|
command << url
|
62
63
|
command << generated_pdf_file.path.to_s
|
@@ -316,6 +317,8 @@ class WickedPdf
|
|
316
317
|
:disable_internal_links,
|
317
318
|
:disable_external_links,
|
318
319
|
:print_media_type,
|
320
|
+
:disable_local_file_access,
|
321
|
+
:enable_local_file_access,
|
319
322
|
:disable_smart_shrinking,
|
320
323
|
:use_xserver,
|
321
324
|
:no_background,
|
@@ -326,9 +329,13 @@ class WickedPdf
|
|
326
329
|
r
|
327
330
|
end
|
328
331
|
|
329
|
-
def
|
332
|
+
def possible_binary_locations
|
330
333
|
possible_locations = (ENV['PATH'].split(':') + %w[/usr/bin /usr/local/bin]).uniq
|
331
334
|
possible_locations += %w[~/bin] if ENV.key?('HOME')
|
335
|
+
end
|
336
|
+
|
337
|
+
def find_wkhtmltopdf_binary_path
|
338
|
+
possible_locations = possible_binary_locations
|
332
339
|
exe_path ||= WickedPdf.config[:exe_path] unless WickedPdf.config.empty?
|
333
340
|
exe_path ||= begin
|
334
341
|
detected_path = (defined?(Bundler) ? Bundler.which('wkhtmltopdf') : `which wkhtmltopdf`).chomp
|
@@ -339,4 +346,11 @@ class WickedPdf
|
|
339
346
|
exe_path ||= possible_locations.map { |l| File.expand_path("#{l}/#{EXE_NAME}") }.find { |location| File.exist?(location) }
|
340
347
|
exe_path || ''
|
341
348
|
end
|
349
|
+
|
350
|
+
def find_xvfb_run_binary_path
|
351
|
+
possible_locations = possible_binary_locations
|
352
|
+
path = possible_locations.map { |l| File.expand_path("#{l}/xvfb-run") }.find { |location| File.exist?(location) }
|
353
|
+
raise StandardError.new('Could not find binary xvfb-run on the system.') unless path
|
354
|
+
path
|
355
|
+
end
|
342
356
|
end
|
data/lib/wicked_pdf/version.rb
CHANGED
@@ -79,6 +79,16 @@ class WickedPdf
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
+
def wicked_pdf_asset_pack_path(asset)
|
83
|
+
return unless defined?(Webpacker)
|
84
|
+
|
85
|
+
if running_in_development?
|
86
|
+
asset_pack_path(asset)
|
87
|
+
else
|
88
|
+
wicked_pdf_asset_path webpacker_source_url(asset)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
82
92
|
private
|
83
93
|
|
84
94
|
# borrowed from actionpack/lib/action_view/helpers/asset_url_helper.rb
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wicked_pdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miles Z. Sterrett
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
version: '0'
|
199
199
|
requirements:
|
200
200
|
- wkhtmltopdf
|
201
|
-
rubygems_version: 3.0.
|
201
|
+
rubygems_version: 3.0.3
|
202
202
|
signing_key:
|
203
203
|
specification_version: 4
|
204
204
|
summary: PDF generator (from HTML) gem for Ruby on Rails
|