keystone_ui-pages 0.5.0 → 0.6.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77da11cab12ab896f890ea203bdf2f4b346603a1a0de8163359adf0fb1f8a608
|
|
4
|
+
data.tar.gz: abed3bcb29768934b84651c448105a9a75d6480c5000149b3473d3ce7250eb6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9bc3c8e60570178ccc5c4ef7029a6fe9cad8039187cb5649039cd85b3162d2a349814987825326834f0d4a8d1791dfbb0f5a2abab60b2e578e470d804f6003b0
|
|
7
|
+
data.tar.gz: 68dea7bf498637cf98b1233afb11f509ff45be2e030a6d3ab4ce150dd2f7b289cca9e80a3ef9b23900aa4d3f85e7f8a82b1cd1b1f7fb1d2658a3ecaf0fb6752f
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
module KeystoneUi
|
|
4
4
|
module Pages
|
|
5
5
|
class PdfJob < ActiveJob::Base
|
|
6
|
-
def perform(page, values)
|
|
7
|
-
KeystoneUi::Pages.pdf(page, values: values)
|
|
6
|
+
def perform(page, values, version = nil)
|
|
7
|
+
KeystoneUi::Pages.pdf(page, values: values, version: version)
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -9,8 +9,8 @@ module KeystoneUi
|
|
|
9
9
|
module Pdfs
|
|
10
10
|
module_function
|
|
11
11
|
|
|
12
|
-
def for(page, values: {})
|
|
13
|
-
version = page.versions.live.first
|
|
12
|
+
def for(page, values: {}, version: nil)
|
|
13
|
+
version = version ? page.versions.find_by(number: version) : page.versions.live.first
|
|
14
14
|
digest = Operations.digest(values.to_h.stringify_keys)
|
|
15
15
|
Pdf.find_by(version: version, values_digest: digest) || Pdf.create!(version: version, values_digest: digest,
|
|
16
16
|
file: { io: StringIO.new(Printer.pdf(PdfDocument.html(version, values: values))), filename: "#{page.slug}.pdf", content_type: "application/pdf" })
|
data/lib/keystone_ui/pages.rb
CHANGED
|
@@ -37,13 +37,13 @@ module KeystoneUi
|
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
def self.pdf(page, values: {})
|
|
40
|
+
def self.pdf(page, values: {}, version: nil)
|
|
41
41
|
require "keystone_ui/pages/pdfs"
|
|
42
|
-
Pdfs.for(page, values: values)
|
|
42
|
+
Pdfs.for(page, values: values, version: version)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
def self.prepare_pdf(page, values: {})
|
|
46
|
-
PdfJob.perform_later(page, values.to_h.stringify_keys)
|
|
45
|
+
def self.prepare_pdf(page, values: {}, version: nil)
|
|
46
|
+
PdfJob.perform_later(page, values.to_h.stringify_keys, version)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def self.catalog
|
|
@@ -120,15 +120,17 @@ inherit from the base controller, so define it there.
|
|
|
120
120
|
unpublished or archived. It returns nil when the page has no version with
|
|
121
121
|
that number. A record made from a page keeps the number it was made with
|
|
122
122
|
and passes it here, so it keeps drawing the same way after later publishes.
|
|
123
|
-
- `KeystoneUi::Pages.pdf(page, values: {})` — returns a
|
|
123
|
+
- `KeystoneUi::Pages.pdf(page, values: {}, version: nil)` — returns a
|
|
124
124
|
`KeystoneUi::Pages::Pdf` record for the page's live version drawn with the
|
|
125
125
|
values given. Its `file` is an Active Storage attachment, ready to download,
|
|
126
|
-
link or email. The same
|
|
126
|
+
link or email. The same version and values return the record already
|
|
127
127
|
kept, and a newly published version or different values print a new one.
|
|
128
|
-
When nothing is kept it prints in the current request.
|
|
129
|
-
|
|
128
|
+
When nothing is kept it prints in the current request. `version:` takes a
|
|
129
|
+
published version's number and prints that version instead, live or
|
|
130
|
+
superseded, the same way `keystone_ui_page` draws it.
|
|
131
|
+
- `KeystoneUi::Pages.prepare_pdf(page, values: {}, version: nil)` — queues
|
|
130
132
|
`KeystoneUi::Pages::PdfJob`, which calls `KeystoneUi::Pages.pdf` with the same
|
|
131
|
-
page and
|
|
133
|
+
page, values and version, so the file is kept before anyone asks for it.
|
|
132
134
|
|
|
133
135
|
### The builder and the editor's screens
|
|
134
136
|
|
|
@@ -276,8 +278,8 @@ The catalog offers these Keystone UI components by default: `button`,
|
|
|
276
278
|
layout and print rules together.
|
|
277
279
|
- **Only the live version leaves the builder.** The draft is what editors
|
|
278
280
|
change. Visitors, `keystone_ui_page` and PDFs show the live version, so an
|
|
279
|
-
unpublished change shows nowhere else. `keystone_ui_page` with
|
|
280
|
-
|
|
281
|
+
unpublished change shows nowhere else. `keystone_ui_page` and PDFs with
|
|
282
|
+
`version:` show an earlier published version, never the draft.
|
|
281
283
|
- **Value names are strings.** `Values.names`, the provider's hash and the
|
|
282
284
|
`values:` passed to the helper and to PDFs all use the same names. The gem
|
|
283
285
|
turns symbol keys into strings, so either works, but the names must match.
|