keystone_ui-pages 0.4.1 → 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 +4 -4
- data/app/helpers/keystone_ui/pages/host_helper.rb +2 -2
- data/app/jobs/keystone_ui/pages/pdf_job.rb +2 -2
- data/lib/keystone_ui/pages/pdfs.rb +2 -2
- data/lib/keystone_ui/pages/version.rb +1 -1
- data/lib/keystone_ui/pages.rb +4 -4
- data/the_local/agents/keystone_ui-pages-develop.md +18 -10
- metadata +1 -1
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
|
|
@@ -6,8 +6,8 @@ module KeystoneUi
|
|
|
6
6
|
include KeystoneUiHelper
|
|
7
7
|
include DrawingHelper
|
|
8
8
|
|
|
9
|
-
def keystone_ui_page(page, values: {})
|
|
10
|
-
version = page.live_version
|
|
9
|
+
def keystone_ui_page(page, values: {}, version: nil)
|
|
10
|
+
version = version ? page.versions.find_by(number: version) : page.live_version
|
|
11
11
|
return if version.nil?
|
|
12
12
|
|
|
13
13
|
tag.div(drawn_version(version, values: values), class: "@container")
|
|
@@ -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
|
|
@@ -111,19 +111,26 @@ inherit from the base controller, so define it there.
|
|
|
111
111
|
|
|
112
112
|
### Drawing and printing
|
|
113
113
|
|
|
114
|
-
- `keystone_ui_page(page, values: {})` — a view helper, available
|
|
115
|
-
view, that draws the page's live version with the values given,
|
|
116
|
-
`<div class="@container">`. It returns nil when
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
- `keystone_ui_page(page, values: {}, version: nil)` — a view helper, available
|
|
115
|
+
in every host view, that draws the page's live version with the values given,
|
|
116
|
+
inside a `<div class="@container">`. It returns nil when no version is live.
|
|
117
|
+
`values:` takes value names to values, with string or symbol keys.
|
|
118
|
+
`version:` takes a published version's number and draws that version
|
|
119
|
+
instead, whether it is live or superseded and whether the page is
|
|
120
|
+
unpublished or archived. It returns nil when the page has no version with
|
|
121
|
+
that number. A record made from a page keeps the number it was made with
|
|
122
|
+
and passes it here, so it keeps drawing the same way after later publishes.
|
|
123
|
+
- `KeystoneUi::Pages.pdf(page, values: {}, version: nil)` — returns a
|
|
119
124
|
`KeystoneUi::Pages::Pdf` record for the page's live version drawn with the
|
|
120
125
|
values given. Its `file` is an Active Storage attachment, ready to download,
|
|
121
|
-
link or email. The same
|
|
126
|
+
link or email. The same version and values return the record already
|
|
122
127
|
kept, and a newly published version or different values print a new one.
|
|
123
|
-
When nothing is kept it prints in the current request.
|
|
124
|
-
|
|
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
|
|
125
132
|
`KeystoneUi::Pages::PdfJob`, which calls `KeystoneUi::Pages.pdf` with the same
|
|
126
|
-
page and
|
|
133
|
+
page, values and version, so the file is kept before anyone asks for it.
|
|
127
134
|
|
|
128
135
|
### The builder and the editor's screens
|
|
129
136
|
|
|
@@ -271,7 +278,8 @@ The catalog offers these Keystone UI components by default: `button`,
|
|
|
271
278
|
layout and print rules together.
|
|
272
279
|
- **Only the live version leaves the builder.** The draft is what editors
|
|
273
280
|
change. Visitors, `keystone_ui_page` and PDFs show the live version, so an
|
|
274
|
-
unpublished change shows nowhere else.
|
|
281
|
+
unpublished change shows nowhere else. `keystone_ui_page` and PDFs with
|
|
282
|
+
`version:` show an earlier published version, never the draft.
|
|
275
283
|
- **Value names are strings.** `Values.names`, the provider's hash and the
|
|
276
284
|
`values:` passed to the helper and to PDFs all use the same names. The gem
|
|
277
285
|
turns symbol keys into strings, so either works, but the names must match.
|