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: 8a26feddb5cd80b4e5a676159463899d2aa3f8956e0a9e3a2a7cfdc2a9645a61
4
- data.tar.gz: 118357d59feb0e62eeb1aa9c04a327fc59ee13683e7878023990ec0388542939
3
+ metadata.gz: 77da11cab12ab896f890ea203bdf2f4b346603a1a0de8163359adf0fb1f8a608
4
+ data.tar.gz: abed3bcb29768934b84651c448105a9a75d6480c5000149b3473d3ce7250eb6e
5
5
  SHA512:
6
- metadata.gz: 9aee570200cb37d2bf6be9c90dec6202087b85c4cefe4a448607df0b26f274f162f5c73a85a456659404b4508541d6e6fe53da3c227877bcde74acaaa75baafe
7
- data.tar.gz: b1413f0fc7236cbfcc7769ba870726b4e79addd6d786705e1eaf5b10e6feb6f602d05a4ad5b68238b0bf67ac2a3aee9a83b24b260fa7a213d41569f3d767bc17
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" })
@@ -2,6 +2,6 @@
2
2
 
3
3
  module KeystoneUi
4
4
  module Pages
5
- VERSION = "0.5.0"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
@@ -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 live version and values return the record already
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
- - `KeystoneUi::Pages.prepare_pdf(page, values: {})` — queues
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 values, so the file is kept before anyone asks for it.
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 `version:`
280
- shows an earlier published version, never the draft.
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.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keystone_ui-pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Schneider