princely 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/README.md +3 -0
- data/lib/princely.rb +2 -1
- data/lib/princely/pdf_helper.rb +8 -3
- data/lib/princely/rails.rb +10 -4
- data/lib/princely/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 159b0a9d3b1ad9903919bfd4c898f0efa167c2f7
|
4
|
+
data.tar.gz: 470467e6249ef9e6ddb11919680dade99dc6b1df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7999bd7330708be669aff4f59dd34efab71f9c0c1789aca60041a905cce3e53f20730f33a530db224338803e4b5e9458bb017365632f87a84ad5a73b87ffc76c
|
7
|
+
data.tar.gz: d089a1b16276f65763a8d8a26d08d0aecf761a3b04b3969f58d04bf962355536630db91e376b4e347b99724e02de517affde3d2337638104e0a1207d20b45fce
|
data/README.md
CHANGED
@@ -20,6 +20,7 @@ class Provider::EstimatesController < Provider::BaseController
|
|
20
20
|
:formats => %w[pdf],
|
21
21
|
:stylesheets => %w[application prince],
|
22
22
|
:layout => 'pdf',
|
23
|
+
:locals => { :foo => 'bar' },
|
23
24
|
:disposition => 'inline', # PDF will be sent inline, means you can load it inside an iFrame or Embed
|
24
25
|
:relative_paths => true # Modify asset paths to make them relative. See [the AssetSupport module](/lib/princely/asset_support.rb)
|
25
26
|
end
|
@@ -40,6 +41,7 @@ The defaults for the render options are as follows:
|
|
40
41
|
|
41
42
|
layout: false
|
42
43
|
template: the template for the current controller/action
|
44
|
+
locals: none
|
43
45
|
stylesheets: none
|
44
46
|
disposition: attachment (created PDF file will be sent as download)
|
45
47
|
relative_paths: true
|
@@ -51,6 +53,7 @@ The defaults for the render options are as follows:
|
|
51
53
|
|
52
54
|
* Maintainer: Jared Fraser ([modsognir](https://github.com/modsognir))
|
53
55
|
* Gemification and more: Nic Williams
|
56
|
+
* Based on code by: Seth B ([subimage](https://github.com/subimage))
|
54
57
|
* [Other Contributors](https://github.com/mbleigh/princely/contributors)
|
55
58
|
|
56
59
|
## Resources
|
data/lib/princely.rb
CHANGED
data/lib/princely/pdf_helper.rb
CHANGED
@@ -3,9 +3,14 @@ require 'princely/asset_support'
|
|
3
3
|
|
4
4
|
module Princely
|
5
5
|
module PdfHelper
|
6
|
-
|
7
6
|
def self.included(base)
|
8
|
-
base.send :
|
7
|
+
base.send :alias_method, :render_without_princely, :render
|
8
|
+
base.send :alias_method, :render, :render_with_princely
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.prepended(base)
|
12
|
+
base.send :alias_method, :render_without_princely, :render
|
13
|
+
base.send :alias_method, :render, :render_with_princely
|
9
14
|
end
|
10
15
|
|
11
16
|
def render_with_princely(options = nil, *args, &block)
|
@@ -34,7 +39,7 @@ module Princely
|
|
34
39
|
# Sets style sheets on PDF renderer
|
35
40
|
prince.add_style_sheets(*options[:stylesheets].collect{|style| asset_file_path(style)})
|
36
41
|
|
37
|
-
html_string = render_to_string(options.slice(:template, :layout, :handlers, :formats))
|
42
|
+
html_string = render_to_string(options.slice(:template, :layout, :handlers, :formats, :locals))
|
38
43
|
|
39
44
|
html_string = localize_html_string(html_string, Rails.public_path) if options[:relative_paths]
|
40
45
|
|
data/lib/princely/rails.rb
CHANGED
@@ -4,7 +4,13 @@ if Mime::Type.lookup_by_extension(:pdf) != 'application/pdf'
|
|
4
4
|
Mime::Type.register 'application/pdf', :pdf
|
5
5
|
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
if defined?(Rails)
|
8
|
+
if Rails::VERSION::MAJOR >= 5
|
9
|
+
ActionController::Base.send(:prepend, Princely::PdfHelper)
|
10
|
+
else
|
11
|
+
ActionController::Base.send(:include, Princely::PdfHelper)
|
12
|
+
end
|
13
|
+
ActionController::Base.send(:include, Princely::AssetSupport) if
|
14
|
+
(Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR > 0) ||
|
15
|
+
(Rails::VERSION::MAJOR >= 4)
|
16
|
+
end
|
data/lib/princely/version.rb
CHANGED