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,68 @@
|
|
|
1
|
+
page = json_ui_page json
|
|
2
|
+
file_url = "#{request.base_url}#{@media_item.original_url}"
|
|
3
|
+
details = {
|
|
4
|
+
t('.file') => @media_item.filename,
|
|
5
|
+
t('.size') => [number_to_human_size(@media_item.byte_size), (@media_item.width && "#{@media_item.width} × #{@media_item.height}")].compact.join(' · '),
|
|
6
|
+
t('.uploaded') => l(@media_item.created_at.to_date, format: :long)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
glib_blog_admin_page json, page, active: :media, title: @media_item.title_or_filename do |res|
|
|
10
|
+
res.panels_responsive width: 'matchParent', childViews: ->(columns) do
|
|
11
|
+
columns.panels_column md: { cols: 5 }, xs: { cols: 12 }, styleClasses: ['admin-column'], childViews: ->(column) do
|
|
12
|
+
column.panels_vertical width: 'matchParent', styleClasses: ['admin-card', 'admin-card--padded'], childViews: ->(card) do
|
|
13
|
+
card.h2 text: t('.details')
|
|
14
|
+
if @media_item.image?
|
|
15
|
+
card.image url: @media_item.url(:medium), width: 'matchParent', styleClasses: ['admin-media-preview']
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
details.each do |term, value|
|
|
19
|
+
card.panels_split width: 'matchParent', styleClasses: ['admin-dl'], content: ->(split) do
|
|
20
|
+
split.left childViews: ->(left) { left.label text: term, styleClasses: ['admin-muted'] }
|
|
21
|
+
split.right childViews: ->(right) { right.label text: value }
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
card.label text: t('.usages'), styleClasses: ['editor-section']
|
|
26
|
+
if @usages.empty?
|
|
27
|
+
card.label text: t('.unused'), styleClasses: ['admin-muted']
|
|
28
|
+
else
|
|
29
|
+
@usages.each do |usage|
|
|
30
|
+
url = usage.logo? ? edit_admin_settings_url : edit_admin_post_url(usage.record)
|
|
31
|
+
card.button \
|
|
32
|
+
text: t(".roles.#{usage.role}", title: usage.record.title),
|
|
33
|
+
styleClasses: ['text', 'small', 'admin-link'],
|
|
34
|
+
onClick: ->(action) { action.windows_open url: url }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
card.panels_flow innerPadding: { bottom: 0, right: 8 }, styleClasses: ['admin-card__actions'], childViews: ->(flow) do
|
|
39
|
+
flow.button text: t('.copy_url'), icon: 'content_copy', styleClasses: ['outlined'], onClick: ->(action) do
|
|
40
|
+
action.commands_copy text: file_url, onCopy: ->(subaction) { subaction.snackbars_alert message: t('.copied') }
|
|
41
|
+
end
|
|
42
|
+
if @usages.empty?
|
|
43
|
+
flow.button text: t('.trash'), icon: 'delete', styleClasses: ['text', 'error'], onClick: ->(action) do
|
|
44
|
+
action.http_post url: admin_media_item_trashes_url, formData: { id: @media_item.id, authenticity_token: form_authenticity_token }
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
columns.panels_column md: { cols: 7 }, xs: { cols: 12 }, styleClasses: ['admin-column'], childViews: ->(column) do
|
|
52
|
+
column.panels_vertical width: 'matchParent', styleClasses: ['admin-card', 'admin-form'], childViews: ->(card) do
|
|
53
|
+
card.panels_form model: @media_item, url: admin_media_item_url(@media_item), method: :patch, width: 'matchParent', childViews: ->(form) do
|
|
54
|
+
form.fields_text prop: :title, width: 'matchParent'
|
|
55
|
+
form.fields_text prop: :alt_text, width: 'matchParent'
|
|
56
|
+
form.fields_textarea prop: :caption, width: 'matchParent'
|
|
57
|
+
form.fields_text prop: :credit, width: 'matchParent'
|
|
58
|
+
if @media_item.image?
|
|
59
|
+
form.fields_number prop: :focal_x, width: 'matchParent', min: 0, max: 1, precision: 2
|
|
60
|
+
form.fields_number prop: :focal_y, width: 'matchParent', min: 0, max: 1, precision: 2
|
|
61
|
+
end
|
|
62
|
+
form.spacer height: 8
|
|
63
|
+
form.fields_submit text: t('.save'), styleClasses: ['primary', 'flat']
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
page = json_ui_page json
|
|
2
|
+
filters = params.permit(:q, :kind, :month, :unused).to_h.symbolize_keys
|
|
3
|
+
next_page = { url: admin_media_items_url(filters.merge(page: @next_page, section_only: 'v1')), autoload: 'asNeeded' } if @next_page
|
|
4
|
+
|
|
5
|
+
# Infinite scroll asks for just the next section.
|
|
6
|
+
if params[:section_only].present?
|
|
7
|
+
json.nextPage next_page if next_page
|
|
8
|
+
json.sections do
|
|
9
|
+
json.child! do
|
|
10
|
+
render 'glib/blog/admin/media_items/rows', json: json, section: page.list_section_builder, media_items: @media_items
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
else
|
|
14
|
+
actions = ->(flow) do
|
|
15
|
+
flow.button text: t('.trash'), icon: 'delete', styleClasses: ['text'], onClick: ->(action) do
|
|
16
|
+
action.windows_open url: admin_media_item_trashes_url
|
|
17
|
+
end
|
|
18
|
+
flow.button text: t('.upload'), icon: 'upload', styleClasses: ['primary', 'flat'], onClick: ->(action) do
|
|
19
|
+
action.windows_open url: new_admin_media_item_url
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
subtitle = t('.subtitle', count: @library_count, size: number_to_human_size(@library_bytes))
|
|
24
|
+
|
|
25
|
+
glib_blog_admin_page json, page, active: :media, title: t('.title'), subtitle: subtitle, actions: actions do |res|
|
|
26
|
+
res.panels_form url: admin_media_items_url, method: :get, width: 'matchParent', styleClasses: ['admin-filters'], childViews: ->(form) do
|
|
27
|
+
form.panels_flow innerPadding: { bottom: 0, right: 8 }, width: 'matchParent', childViews: ->(flow) do
|
|
28
|
+
flow.fields_text name: 'q', placeholder: t('.search'), value: params[:q], width: 280, leftIcon: 'search', styleClasses: ['compact']
|
|
29
|
+
flow.fields_select \
|
|
30
|
+
name: 'kind',
|
|
31
|
+
label: t('.kind'),
|
|
32
|
+
value: params[:kind].to_s,
|
|
33
|
+
width: 160,
|
|
34
|
+
styleClasses: ['compact'],
|
|
35
|
+
options: [{ text: t('.all_kinds'), value: '' }] +
|
|
36
|
+
Glib::Blog::MediaItem.kinds.keys.map { |kind| { text: t(".kinds.#{kind}"), value: kind } }
|
|
37
|
+
flow.fields_select \
|
|
38
|
+
name: 'month',
|
|
39
|
+
label: t('.month'),
|
|
40
|
+
value: params[:month].to_s,
|
|
41
|
+
width: 180,
|
|
42
|
+
styleClasses: ['compact'],
|
|
43
|
+
options: [{ text: t('.all_months'), value: '' }] +
|
|
44
|
+
@months.map { |month| { text: l(month, format: '%B %Y'), value: month.strftime('%Y-%m') } }
|
|
45
|
+
flow.fields_check name: 'unused', label: t('.unused_only'), checkValue: 'true', value: params[:unused]
|
|
46
|
+
flow.fields_submit text: t('.filter'), styleClasses: ['text']
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
if @media_items.empty?
|
|
51
|
+
res.panels_vertical width: 'matchParent', styleClasses: ['admin-card'], childViews: ->(card) do
|
|
52
|
+
card.label text: t('.empty'), styleClasses: ['admin-empty']
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
res.panels_form url: admin_media_item_trashes_url, method: :post, width: 'matchParent', childViews: ->(form) do
|
|
56
|
+
form.panels_list \
|
|
57
|
+
width: 'matchParent',
|
|
58
|
+
fieldPrefix: 'media_items',
|
|
59
|
+
nextPage: next_page,
|
|
60
|
+
styleClasses: ['admin-media-grid'],
|
|
61
|
+
firstSection: ->(section) do
|
|
62
|
+
render 'glib/blog/admin/media_items/rows', json: json, section: section, media_items: @media_items
|
|
63
|
+
end
|
|
64
|
+
form.fields_submit text: t('.trash_selected'), styleClasses: ['outlined', 'admin-media-trash']
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
page = json_ui_page json
|
|
2
|
+
|
|
3
|
+
glib_blog_admin_page json, page, active: :media, title: t('.title'), subtitle: t('.rules') do |res|
|
|
4
|
+
res.panels_vertical width: 'matchParent', styleClasses: ['admin-card', 'admin-form'], childViews: ->(card) do
|
|
5
|
+
card.panels_form url: admin_media_items_url, method: :post, width: 'matchParent', childViews: ->(form) do
|
|
6
|
+
form.fields_upload \
|
|
7
|
+
name: 'signed_ids[]',
|
|
8
|
+
width: 'matchParent',
|
|
9
|
+
multiple: true,
|
|
10
|
+
styleClasses: ['admin-dropzone'],
|
|
11
|
+
directUploadUrl: admin_direct_uploads_url,
|
|
12
|
+
accepts: { fileType: ['image', 'pdf'], maxFileSize: Glib::Blog::MediaUpload::MAX_BYTE_SIZE / 1000 },
|
|
13
|
+
multiProgressView: { files: [] }
|
|
14
|
+
form.spacer height: 16
|
|
15
|
+
form.fields_submit text: t('.save'), styleClasses: ['primary', 'flat']
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
page = json_ui_page json
|
|
2
|
+
pick = { mode: @mode, target: @target }
|
|
3
|
+
next_page = if @next_page
|
|
4
|
+
{ url: admin_media_picks_url(mode: @mode, target: @target, page: @next_page, section_only: 'v1'), autoload: 'asNeeded' }
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
# Infinite scroll asks for just the next section.
|
|
8
|
+
if params[:section_only].present?
|
|
9
|
+
json.nextPage next_page if next_page
|
|
10
|
+
json.sections do
|
|
11
|
+
json.child! do
|
|
12
|
+
render 'glib/blog/admin/media_items/rows', json: json, section: page.list_section_builder, media_items: @media_items, pick: pick
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
else
|
|
16
|
+
json.title t(".title.#{@mode}")
|
|
17
|
+
|
|
18
|
+
page.body childViews: ->(body) do
|
|
19
|
+
body.panels_responsive padding: glib_json_padding_body, childViews: ->(res) do
|
|
20
|
+
if @media_items.empty?
|
|
21
|
+
res.label text: t('.empty')
|
|
22
|
+
else
|
|
23
|
+
res.panels_list width: 'matchParent', nextPage: next_page, firstSection: ->(section) do
|
|
24
|
+
render 'glib/blog/admin/media_items/rows', json: json, section: section, media_items: @media_items, pick: pick
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# The full-screen post editor. Locals: page, title, url, method.
|
|
2
|
+
status = glib_blog_post_status(@post)
|
|
3
|
+
|
|
4
|
+
json.title title
|
|
5
|
+
json.styleClasses ['blog-admin']
|
|
6
|
+
page.template 'fullWidth'
|
|
7
|
+
|
|
8
|
+
page.body childViews: ->(body) do
|
|
9
|
+
body.html text: admin_stylesheet_html
|
|
10
|
+
body.panels_form model: @post, url: url, method: method, width: 'matchParent', styleClasses: ['editor'], childViews: ->(form) do
|
|
11
|
+
form.fields_hidden prop: :lock_version if @post.persisted?
|
|
12
|
+
|
|
13
|
+
form.panels_split width: 'matchParent', align: 'middle', styleClasses: ['editor-topbar'], content: ->(split) do
|
|
14
|
+
split.left childViews: ->(left) do
|
|
15
|
+
left.panels_horizontal align: 'middle', childViews: ->(horizontal) do
|
|
16
|
+
horizontal.button text: t('.back'), icon: 'chevron_left', styleClasses: ['text', 'editor-back'], onClick: ->(action) do
|
|
17
|
+
action.windows_open url: admin_posts_url
|
|
18
|
+
end
|
|
19
|
+
render 'glib/blog/admin/status_chip', json: json, view: horizontal, status: status, text: t("glib.blog.admin.statuses.#{status}")
|
|
20
|
+
if @post.persisted?
|
|
21
|
+
horizontal.label text: t('.saved', time: time_ago_in_words(@post.updated_at)), styleClasses: ['admin-muted', 'editor-saved']
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
split.right childViews: ->(right) do
|
|
26
|
+
right.panels_flow innerPadding: { bottom: 0, right: 8 }, align: 'middle', childViews: ->(flow) do
|
|
27
|
+
if @post.live?
|
|
28
|
+
flow.button text: t('.view'), icon: 'open_in_new', styleClasses: ['outlined'], onClick: ->(action) do
|
|
29
|
+
action.windows_open url: post_url(@post.slug)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
flow.fields_submit text: t('.save'), styleClasses: ['primary', 'flat']
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
form.panels_responsive width: 'matchParent', styleClasses: ['editor-columns'], childViews: ->(res) do
|
|
38
|
+
res.panels_column lg: { cols: 9 }, md: { cols: 8 }, xs: { cols: 12 }, styleClasses: ['editor-main'], childViews: ->(main) do
|
|
39
|
+
main.fields_text prop: :title, width: 'matchParent', placeholder: t('.title_placeholder'), styleClasses: ['editor-title']
|
|
40
|
+
main.fields_actionText \
|
|
41
|
+
id: 'post_body',
|
|
42
|
+
prop: :body,
|
|
43
|
+
width: 'matchParent',
|
|
44
|
+
styleClasses: ['editor-body'],
|
|
45
|
+
directUploadUrl: admin_direct_uploads_url,
|
|
46
|
+
attachmentUrl: admin_editor_attachments_url,
|
|
47
|
+
libraryUrl: admin_media_picks_url(target: 'post_body', mode: 'body'),
|
|
48
|
+
accepts: { fileType: ['image', 'pdf'], maxFileSize: Glib::Blog::MediaUpload::MAX_BYTE_SIZE / 1000 }
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
res.panels_column lg: { cols: 3 }, md: { cols: 4 }, xs: { cols: 12 }, styleClasses: ['editor-aside'], childViews: ->(aside) do
|
|
52
|
+
aside.label text: t('.publishing'), styleClasses: ['editor-section']
|
|
53
|
+
aside.fields_select \
|
|
54
|
+
prop: :status,
|
|
55
|
+
width: 'matchParent',
|
|
56
|
+
options: Glib::Blog::Post.statuses.keys.map { |key| { text: t("glib.blog.admin.statuses.#{key}"), value: key } }
|
|
57
|
+
aside.fields_datetime prop: :published_at, width: 'matchParent', clearable: true
|
|
58
|
+
aside.fields_check prop: :comments_enabled, checkValue: true, uncheckValue: false
|
|
59
|
+
aside.fields_check prop: :featured, checkValue: true, uncheckValue: false
|
|
60
|
+
|
|
61
|
+
aside.label text: t('.cover'), styleClasses: ['editor-section']
|
|
62
|
+
aside.fields_hidden id: 'cover_media_item_id', prop: :cover_media_item_id
|
|
63
|
+
aside.image id: 'cover_media_item_preview', url: @post.cover_media_item&.url(:medium), width: 'matchParent', styleClasses: ['editor-cover']
|
|
64
|
+
aside.panels_flow innerPadding: { bottom: 0, right: 8 }, childViews: ->(flow) do
|
|
65
|
+
flow.button text: t('.choose_cover'), icon: 'image', styleClasses: ['outlined'], onClick: ->(action) do
|
|
66
|
+
action.dialogs_open url: admin_media_picks_url(target: 'cover_media_item', mode: 'cover')
|
|
67
|
+
end
|
|
68
|
+
flow.button text: t('.remove_cover'), styleClasses: ['text'], onClick: ->(action) do
|
|
69
|
+
action.runMultiple childActions: ->(multiple) do
|
|
70
|
+
multiple.logics_set targetId: 'cover_media_item_id', data: { value: '' }
|
|
71
|
+
multiple.logics_set targetId: 'cover_media_item_preview', data: { url: nil }
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
aside.label text: t('.organize'), styleClasses: ['editor-section']
|
|
77
|
+
aside.fields_select \
|
|
78
|
+
prop: :category_id,
|
|
79
|
+
width: 'matchParent',
|
|
80
|
+
options: [{ text: t('.no_category'), value: '' }] +
|
|
81
|
+
@categories.map { |category| { text: category.parent_id ? "— #{category.name}" : category.name, value: category.id } }
|
|
82
|
+
aside.fields_text prop: :tag_list, width: 'matchParent'
|
|
83
|
+
|
|
84
|
+
aside.label text: t('.seo'), styleClasses: ['editor-section']
|
|
85
|
+
aside.fields_text prop: :slug, width: 'matchParent', styleClasses: ['admin-mono']
|
|
86
|
+
aside.fields_textarea prop: :excerpt, width: 'matchParent'
|
|
87
|
+
aside.fields_text prop: :meta_title, width: 'matchParent'
|
|
88
|
+
aside.fields_textarea prop: :meta_description, width: 'matchParent'
|
|
89
|
+
aside.fields_url prop: :canonical_url, width: 'matchParent'
|
|
90
|
+
aside.fields_check prop: :noindex, checkValue: true, uncheckValue: false
|
|
91
|
+
|
|
92
|
+
if @post.persisted?
|
|
93
|
+
bulk_action = @post.trashed? ? 'restore' : 'trash'
|
|
94
|
+
aside.button text: t(".#{bulk_action}"), styleClasses: ['text', (@post.trashed? ? nil : 'error')].compact, onClick: ->(action) do
|
|
95
|
+
action.http_post url: admin_post_bulk_actions_url, formData: {
|
|
96
|
+
'bulk_action' => bulk_action, 'post_ids[]' => @post.id, 'authenticity_token' => form_authenticity_token,
|
|
97
|
+
'return_status' => ('trash' if @post.trashed?)
|
|
98
|
+
}.compact
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
render 'glib/blog/admin/posts/form', json: json, page: json_ui_page(json), title: t('.title'), url: admin_post_url(@post), method: :patch
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
page = json_ui_page json
|
|
2
|
+
filters = { status: @status, q: params[:q].presence }.compact
|
|
3
|
+
next_page = { url: admin_posts_url(filters.merge(page: @next_page, section_only: 'v1')), autoload: 'asNeeded' } if @next_page
|
|
4
|
+
|
|
5
|
+
bulk_actions = @status == 'trash' ? [:restore] : [:publish, :draft, :trash]
|
|
6
|
+
|
|
7
|
+
# One post through the bulk endpoint, from its row.
|
|
8
|
+
post_action = lambda do |post, bulk_action|
|
|
9
|
+
lambda do |action|
|
|
10
|
+
action.http_post url: admin_post_bulk_actions_url, formData: {
|
|
11
|
+
'bulk_action' => bulk_action, 'post_ids[]' => post.id, 'return_status' => @status, 'authenticity_token' => form_authenticity_token
|
|
12
|
+
}.compact
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Only the title opens the post, so ticking a row's checkbox never also navigates.
|
|
17
|
+
rows = ->(section) do
|
|
18
|
+
section.rows objects: @posts, builder: ->(row, post, _index) do
|
|
19
|
+
status = glib_blog_post_status(post)
|
|
20
|
+
|
|
21
|
+
row.default cellViews: ->(cell) do
|
|
22
|
+
cell.fields_check name: 'post_ids[]', checkValue: post.id, label: t('glib.blog.admin.posts.index.select', title: post.title)
|
|
23
|
+
cell.label text: post.title, styleClasses: ['admin-table__primary', 'admin-table__link'], onClick: ->(action) do
|
|
24
|
+
action.windows_open url: edit_admin_post_url(post)
|
|
25
|
+
end
|
|
26
|
+
cell.label text: post.author.display_name
|
|
27
|
+
cell.label text: post.category&.name || '—'
|
|
28
|
+
render 'glib/blog/admin/status_chip', json: json, view: cell, status: status, text: t("glib.blog.admin.statuses.#{status}")
|
|
29
|
+
cell.label text: post.comments_count.to_s, styleClasses: ['admin-mono']
|
|
30
|
+
cell.label text: glib_blog_post_date(post), styleClasses: ['admin-muted']
|
|
31
|
+
cell.panels_horizontal childViews: ->(buttons) do
|
|
32
|
+
if post.trashed?
|
|
33
|
+
buttons.button styleClasses: ['icon', 'text', 'x-small'], icon: 'restore_from_trash', tooltip: { text: t('.bulk.restore') },
|
|
34
|
+
onClick: post_action.call(post, 'restore')
|
|
35
|
+
render 'glib/blog/admin/delete_button', json: json, menu: buttons, name: post.title, url: admin_post_url(post), icon: 'delete_forever'
|
|
36
|
+
else
|
|
37
|
+
buttons.button styleClasses: ['icon', 'text', 'x-small'], icon: 'delete_outline', tooltip: { text: t('.bulk.trash') },
|
|
38
|
+
onClick: post_action.call(post, 'trash')
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Infinite scroll asks for just the next section.
|
|
46
|
+
if params[:section_only].present?
|
|
47
|
+
json.nextPage next_page if next_page
|
|
48
|
+
json.sections do
|
|
49
|
+
json.child! { rows.call(page.table_section_builder) }
|
|
50
|
+
end
|
|
51
|
+
else
|
|
52
|
+
actions = ->(flow) do
|
|
53
|
+
flow.button text: t('.new'), icon: 'add', styleClasses: ['primary', 'flat'], onClick: ->(action) do
|
|
54
|
+
action.windows_open url: new_admin_post_url
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
glib_blog_admin_page json, page, active: :posts, title: t('.title'), subtitle: t('.subtitle'), actions: actions do |res|
|
|
59
|
+
res.panels_flow width: 'matchParent', innerPadding: { bottom: 0, right: 4 }, styleClasses: ['admin-tabs'], childViews: ->(tabs) do
|
|
60
|
+
[nil, *Glib::Blog::Admin::PostsController::STATUS_FILTERS.keys].each do |status|
|
|
61
|
+
tabs.button \
|
|
62
|
+
text: "#{t(".tabs.#{status || 'all'}")} #{@status_counts[status || 'all']}",
|
|
63
|
+
styleClasses: ['text', 'admin-tab', (status == @status ? 'active' : nil)].compact,
|
|
64
|
+
onClick: ->(action) { action.windows_open url: admin_posts_url(status: status, q: params[:q].presence) }
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
res.panels_form url: admin_posts_url, method: :get, width: 'matchParent', styleClasses: ['admin-filters'], childViews: ->(form) do
|
|
69
|
+
form.fields_hidden name: 'status', value: @status if @status
|
|
70
|
+
form.panels_flow innerPadding: { bottom: 0, right: 8 }, width: 'matchParent', childViews: ->(flow) do
|
|
71
|
+
flow.fields_text name: 'q', placeholder: t('.search'), value: params[:q], width: 320, leftIcon: 'search', styleClasses: ['compact']
|
|
72
|
+
flow.fields_submit text: t('.search_submit'), styleClasses: ['text']
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
if @posts.empty?
|
|
77
|
+
res.panels_vertical width: 'matchParent', styleClasses: ['admin-card'], childViews: ->(card) do
|
|
78
|
+
card.label text: t('.empty'), styleClasses: ['admin-empty']
|
|
79
|
+
end
|
|
80
|
+
else
|
|
81
|
+
res.panels_form url: admin_post_bulk_actions_url, method: :post, width: 'matchParent', childViews: ->(form) do
|
|
82
|
+
form.panels_vertical width: 'matchParent', styleClasses: ['admin-card'], childViews: ->(card) do
|
|
83
|
+
card.panels_flow \
|
|
84
|
+
width: 'matchParent',
|
|
85
|
+
align: 'middle',
|
|
86
|
+
innerPadding: { bottom: 0, right: 8 },
|
|
87
|
+
styleClasses: ['admin-bulk-bar'],
|
|
88
|
+
childViews: ->(bar) do
|
|
89
|
+
bar.label text: t('.bulk.label'), styleClasses: ['admin-muted', 'admin-small']
|
|
90
|
+
bulk_actions.each do |bulk_action|
|
|
91
|
+
bar.button text: t(".bulk.#{bulk_action}"), styleClasses: ['outlined', 'small'], onClick: ->(action) do
|
|
92
|
+
action.forms_submit extraFormData: { bulk_action: bulk_action, return_status: @status }.compact
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
card.panels_table width: 'matchParent', styleClasses: ['admin-table'], nextPage: next_page, firstSection: ->(section) do
|
|
98
|
+
section.header cellViews: ->(header) do
|
|
99
|
+
%w[select title author category status comments date actions].each do |column|
|
|
100
|
+
header.label text: t(".columns.#{column}")
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
rows.call(section)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
render 'glib/blog/admin/posts/form', json: json, page: json_ui_page(json), title: t('.title'), url: admin_posts_url, method: :post
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
page = json_ui_page json
|
|
2
|
+
|
|
3
|
+
section = lambda do |form, title, fields|
|
|
4
|
+
form.panels_vertical width: 'matchParent', styleClasses: ['admin-card', 'admin-form', 'admin-settings-section'], childViews: ->(card) do
|
|
5
|
+
card.h2 text: title
|
|
6
|
+
fields.call(card)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
glib_blog_admin_page json, page, active: :settings, title: t('.title'), subtitle: t('.subtitle') do |res|
|
|
11
|
+
res.panels_form model: @setting, url: admin_settings_url, method: :patch, width: 'matchParent', childViews: ->(form) do
|
|
12
|
+
section.call(form, t('.general'), lambda { |card|
|
|
13
|
+
card.fields_text prop: :title, width: 'matchParent'
|
|
14
|
+
card.fields_text prop: :tagline, width: 'matchParent'
|
|
15
|
+
|
|
16
|
+
card.label text: t('.logo'), styleClasses: ['editor-section']
|
|
17
|
+
card.fields_hidden id: 'logo_media_item_id', prop: :logo_media_item_id
|
|
18
|
+
card.image id: 'logo_media_item_preview', url: @setting.logo_media_item&.url(:thumb), width: 96, styleClasses: ['admin-settings-logo']
|
|
19
|
+
card.panels_flow innerPadding: { bottom: 0, right: 8 }, childViews: lambda { |flow|
|
|
20
|
+
flow.button text: t('.choose_logo'), icon: 'image', styleClasses: ['outlined'], onClick: lambda { |action|
|
|
21
|
+
action.dialogs_open url: admin_media_picks_url(target: 'logo_media_item', mode: 'logo')
|
|
22
|
+
}
|
|
23
|
+
flow.button text: t('.remove_logo'), styleClasses: ['text'], onClick: lambda { |action|
|
|
24
|
+
action.runMultiple childActions: lambda { |multiple|
|
|
25
|
+
multiple.logics_set targetId: 'logo_media_item_id', data: { value: '' }
|
|
26
|
+
multiple.logics_set targetId: 'logo_media_item_preview', data: { url: nil }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
section.call(form, t('.appearance'), lambda { |card|
|
|
33
|
+
# Selects the theme readers see, which is the first one while none is chosen.
|
|
34
|
+
card.fields_radioGroup prop: :theme, value: @setting.public_theme.name, childViews: lambda { |group|
|
|
35
|
+
Glib::Blog.themes.each_key do |name|
|
|
36
|
+
group.fields_radio value: name.to_s, label: t("glib.blog.themes.#{name}.name", default: name.to_s.humanize),
|
|
37
|
+
subtitle: t("glib.blog.themes.#{name}.description", default: nil)
|
|
38
|
+
end
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
section.call(form, t('.reading'), lambda { |card|
|
|
43
|
+
card.fields_number prop: :posts_per_page, width: 240, min: 1, max: Glib::Blog::Setting::MAX_POSTS_PER_PAGE
|
|
44
|
+
card.fields_check prop: :noindex, checkValue: true, uncheckValue: false
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
section.call(form, t('.comments'), lambda { |card|
|
|
48
|
+
card.fields_check prop: :comments_enabled_by_default, checkValue: true, uncheckValue: false
|
|
49
|
+
card.fields_check prop: :comments_require_approval, checkValue: true, uncheckValue: false
|
|
50
|
+
card.fields_number prop: :comments_close_after_days, width: 240, min: 0, hint: t('.close_after_hint')
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
form.fields_submit text: t('.save'), styleClasses: ['primary', 'flat']
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
view.panels_form model: @tag, url: url, method: method, width: 'matchParent', childViews: ->(form) do
|
|
2
|
+
form.fields_text prop: :name, width: 'matchParent'
|
|
3
|
+
form.fields_text prop: :slug, width: 'matchParent'
|
|
4
|
+
form.spacer height: 16
|
|
5
|
+
form.fields_submit text: t('.save'), styleClasses: ['primary', 'flat']
|
|
6
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
page = json_ui_page json
|
|
2
|
+
|
|
3
|
+
glib_blog_admin_page json, page, active: :categories_and_tags, title: t('.title') do |res|
|
|
4
|
+
res.panels_vertical width: 'matchParent', styleClasses: ['admin-card', 'admin-form'], childViews: ->(card) do
|
|
5
|
+
render 'glib/blog/admin/tags/form', json: json, view: card, url: admin_tag_url(@tag), method: :patch
|
|
6
|
+
end
|
|
7
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
page = json_ui_page json
|
|
2
|
+
|
|
3
|
+
actions = ->(flow) do
|
|
4
|
+
flow.button text: t('.new'), icon: 'add', styleClasses: ['primary', 'flat'], onClick: ->(action) do
|
|
5
|
+
action.windows_open url: new_admin_tag_url
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
glib_blog_admin_page json, page, active: :categories_and_tags, title: t('.title'), actions: actions do |res|
|
|
10
|
+
res.panels_vertical width: 'matchParent', styleClasses: ['admin-card'], childViews: ->(card) do
|
|
11
|
+
if @tags.empty?
|
|
12
|
+
card.label text: t('.empty'), styleClasses: ['admin-empty']
|
|
13
|
+
else
|
|
14
|
+
card.panels_table width: 'matchParent', styleClasses: ['admin-table'], firstSection: ->(section) do
|
|
15
|
+
section.header cellViews: ->(header) do
|
|
16
|
+
%w[name slug posts actions].each { |column| header.label text: t(".columns.#{column}") }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
section.rows objects: @tags, builder: ->(row, tag, _index) do
|
|
20
|
+
row.default onClick: ->(action) { action.windows_open url: edit_admin_tag_url(tag) }, cellViews: ->(cell) do
|
|
21
|
+
cell.label text: tag.name, styleClasses: ['admin-table__primary']
|
|
22
|
+
cell.label text: tag.slug, styleClasses: ['admin-mono', 'admin-muted']
|
|
23
|
+
cell.label text: tag.taggings_count.to_s, styleClasses: ['admin-mono']
|
|
24
|
+
render 'glib/blog/admin/delete_button', json: json, menu: cell, name: tag.name, url: admin_tag_url(tag)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
page = json_ui_page json
|
|
2
|
+
|
|
3
|
+
glib_blog_admin_page json, page, active: :categories_and_tags, title: t('.title') do |res|
|
|
4
|
+
res.panels_vertical width: 'matchParent', styleClasses: ['admin-card', 'admin-form'], childViews: ->(card) do
|
|
5
|
+
render 'glib/blog/admin/tags/form', json: json, view: card, url: admin_tags_url, method: :post
|
|
6
|
+
end
|
|
7
|
+
end
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# The comment is saved but waits for approval, so reloading the post alone would look as if it
|
|
2
|
+
# had been lost.
|
|
3
|
+
json_ui_response json do |action|
|
|
4
|
+
action.dialogs_alert title: t('.title'), message: t('.message'), onClose: ->(subaction) do
|
|
5
|
+
subaction.windows_reload url: post_url(@post.slug)
|
|
6
|
+
end
|
|
7
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%# Action Text passes the item wrapped in an ActionText::Attachment, whose own `caption` is the
|
|
2
|
+
caption typed into the editor; the library's caption is the item's. %>
|
|
3
|
+
<% item = media_item.try(:attachable) || media_item %>
|
|
4
|
+
<figure class="attachment attachment--<%= item.image? ? 'preview' : 'file' %>">
|
|
5
|
+
<% if item.image? %>
|
|
6
|
+
<%= image_tag item.url(:large), alt: item.alt_text.to_s, width: item.width, height: item.height %>
|
|
7
|
+
<% else %>
|
|
8
|
+
<%= link_to item.title_or_filename, item.original_url %>
|
|
9
|
+
<% end %>
|
|
10
|
+
<% caption = [item.caption.presence, item.credit.presence].compact.join(' · ') %>
|
|
11
|
+
<% if caption.present? %>
|
|
12
|
+
<figcaption class="attachment__caption"><%= caption %></figcaption>
|
|
13
|
+
<% end %>
|
|
14
|
+
</figure>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
view.panels_horizontal width: 'matchParent', childViews: ->(row) do
|
|
2
|
+
row.avatar initials: { text: comment.initials, color: '#FFFFFF' }, backgroundColor: comment.avatar_color
|
|
3
|
+
row.spacer width: 12
|
|
4
|
+
row.panels_vertical width: 'matchParent', childViews: ->(column) do
|
|
5
|
+
column.panels_flow innerPadding: { bottom: 0, right: 8 }, childViews: ->(heading) do
|
|
6
|
+
heading.label text: comment.author_name, styleClasses: ['bold']
|
|
7
|
+
heading.chip text: t('.staff') if comment.staff?
|
|
8
|
+
heading.label text: l(comment.created_at, format: :long), styleClasses: ['caption']
|
|
9
|
+
end
|
|
10
|
+
column.html text: glib_blog_comment_html(comment.body)
|
|
11
|
+
|
|
12
|
+
if @post.comments_open? && comment.parent_id.nil?
|
|
13
|
+
column.button text: t('.reply'), styleClasses: ['text', 'small'], onClick: ->(action) do
|
|
14
|
+
action.dialogs_show content: ->(dialog) do
|
|
15
|
+
dialog.body padding: glib_json_padding_body, childViews: ->(body) do
|
|
16
|
+
body.h3 text: t('.reply_to', name: comment.author_name)
|
|
17
|
+
render 'glib/blog/posts/comment_form', json: json, view: body, parent: comment
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# No autofocus: it would scroll every reader past the post to the form.
|
|
2
|
+
view.panels_form url: post_comments_url(@post.slug), method: :post, width: 'matchParent', autofocus: false, childViews: ->(form) do
|
|
3
|
+
form.fields_hidden name: 'comment[token]', value: Glib::Blog::CommentToken.generate(@post)
|
|
4
|
+
form.fields_hidden name: 'comment[parent_id]', value: parent.id if parent
|
|
5
|
+
|
|
6
|
+
if current_blog_author
|
|
7
|
+
form.label text: t('.as', name: current_blog_author.display_name)
|
|
8
|
+
else
|
|
9
|
+
form.fields_text name: 'comment[author_name]', label: t('.name'), width: 'matchParent'
|
|
10
|
+
form.fields_email name: 'comment[author_email]', label: t('.email'), hint: t('.email_hint'), width: 'matchParent'
|
|
11
|
+
end
|
|
12
|
+
form.fields_textarea name: 'comment[body]', label: t('.body'), width: 'matchParent', maxLength: Glib::Blog::Comment::MAX_BODY_LENGTH
|
|
13
|
+
form.fields_submit text: t('.submit')
|
|
14
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
view.spacer height: 32
|
|
2
|
+
view.h2 text: t('.title', count: @post.comments_count)
|
|
3
|
+
|
|
4
|
+
@comments.each do |comment|
|
|
5
|
+
view.spacer height: 16
|
|
6
|
+
render 'glib/blog/posts/comment', json: json, view: view, comment: comment
|
|
7
|
+
|
|
8
|
+
comment.approved_replies.each do |reply|
|
|
9
|
+
view.panels_vertical width: 'matchParent', padding: { left: 52, top: 12 }, childViews: ->(indented) do
|
|
10
|
+
render 'glib/blog/posts/comment', json: json, view: indented, comment: reply
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
view.spacer height: 24
|
|
16
|
+
if @post.comments_open?
|
|
17
|
+
view.h3 text: t('.leave')
|
|
18
|
+
render 'glib/blog/posts/comment_form', json: json, view: view, parent: nil
|
|
19
|
+
else
|
|
20
|
+
view.label text: t('.closed')
|
|
21
|
+
end
|