glib-web 8.1.0 → 8.2.1
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/controllers/concerns/glib/json/libs.rb +16 -0
- data/app/controllers/glib/glib_direct_uploads_controller.rb +2 -1
- data/app/helpers/glib/app_feature_support_helper.rb +33 -8
- data/app/helpers/glib/json_ui/view_builder/fields.rb +110 -9
- data/app/helpers/glib/json_ui/view_builder.rb +29 -0
- data/app/jobs/glib/scheduled_job.rb +581 -0
- data/app/jobs/glib/scheduled_job_tick.rb +21 -0
- data/app/models/glib/scheduled_job_run.rb +16 -0
- data/app/views/json_ui/garage/actions/sheet_content.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/_action_text_conversion.json.jbuilder +12 -0
- data/app/views/json_ui/garage/forms/action_text.json.jbuilder +57 -0
- data/app/views/json_ui/garage/forms/action_text_attachment.json.jbuilder +7 -0
- data/app/views/json_ui/garage/forms/action_text_conversion.json.jbuilder +5 -0
- data/app/views/json_ui/garage/forms/action_text_library.json.jbuilder +26 -0
- data/app/views/json_ui/garage/forms/action_text_mentions.json.jbuilder +4 -0
- data/app/views/json_ui/garage/forms/action_text_preview.json.jbuilder +9 -0
- data/app/views/json_ui/garage/forms/dialogs_form.json.jbuilder +10 -10
- data/app/views/json_ui/garage/forms/dirty_prompt.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/dynamic_group.json.jbuilder +1 -1
- data/app/views/json_ui/garage/forms/index.json.jbuilder +6 -0
- data/app/views/json_ui/garage/forms/pickers.json.jbuilder +7 -0
- data/app/views/json_ui/garage/forms/show_hide.json.jbuilder +1 -1
- data/app/views/json_ui/garage/test_page/_header.json.jbuilder +6 -0
- data/app/views/json_ui/garage/test_page/charts.json.jbuilder +4 -2
- data/app/views/json_ui/garage/test_page/fields_actionText.json.jbuilder +189 -0
- data/app/views/json_ui/garage/test_page/fields_richText.json.jbuilder +45 -1
- data/app/views/json_ui/garage/test_page/fields_sign.json.jbuilder +34 -3
- data/app/views/json_ui/garage/test_page/form_dirty_fields.json.jbuilder +1 -1
- data/app/views/json_ui/garage/test_page/form_dirty_hooks.json.jbuilder +22 -0
- data/app/views/json_ui/garage/test_page/form_hidden_panels.json.jbuilder +105 -0
- data/app/views/json_ui/garage/views/charts.json.jbuilder +4 -2
- data/app/views/layouts/json_ui/renderer.html.erb +11 -1
- data/engines/blog/README.md +172 -0
- data/engines/blog/app/assets/stylesheets/glib/blog/admin.css +855 -0
- data/engines/blog/app/assets/stylesheets/glib/blog/themes/clean.css +816 -0
- data/engines/blog/app/assets/stylesheets/glib/blog/themes/editorial.css +631 -0
- data/engines/blog/app/controllers/concerns/glib/blog/admin/media_listing.rb +27 -0
- data/engines/blog/app/controllers/concerns/glib/blog/pagination.rb +14 -0
- data/engines/blog/app/controllers/glib/blog/admin/application_controller.rb +28 -0
- data/engines/blog/app/controllers/glib/blog/admin/authors_controller.rb +55 -0
- data/engines/blog/app/controllers/glib/blog/admin/categories_controller.rb +53 -0
- data/engines/blog/app/controllers/glib/blog/admin/comment_replies_controller.rb +34 -0
- data/engines/blog/app/controllers/glib/blog/admin/comments_controller.rb +50 -0
- data/engines/blog/app/controllers/glib/blog/admin/dashboards_controller.rb +34 -0
- data/engines/blog/app/controllers/glib/blog/admin/direct_uploads_controller.rb +30 -0
- data/engines/blog/app/controllers/glib/blog/admin/editor_attachments_controller.rb +16 -0
- data/engines/blog/app/controllers/glib/blog/admin/media_item_trashes_controller.rb +43 -0
- data/engines/blog/app/controllers/glib/blog/admin/media_items_controller.rb +61 -0
- data/engines/blog/app/controllers/glib/blog/admin/media_picks_controller.rb +19 -0
- data/engines/blog/app/controllers/glib/blog/admin/post_bulk_actions_controller.rb +33 -0
- data/engines/blog/app/controllers/glib/blog/admin/posts_controller.rb +79 -0
- data/engines/blog/app/controllers/glib/blog/admin/settings_controller.rb +27 -0
- data/engines/blog/app/controllers/glib/blog/admin/tags_controller.rb +46 -0
- data/engines/blog/app/controllers/glib/blog/application_controller.rb +90 -0
- data/engines/blog/app/controllers/glib/blog/authors_controller.rb +15 -0
- data/engines/blog/app/controllers/glib/blog/categories_controller.rb +15 -0
- data/engines/blog/app/controllers/glib/blog/comments_controller.rb +41 -0
- data/engines/blog/app/controllers/glib/blog/posts_controller.rb +47 -0
- data/engines/blog/app/controllers/glib/blog/tags_controller.rb +15 -0
- data/engines/blog/app/helpers/glib/blog/admin_helper.rb +57 -0
- data/engines/blog/app/helpers/glib/blog/comments_helper.rb +16 -0
- data/engines/blog/app/helpers/glib/blog/post_list_helper.rb +26 -0
- data/engines/blog/app/helpers/glib/blog/theme_helper.rb +85 -0
- data/engines/blog/app/jobs/glib/blog/purge_trash_job.rb +13 -0
- data/engines/blog/app/models/concerns/glib/blog/sluggable.rb +72 -0
- data/engines/blog/app/models/concerns/glib/blog/uses_media.rb +35 -0
- data/engines/blog/app/models/glib/blog/application_record.rb +7 -0
- data/engines/blog/app/models/glib/blog/author.rb +47 -0
- data/engines/blog/app/models/glib/blog/category.rb +53 -0
- data/engines/blog/app/models/glib/blog/comment.rb +66 -0
- data/engines/blog/app/models/glib/blog/comment_token.rb +30 -0
- data/engines/blog/app/models/glib/blog/media_item.rb +121 -0
- data/engines/blog/app/models/glib/blog/media_upload.rb +97 -0
- data/engines/blog/app/models/glib/blog/media_usage.rb +10 -0
- data/engines/blog/app/models/glib/blog/post.rb +110 -0
- data/engines/blog/app/models/glib/blog/post_view.rb +24 -0
- data/engines/blog/app/models/glib/blog/setting.rb +55 -0
- data/engines/blog/app/models/glib/blog/slug_redirect.rb +7 -0
- data/engines/blog/app/models/glib/blog/tag.rb +15 -0
- data/engines/blog/app/models/glib/blog/tagging.rb +10 -0
- data/engines/blog/app/policies/glib/blog/admin/author_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/category_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/comment_policy.rb +16 -0
- data/engines/blog/app/policies/glib/blog/admin/comment_reply_policy.rb +12 -0
- data/engines/blog/app/policies/glib/blog/admin/dashboard_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/direct_upload_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/editor_attachment_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/media_item_policy.rb +20 -0
- data/engines/blog/app/policies/glib/blog/admin/media_item_trash_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/media_pick_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/post_bulk_action_policy.rb +12 -0
- data/engines/blog/app/policies/glib/blog/admin/post_policy.rb +16 -0
- data/engines/blog/app/policies/glib/blog/admin/setting_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/admin/tag_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/application_policy.rb +16 -0
- data/engines/blog/app/policies/glib/blog/author_policy.rb +9 -0
- data/engines/blog/app/policies/glib/blog/category_policy.rb +9 -0
- data/engines/blog/app/policies/glib/blog/comment_policy.rb +11 -0
- data/engines/blog/app/policies/glib/blog/post_policy.rb +9 -0
- data/engines/blog/app/policies/glib/blog/tag_policy.rb +9 -0
- data/engines/blog/app/views/glib/blog/admin/_delete_button.json.jbuilder +24 -0
- data/engines/blog/app/views/glib/blog/admin/_nav.json.jbuilder +45 -0
- data/engines/blog/app/views/glib/blog/admin/_status_chip.json.jbuilder +2 -0
- data/engines/blog/app/views/glib/blog/admin/authors/_form.json.jbuilder +17 -0
- data/engines/blog/app/views/glib/blog/admin/authors/edit.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/admin/authors/index.json.jbuilder +50 -0
- data/engines/blog/app/views/glib/blog/admin/authors/new.json.jbuilder +11 -0
- data/engines/blog/app/views/glib/blog/admin/categories/_form.json.jbuilder +13 -0
- data/engines/blog/app/views/glib/blog/admin/categories/edit.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/admin/categories/index.json.jbuilder +68 -0
- data/engines/blog/app/views/glib/blog/admin/categories/new.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/admin/comments/_moderation_buttons.json.jbuilder +35 -0
- data/engines/blog/app/views/glib/blog/admin/comments/index.json.jbuilder +59 -0
- data/engines/blog/app/views/glib/blog/admin/dashboards/show.json.jbuilder +109 -0
- data/engines/blog/app/views/glib/blog/admin/media_item_trashes/index.json.jbuilder +32 -0
- data/engines/blog/app/views/glib/blog/admin/media_items/_rows.json.jbuilder +32 -0
- data/engines/blog/app/views/glib/blog/admin/media_items/edit.json.jbuilder +68 -0
- data/engines/blog/app/views/glib/blog/admin/media_items/index.json.jbuilder +68 -0
- data/engines/blog/app/views/glib/blog/admin/media_items/new.json.jbuilder +18 -0
- data/engines/blog/app/views/glib/blog/admin/media_picks/index.json.jbuilder +29 -0
- data/engines/blog/app/views/glib/blog/admin/posts/_form.json.jbuilder +104 -0
- data/engines/blog/app/views/glib/blog/admin/posts/edit.json.jbuilder +1 -0
- data/engines/blog/app/views/glib/blog/admin/posts/index.json.jbuilder +109 -0
- data/engines/blog/app/views/glib/blog/admin/posts/new.json.jbuilder +1 -0
- data/engines/blog/app/views/glib/blog/admin/settings/edit.json.jbuilder +55 -0
- data/engines/blog/app/views/glib/blog/admin/tags/_form.json.jbuilder +6 -0
- data/engines/blog/app/views/glib/blog/admin/tags/edit.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/admin/tags/index.json.jbuilder +30 -0
- data/engines/blog/app/views/glib/blog/admin/tags/new.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/authors/show.json.jbuilder +4 -0
- data/engines/blog/app/views/glib/blog/categories/show.json.jbuilder +4 -0
- data/engines/blog/app/views/glib/blog/comments/pending.json.jbuilder +7 -0
- data/engines/blog/app/views/glib/blog/media_items/_media_item.html.erb +14 -0
- data/engines/blog/app/views/glib/blog/posts/_comment.json.jbuilder +23 -0
- data/engines/blog/app/views/glib/blog/posts/_comment_form.json.jbuilder +14 -0
- data/engines/blog/app/views/glib/blog/posts/_comments.json.jbuilder +21 -0
- data/engines/blog/app/views/glib/blog/posts/index.json.jbuilder +4 -0
- data/engines/blog/app/views/glib/blog/posts/show.json.jbuilder +5 -0
- data/engines/blog/app/views/glib/blog/shared/errors.json.jbuilder +5 -0
- data/engines/blog/app/views/glib/blog/tags/show.json.jbuilder +3 -0
- data/engines/blog/app/views/glib/blog/themes/_nav_links.json.jbuilder +12 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_brand.json.jbuilder +11 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_card.json.jbuilder +15 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_featured.json.jbuilder +23 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_footer.json.jbuilder +15 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_header.json.jbuilder +9 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_post.json.jbuilder +98 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_post_list.json.jbuilder +40 -0
- data/engines/blog/app/views/glib/blog/themes/clean/_post_rows.json.jbuilder +10 -0
- data/engines/blog/app/views/glib/blog/themes/editorial/_footer.json.jbuilder +15 -0
- data/engines/blog/app/views/glib/blog/themes/editorial/_header.json.jbuilder +11 -0
- data/engines/blog/app/views/glib/blog/themes/editorial/_post.json.jbuilder +62 -0
- data/engines/blog/app/views/glib/blog/themes/editorial/_post_list.json.jbuilder +25 -0
- data/engines/blog/app/views/glib/blog/themes/editorial/_post_rows.json.jbuilder +18 -0
- data/engines/blog/config/locales/en.yml +500 -0
- data/engines/blog/config/routes.rb +33 -0
- data/engines/blog/db/migrate/20261103090000_create_glib_blog_tables.rb +70 -0
- data/engines/blog/db/migrate/20261104090000_create_glib_blog_media_tables.rb +44 -0
- data/engines/blog/db/migrate/20261104120000_create_glib_blog_comments.rb +23 -0
- data/engines/blog/db/migrate/20261105090000_add_glib_blog_comment_moderation.rb +16 -0
- data/engines/blog/db/migrate/20261105100000_add_deleted_at_to_glib_blog_posts.rb +6 -0
- data/engines/blog/db/migrate/20261105110000_add_parent_and_default_to_glib_blog_categories.rb +10 -0
- data/engines/blog/db/migrate/20261105120000_create_glib_blog_post_views.rb +13 -0
- data/engines/blog/db/migrate/20261105130000_create_glib_blog_settings.rb +26 -0
- data/engines/blog/db/migrate/20261106090000_add_theme_to_glib_blog_settings.rb +7 -0
- data/engines/blog/lib/tasks/glib_blog_tasks.rake +32 -0
- data/lib/generators/glib/blog/install_generator.rb +44 -0
- data/lib/generators/glib/blog/templates/initializer.rb +22 -0
- data/lib/generators/glib/scheduled_jobs_generator.rb +30 -0
- data/lib/generators/templates/scheduled_jobs/create_glib_scheduled_job_runs.rb +22 -0
- data/lib/glib/blog/engine.rb +20 -0
- data/lib/glib/blog/theme.rb +35 -0
- data/lib/glib/blog.rb +50 -0
- data/lib/glib/engine.rb +17 -0
- data/lib/glib/scheduled_jobs/config.rb +36 -0
- data/lib/glib/scheduled_jobs/loader.rb +98 -0
- data/lib/glib-web.rb +2 -0
- metadata +177 -3
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
json.title 'Test Page (Form Hidden Panels)'
|
|
2
|
+
|
|
3
|
+
page = json_ui_page json
|
|
4
|
+
|
|
5
|
+
render 'json_ui/garage/test_page/header', json: json, page: page
|
|
6
|
+
|
|
7
|
+
# Probes panels that are hidden and shown with ONE `logics_set` per panel
|
|
8
|
+
# while their fields keep what the user typed or attached. Every panel and
|
|
9
|
+
# field here is declared `submitWhenNotDisplayed: true`, so hiding keeps it
|
|
10
|
+
# mounted (display: none) and its value still submits. Siblings:
|
|
11
|
+
# form_removed_field (fields WITHOUT the flag unmount when hidden).
|
|
12
|
+
panel_ids = %w[hidden_panel_a hidden_panel_b hidden_panel_c]
|
|
13
|
+
|
|
14
|
+
show_panel = ->(action, shown_id) do
|
|
15
|
+
action.runMultiple childActions: ->(multiple) do
|
|
16
|
+
panel_ids.each do |panel_id|
|
|
17
|
+
multiple.logics_set targetId: panel_id, data: { displayed: panel_id == shown_id, submitWhenNotDisplayed: true }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
page.body childViews: ->(body) do
|
|
23
|
+
body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
|
|
24
|
+
res.h2 text: 'Hidden panels keep their fields'
|
|
25
|
+
res.spacer height: 8
|
|
26
|
+
# Dirty state, observable: `onDirty`/`onPristine` fire on transitions, and
|
|
27
|
+
# `hidden_ever_dirty` never resets, so a transient dirty blip shows too.
|
|
28
|
+
res.label id: 'hidden_dirty_state', text: 'Form: pristine'
|
|
29
|
+
res.label id: 'hidden_ever_dirty', text: 'Ever dirty: no'
|
|
30
|
+
res.spacer height: 8
|
|
31
|
+
res.panels_form \
|
|
32
|
+
url: json_ui_garage_url(path: 'forms/generic_post'),
|
|
33
|
+
method: 'post',
|
|
34
|
+
onDirty: ->(action) do
|
|
35
|
+
action.runMultiple childActions: ->(multiple) do
|
|
36
|
+
multiple.logics_set targetId: 'hidden_dirty_state', data: { text: 'Form: dirty' }
|
|
37
|
+
multiple.logics_set targetId: 'hidden_ever_dirty', data: { text: 'Ever dirty: yes' }
|
|
38
|
+
end
|
|
39
|
+
end,
|
|
40
|
+
onPristine: ->(action) do
|
|
41
|
+
action.logics_set targetId: 'hidden_dirty_state', data: { text: 'Form: pristine' }
|
|
42
|
+
end,
|
|
43
|
+
childViews: ->(form) do
|
|
44
|
+
form.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', childViews: ->(flow) do
|
|
45
|
+
flow.button text: 'Show A', onClick: ->(action) { show_panel.call(action, 'hidden_panel_a') }
|
|
46
|
+
flow.spacer width: 8
|
|
47
|
+
flow.button text: 'Show B', onClick: ->(action) { show_panel.call(action, 'hidden_panel_b') }
|
|
48
|
+
flow.spacer width: 8
|
|
49
|
+
flow.button text: 'Show C', onClick: ->(action) { show_panel.call(action, 'hidden_panel_c') }
|
|
50
|
+
end
|
|
51
|
+
form.spacer height: 8
|
|
52
|
+
|
|
53
|
+
form.panels_vertical width: 'matchParent', id: 'hidden_panel_a', submitWhenNotDisplayed: true, childViews: ->(panel) do
|
|
54
|
+
panel.label text: 'Panel A'
|
|
55
|
+
panel.fields_actionText id: 'hidden_text_a', width: 'matchParent', name: 'user[text_a]', value: '<div>Alpha start</div>', submitWhenNotDisplayed: true
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
form.panels_vertical width: 'matchParent', id: 'hidden_panel_b', displayed: false, submitWhenNotDisplayed: true, childViews: ->(panel) do
|
|
59
|
+
panel.label text: 'Panel B'
|
|
60
|
+
panel.fields_actionText id: 'hidden_text_b', width: 'matchParent', name: 'user[text_b]', value: '<div>Bravo start</div>', submitWhenNotDisplayed: true
|
|
61
|
+
panel.fields_upload \
|
|
62
|
+
id: 'hidden_upload_b',
|
|
63
|
+
name: 'user[file_b]',
|
|
64
|
+
label: 'Attach a file',
|
|
65
|
+
width: 320,
|
|
66
|
+
directUploadUrl: glib_direct_uploads_url,
|
|
67
|
+
accepts: { fileType: 'image' },
|
|
68
|
+
inputView: {},
|
|
69
|
+
submitWhenNotDisplayed: true
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
form.panels_vertical width: 'matchParent', id: 'hidden_panel_c', displayed: false, submitWhenNotDisplayed: true, childViews: ->(panel) do
|
|
73
|
+
panel.label text: 'Panel C'
|
|
74
|
+
panel.fields_actionText id: 'hidden_text_c', width: 'matchParent', name: 'user[text_c]', value: '<div>Charlie start</div>', submitWhenNotDisplayed: true
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
form.spacer height: 12
|
|
78
|
+
form.hr width: 'matchParent'
|
|
79
|
+
form.spacer height: 12
|
|
80
|
+
|
|
81
|
+
# A `logics_set` aimed straight at the upload (not its panel).
|
|
82
|
+
form.panels_flow innerPadding: { bottom: 0 }, width: 'matchParent', childViews: ->(flow) do
|
|
83
|
+
flow.button text: 'Hide upload', onClick: ->(action) do
|
|
84
|
+
action.logics_set targetId: 'hidden_upload_b', data: { displayed: false }
|
|
85
|
+
end
|
|
86
|
+
flow.spacer width: 8
|
|
87
|
+
flow.button text: 'Show upload', onClick: ->(action) do
|
|
88
|
+
action.logics_set targetId: 'hidden_upload_b', data: { displayed: true }
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
form.spacer height: 12
|
|
92
|
+
|
|
93
|
+
# A field declared with the flag, hidden by a `logics_set` that does
|
|
94
|
+
# not mention the flag: it must keep it, so it stays submitted.
|
|
95
|
+
form.fields_text id: 'hidden_lone_text', width: 'matchParent', name: 'user[lone]', label: 'Lone', value: 'Lone value', submitWhenNotDisplayed: true
|
|
96
|
+
form.button text: 'Hide lone', onClick: ->(action) do
|
|
97
|
+
action.logics_set targetId: 'hidden_lone_text', data: { displayed: false }
|
|
98
|
+
end
|
|
99
|
+
form.spacer height: 12
|
|
100
|
+
|
|
101
|
+
form.spacer height: 20
|
|
102
|
+
form.fields_submit text: 'Submit'
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
default_plugins = {
|
|
2
2
|
datalabels: {
|
|
3
|
-
backgroundColor: 'skyblue',
|
|
4
3
|
borderRadius: 4,
|
|
5
4
|
color: 'white',
|
|
6
5
|
font: {
|
|
@@ -10,6 +9,9 @@ default_plugins = {
|
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
|
|
12
|
+
custom_plugins = default_plugins.deep_dup
|
|
13
|
+
custom_plugins[:datalabels][:backgroundColor] = ['#1E5006', '#E36414']
|
|
14
|
+
|
|
13
15
|
if params[:data_only].present?
|
|
14
16
|
json_ui_page json do |page|
|
|
15
17
|
page.data content: ->(data) do
|
|
@@ -54,7 +56,7 @@ else
|
|
|
54
56
|
json.points points.map { |k, v| { x: k, y: v, label: v > 5 ? 'Greater than five' : v } }
|
|
55
57
|
end
|
|
56
58
|
],
|
|
57
|
-
plugins:
|
|
59
|
+
plugins: custom_plugins,
|
|
58
60
|
colors: ['#79AC78', '#3085C3'], legend: { display: false }, formatYAxis: true
|
|
59
61
|
|
|
60
62
|
# scroll.spacer height: 20
|
|
@@ -16,7 +16,17 @@
|
|
|
16
16
|
`crossorigin` is required on the font origin because fonts are fetched
|
|
17
17
|
CORS-anonymously, and without it the preconnected socket is discarded.
|
|
18
18
|
Note the icons themselves are held blank until this font resolves -- see
|
|
19
|
-
Dom.hideIconsUntilFontReady in the npm package.
|
|
19
|
+
Dom.hideIconsUntilFontReady in the npm package.
|
|
20
|
+
|
|
21
|
+
The stylesheet URL deliberately has no `&display=swap`. Icons here are
|
|
22
|
+
LIGATURE TEXT, so `swap` paints the icon's NAME ("menu", "close") as
|
|
23
|
+
fallback immediately, while the default `auto`/`block` does the same
|
|
24
|
+
once its ~3s block period lapses -- neither keeps the icons correct
|
|
25
|
+
while the font is in flight. Instead we preconnect (above) to shorten
|
|
26
|
+
the handshake and let Dom.hideIconsUntilFontReady keep the icons BLANK
|
|
27
|
+
until the face actually resolves. Preconnect and font-display are
|
|
28
|
+
orthogonal: preconnect is connection setup, font-display is the
|
|
29
|
+
render-fallback policy. %>
|
|
20
30
|
<link href="//fonts.googleapis.com" rel="preconnect">
|
|
21
31
|
<link href="//fonts.gstatic.com" rel="preconnect" crossorigin>
|
|
22
32
|
<link href="//fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet">
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# Glib::Blog
|
|
2
|
+
|
|
3
|
+
An opt-in blog engine for glib apps. It provides posts, categories, tags, authors with roles, scheduling, SEO
|
|
4
|
+
fields and slugs that keep redirecting after they change. Every page, public and admin, is glib JSON UI. Post
|
|
5
|
+
bodies use Action Text, edited with `fields_actionText` and shown with the `actionText` view.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
1. Load the engine after `Bundler.require` in `config/application.rb`, along with Action Text:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
require 'glib/blog'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
2. Run the generator. It writes `config/initializers/glib_blog.rb`, mounts the engine at `/blog`, and copies the
|
|
16
|
+
migrations (Action Text's too, when the app doesn't have them yet):
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
bin/rails g glib:blog:install
|
|
20
|
+
bin/rails db:migrate
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
3. Give an existing user access as the first admin:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
bin/rails glib_blog:author EMAIL=ada@example.com
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
`USER_ID=` finds the user by ID instead, `ROLE=` gives `author` or `editor` instead of `admin`, and `BYLINE=`
|
|
30
|
+
sets the name shown on their posts (by default the user's `full_name` or `name`). The engine never creates
|
|
31
|
+
users: people sign up through the app, and an admin then adds them as authors from `/blog/admin/authors`.
|
|
32
|
+
|
|
33
|
+
## What the host app provides
|
|
34
|
+
|
|
35
|
+
- `current_user`, on the controller set as `Glib::Blog.parent_controller` (default `::ApplicationController`).
|
|
36
|
+
Engine controllers inherit from it.
|
|
37
|
+
- A user model, `Glib::Blog.user_class` (default `'User'`).
|
|
38
|
+
- `Glib::Blog.sign_in_url`, where guests are sent from admin pages.
|
|
39
|
+
- `gem 'image_processing'` and libvips, for the media library.
|
|
40
|
+
- A daily run of `Glib::Blog::PurgeTrashJob`, which empties the 30-day post and media trash (Solid Queue
|
|
41
|
+
recurring task, cron with `bin/rails glib_blog:purge_trash`, ...).
|
|
42
|
+
- `Glib::Blog.media_url`, when the app turns off Active Storage's routes. The default builds Rails proxy URLs,
|
|
43
|
+
which a CDN can cache.
|
|
44
|
+
|
|
45
|
+
## Admin look
|
|
46
|
+
|
|
47
|
+
The admin has its own look (a dark sidebar and IBM Plex type), scoped to its pages, so it ignores the host's
|
|
48
|
+
theme and leaves the host's pages alone. The styles are in `app/assets/stylesheets/glib/blog/admin.css`
|
|
49
|
+
and are sent with each admin page. The fonts load from Google Fonts, so a strict Content Security Policy
|
|
50
|
+
needs to allow `fonts.googleapis.com` and `fonts.gstatic.com`. The sidebar shows the blog's title and logo
|
|
51
|
+
from its settings.
|
|
52
|
+
|
|
53
|
+
## Themes
|
|
54
|
+
|
|
55
|
+
The public blog has two looks, and an admin switches between them in the settings (Appearance):
|
|
56
|
+
|
|
57
|
+
- Clean (the default): white pages, IBM Plex type and blue accents. The home page leads with the featured post
|
|
58
|
+
above a grid of cards filtered by top-level category; articles list their sections beside the text and end with
|
|
59
|
+
an author box and more posts from the same category.
|
|
60
|
+
- Editorial: warm paper tones and Cormorant Garamond headings. The home page opens on a large title over the
|
|
61
|
+
tagline, then a single column of entries dated in the margin; articles end with a link to the previous post.
|
|
62
|
+
|
|
63
|
+
Both show the newest post marked "Featured" first, and both carry the comments, tags and infinite scrolling.
|
|
64
|
+
|
|
65
|
+
A theme is a stylesheet plus a folder of partials, `app/views/glib/blog/themes/<name>`. The page carries the class
|
|
66
|
+
`blog-theme-<name>`, which scopes the stylesheet, and the stylesheet is sent with each page like the admin's. The
|
|
67
|
+
built-in themes load their fonts from Google Fonts, so a strict Content Security Policy needs to allow them.
|
|
68
|
+
|
|
69
|
+
### Adding, changing or removing themes
|
|
70
|
+
|
|
71
|
+
Themes are registered in `Glib::Blog.themes`; an app changes them in `config/initializers/glib_blog.rb`:
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
# Add a theme. With `based_on`, every partial it lacks comes from that theme, and that theme's
|
|
75
|
+
# stylesheet loads before its own, so a theme can be nothing but a stylesheet.
|
|
76
|
+
Glib::Blog.register_theme :dark, based_on: :clean, stylesheet: Rails.root.join('app/assets/stylesheets/blog/dark.css')
|
|
77
|
+
|
|
78
|
+
# Replace a theme's stylesheet: registering a name again replaces it.
|
|
79
|
+
Glib::Blog.register_theme :clean, stylesheet: Rails.root.join('app/assets/stylesheets/blog/clean.css')
|
|
80
|
+
|
|
81
|
+
# Remove a theme.
|
|
82
|
+
Glib::Blog.themes.delete(:editorial)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- **Stylesheets** scope their rules to `.blog-theme-<name>`. A page carries the class of its theme and of every theme
|
|
86
|
+
it is based on, so `dark.css` can override `.blog-theme-clean` rules with `.blog-theme-dark` ones. Edits show
|
|
87
|
+
without a restart where the app reloads code.
|
|
88
|
+
- **Partials**: an app's own `app/views/glib/blog/themes/<name>/_footer.json.jbuilder` wins over the engine's file at
|
|
89
|
+
that path, for a built-in theme too. The partials a theme may provide are `header`, `footer`, `post_list` (a list
|
|
90
|
+
page), `post_rows` (a page of list rows) and `post` (an article), plus any its own partials render through
|
|
91
|
+
`glib_blog_theme_partial`.
|
|
92
|
+
- **Text**: the settings show `glib.blog.themes.<name>.name` and `.description` from the app's locale (the name
|
|
93
|
+
defaults to the humanized key). Strings a theme shares, such as `home`, fall back to the theme it is based on.
|
|
94
|
+
- The first registered theme is used until an admin chooses one, and whenever the chosen theme is no longer
|
|
95
|
+
registered.
|
|
96
|
+
|
|
97
|
+
## Settings
|
|
98
|
+
|
|
99
|
+
Admins change the blog's settings in `/blog/admin/settings/edit`:
|
|
100
|
+
|
|
101
|
+
- General: the blog's title (shown on the blog and in the admin; "Blog" until set), tagline and logo, a library image.
|
|
102
|
+
- Appearance: the public blog's theme.
|
|
103
|
+
- Reading: how many posts each list shows before loading more as the reader scrolls, and hiding the whole blog from
|
|
104
|
+
search engines.
|
|
105
|
+
- Comments: whether new posts allow comments, whether readers' comments wait for approval, and after how many days
|
|
106
|
+
comments close.
|
|
107
|
+
|
|
108
|
+
The two comment rules start from the app's configuration (`Glib::Blog.comments_require_approval` and
|
|
109
|
+
`Glib::Blog.comments_close_after`); once an admin saves them, the saved values win.
|
|
110
|
+
|
|
111
|
+
## Views
|
|
112
|
+
|
|
113
|
+
Each time a reader opens a live post, the post's count for that day goes up by one. Signed-in authors and obvious
|
|
114
|
+
crawlers are not counted, and nothing about the reader is stored. The dashboard shows the views of the last 30 days
|
|
115
|
+
against the 30 before, and the views of each recent post.
|
|
116
|
+
|
|
117
|
+
## Posts
|
|
118
|
+
|
|
119
|
+
Posts are drafts, published (scheduled while their publish date is still ahead) or archived. Deleting a post moves
|
|
120
|
+
it to the trash, where it drops off the blog and can be restored for 30 days; `PurgeTrashJob` deletes it after
|
|
121
|
+
that, and an editor can delete it permanently from the trash at any time. The post list publishes, unpublishes,
|
|
122
|
+
trashes or restores several posts at once.
|
|
123
|
+
|
|
124
|
+
## Media library
|
|
125
|
+
|
|
126
|
+
Every file lives once in `/blog/admin/media_items` and posts point at it, so the library knows where each file is
|
|
127
|
+
used.
|
|
128
|
+
|
|
129
|
+
- Uploads are checked by content, not by the browser's declared type: JPG, PNG, WebP, GIF, HEIC and PDF up to
|
|
130
|
+
10 MB, plus SVG for admins.
|
|
131
|
+
- Photos are rotated upright, scaled to 2560 px, converted from HEIC to JPEG and stripped of EXIF and GPS data
|
|
132
|
+
before they are stored; the original is not kept. Thumb, medium and large WebP sizes are generated in the
|
|
133
|
+
background.
|
|
134
|
+
- Uploading a file that is already in the library reuses it.
|
|
135
|
+
- Alt text, caption and credit are set once per file; posts render the current values.
|
|
136
|
+
- A file used in a post body or as a cover cannot be trashed. Trashed files can be restored for 30 days.
|
|
137
|
+
- The post editor uploads into the library and has an "Insert from library" button; covers are chosen from the
|
|
138
|
+
library.
|
|
139
|
+
|
|
140
|
+
## Comments
|
|
141
|
+
|
|
142
|
+
Readers comment on live posts as guests with a name and email; signed-in authors comment as themselves and are
|
|
143
|
+
marked "Author". Replies go one level deep, and emails are never shown.
|
|
144
|
+
|
|
145
|
+
- Comments are off until a post turns on "Allow comments" (or the settings turn them on for new posts).
|
|
146
|
+
`Glib::Blog.comments_close_after = 30` closes them everywhere 30 days after publishing.
|
|
147
|
+
- Readers' comments wait for approval; staff comments appear at once. `Glib::Blog.comments_require_approval = false`
|
|
148
|
+
publishes every comment immediately. The blog's settings can change both.
|
|
149
|
+
- Editors and admins moderate any comment in `/blog/admin/comments`; authors those on their own posts. A comment is
|
|
150
|
+
pending, approved, spam or trash, and only approved ones appear on the post and in its comment count. Replying from
|
|
151
|
+
the admin approves the comment being answered. Spam and trash are deleted permanently by hand.
|
|
152
|
+
- Spam protection stores nothing about visitors:
|
|
153
|
+
- The form carries a signed token, refused when missing, forged, older than a day or used within 3 seconds.
|
|
154
|
+
- At most 5 comments per IP address every 10 minutes, counted in the cache store. Rate limiting needs a real
|
|
155
|
+
cache store; it is inert on `:null_store`.
|
|
156
|
+
|
|
157
|
+
## Roles
|
|
158
|
+
|
|
159
|
+
| Role | Can do |
|
|
160
|
+
| --- | --- |
|
|
161
|
+
| author | Write, edit and delete their own posts |
|
|
162
|
+
| editor | Everything an author can, on everyone's posts, plus categories and tags |
|
|
163
|
+
| admin | Everything, including authors |
|
|
164
|
+
|
|
165
|
+
## URLs
|
|
166
|
+
|
|
167
|
+
| Path | Page |
|
|
168
|
+
| --- | --- |
|
|
169
|
+
| `/blog` | Live posts, newest first |
|
|
170
|
+
| `/blog/:slug` | A post. Old slugs answer with a 301; drafts, archived and scheduled posts are 404 |
|
|
171
|
+
| `/blog/categories/:slug`, `/blog/tags/:slug`, `/blog/authors/:slug` | Live posts in that category, tag or by that author |
|
|
172
|
+
| `/blog/admin` | Admin, starting at the dashboard |
|