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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5d088ec6d58820618a3aa36589e438d615e44200e7a0376eddedac20a721d89b
|
|
4
|
+
data.tar.gz: 982bb5e1cefe4f064f95e7c8a8407c0a5fa9562bd205610a7e1a04d29fe64810
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 569d870e43d67adccbad29c44293d82fe6a0fd77c4d824e395b7a63d2817a605617a2c64cad62814363cf983f7121ea9c3bf9101231fcffda067c459a62efe50
|
|
7
|
+
data.tar.gz: b51321994361436a14f3bcc646d4c1aa46f126d345e31e2fd9aec5d945271c92fe7fed8e8443bc2b40ccf9a06574b20a6e9b7a42ba1ffe86b324ee6e72f018ab
|
|
@@ -4,8 +4,15 @@ module Glib::Json::Libs
|
|
|
4
4
|
included do
|
|
5
5
|
extend ClassMethods
|
|
6
6
|
|
|
7
|
+
# Glib::AppFeatureSupportHelper ships as a view helper (AllHelpers does
|
|
8
|
+
# `base.helper`), which never reaches controller ancestry — but the
|
|
9
|
+
# json_ui_app_version_gte? predicate below delegates to
|
|
10
|
+
# glib_app_version_gte, so the concern includes it itself (spec 464).
|
|
11
|
+
include Glib::AppFeatureSupportHelper
|
|
12
|
+
|
|
7
13
|
helper_method :json_ui_app_bundle_id, :json_ui_app_build_version, :json_ui_app_device_os
|
|
8
14
|
helper_method :json_ui_app_is_android?, :json_ui_app_is_ios?, :json_ui_app_is_web?
|
|
15
|
+
helper_method :json_ui_app_version_gte?
|
|
9
16
|
# helper_method :json_ui_redirect_back_or_to
|
|
10
17
|
helper_method :delete_redirect_back_url, :redirect_back_url
|
|
11
18
|
|
|
@@ -41,6 +48,15 @@ module Glib::Json::Libs
|
|
|
41
48
|
json_ui_app_device_os == 'web'
|
|
42
49
|
end
|
|
43
50
|
|
|
51
|
+
# Version predicate beside the OS ones (spec 464, Decision 8), so a view
|
|
52
|
+
# can write `json_ui_app_is_ios? && json_ui_app_version_gte?('2.0')`
|
|
53
|
+
# without the dictionary. One compare: delegates to
|
|
54
|
+
# glib_app_version_gte, which treats a blank or malformed version as
|
|
55
|
+
# passing (web never sends one).
|
|
56
|
+
def json_ui_app_version_gte?(version)
|
|
57
|
+
glib_app_version_gte(version, json_ui_app_build_version)
|
|
58
|
+
end
|
|
59
|
+
|
|
44
60
|
def json_ui_etag
|
|
45
61
|
template = "#{controller_name}/#{action_name}"
|
|
46
62
|
|
|
@@ -27,7 +27,8 @@ module Glib
|
|
|
27
27
|
blob.assign_attributes(**blob_args.except(:tagging, :prefix))
|
|
28
28
|
blob.save!
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
# GlibS3Service is only loaded when an app configures it, so referencing the constant breaks Disk-backed apps.
|
|
31
|
+
if blob.service.respond_to?(:tagging=)
|
|
31
32
|
blob.service.tagging = blob_args[:tagging]
|
|
32
33
|
end
|
|
33
34
|
|
|
@@ -1,16 +1,41 @@
|
|
|
1
1
|
module Glib
|
|
2
2
|
module AppFeatureSupportHelper
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
RESERVED_KEYS = %i[default except].freeze
|
|
4
|
+
# Feature-support gate (spec 464): per-feature, per-device minimum
|
|
5
|
+
# versions, read from what the request itself carries. Every feature
|
|
6
|
+
# entry is a Hash keyed by device (`:android`/`:ios`/`:web`), with
|
|
7
|
+
# `:default` and `:except` as the reserved keys — never read as
|
|
8
|
+
# devices:
|
|
9
|
+
#
|
|
10
|
+
# { my_feature: { android: '1.4.0', ios: '2.0', web: :all,
|
|
11
|
+
# default: '1.5', except: { android: '1.4.1' } } }
|
|
12
|
+
#
|
|
13
|
+
# A device key wins; a device without its own key falls back to
|
|
14
|
+
# `:default`; a feature with neither is unsupported. `:all` passes any
|
|
15
|
+
# client, and `except` excludes one exact version. An iOS-only
|
|
16
|
+
# component is `{ my_feature: { ios: '2.0' } }` — true only for iOS
|
|
17
|
+
# clients at 2.0 or later.
|
|
18
|
+
def glib_app_feature_supported?(name, dictionary, app_version: json_ui_app_build_version)
|
|
19
|
+
entry = dictionary[name.to_sym] or return false
|
|
20
|
+
device = json_ui_app_device_os.to_sym
|
|
21
|
+
# The device comes from a client header, so a client can send
|
|
22
|
+
# JsonUiApp-Device-Os: except — treating the reserved keys as
|
|
23
|
+
# devices would use the except Hash as a minimum version and raise
|
|
24
|
+
# inside Gem::Version (review round 1).
|
|
25
|
+
version = entry.key?(device) && !RESERVED_KEYS.include?(device) ? entry[device] : entry[:default]
|
|
26
|
+
except = entry.dig(:except, device)
|
|
27
|
+
!version.nil? && (version == :all || glib_app_version_gte(version, app_version)) &&
|
|
28
|
+
(except.nil? || except.to_s != app_version)
|
|
10
29
|
end
|
|
11
30
|
|
|
12
31
|
def glib_app_version_gte(feature_version, app_version)
|
|
13
|
-
|
|
32
|
+
# A blank version passes any minimum (web never sends one). A
|
|
33
|
+
# malformed one is treated as blank rather than raised: the version
|
|
34
|
+
# arrives as a client header, and a page render must not 500 on it
|
|
35
|
+
# (spec 464, Decision 7).
|
|
36
|
+
return true if app_version.blank? || !Gem::Version.correct?(app_version)
|
|
37
|
+
|
|
38
|
+
Gem::Version.new(app_version) >= Gem::Version.new(feature_version)
|
|
14
39
|
end
|
|
15
40
|
end
|
|
16
41
|
end
|
|
@@ -609,6 +609,10 @@ class Glib::JsonUi::ViewBuilder
|
|
|
609
609
|
|
|
610
610
|
# Rich text editor field with WYSIWYG editing.
|
|
611
611
|
#
|
|
612
|
+
# @deprecated Quill has an unfixed XSS advisory. Use `fields_actionText` for rich text, or
|
|
613
|
+
# `fields_textarea` where users write markdown themselves. See the glib-web-npm
|
|
614
|
+
# `doc/rich_text_migration.md` guide.
|
|
615
|
+
#
|
|
612
616
|
# Provides a full-featured text editor with formatting options, image uploads,
|
|
613
617
|
# and @mention support. Can output HTML or Markdown.
|
|
614
618
|
#
|
|
@@ -663,6 +667,94 @@ class Glib::JsonUi::ViewBuilder
|
|
|
663
667
|
|
|
664
668
|
# Enables debug mode with additional logging.
|
|
665
669
|
bool :debug
|
|
670
|
+
|
|
671
|
+
# Override
|
|
672
|
+
def created
|
|
673
|
+
super
|
|
674
|
+
# Local only: every render of every richText field would otherwise flood remote logging.
|
|
675
|
+
GLog.local_warn(
|
|
676
|
+
'`fields_richText` is deprecated: use `fields_actionText`, or `fields_textarea` for ' \
|
|
677
|
+
'markdown input. See doc/rich_text_migration.md in glib-web-npm.'
|
|
678
|
+
)
|
|
679
|
+
end
|
|
680
|
+
end
|
|
681
|
+
|
|
682
|
+
# Trix editor field that submits the same HTML as Rails' Action Text form helper,
|
|
683
|
+
# so the value can be assigned straight to a `has_rich_text` attribute.
|
|
684
|
+
#
|
|
685
|
+
# Attached files are uploaded directly to Active Storage and embedded as Action Text
|
|
686
|
+
# attachments (identified by the blob's `attachable_sgid`), so `has_rich_text` resolves
|
|
687
|
+
# them on save without any custom parsing. Requires the host app to load
|
|
688
|
+
# `action_text/engine`.
|
|
689
|
+
#
|
|
690
|
+
# When `prop` refers to a `has_rich_text` attribute, the field is pre-filled with the
|
|
691
|
+
# attribute's `to_trix_html`.
|
|
692
|
+
#
|
|
693
|
+
# @example Action Text attribute on a model form
|
|
694
|
+
# form.fields_actionText \
|
|
695
|
+
# prop: :body,
|
|
696
|
+
# width: 'matchParent',
|
|
697
|
+
# directUploadUrl: glib_direct_uploads_url,
|
|
698
|
+
# blobUrlGenerator: glib_blob_url_generators_url,
|
|
699
|
+
# accepts: { fileType: ['image', 'pdf'], maxFileSize: 10_000 }
|
|
700
|
+
#
|
|
701
|
+
# @see app/views/json_ui/garage/forms/action_text.json.jbuilder Garage example
|
|
702
|
+
# @see ViewBuilder::ActionText View that renders the saved content
|
|
703
|
+
class ActionText < AbstractField
|
|
704
|
+
include Glib::JsonUi::Upload
|
|
705
|
+
include Glib::JsonUi::FileUploadErrorHandler
|
|
706
|
+
|
|
707
|
+
# Endpoint that receives `signed_id` and returns `{ url: ... }` for an uploaded blob.
|
|
708
|
+
# The URL becomes the attachment's preview in the editor. File attachments are
|
|
709
|
+
# disabled when `directUploadUrl` or both this and `attachmentUrl` are missing.
|
|
710
|
+
# @example blobUrlGenerator: glib_blob_url_generators_url
|
|
711
|
+
string :blobUrlGenerator
|
|
712
|
+
|
|
713
|
+
# Endpoint that receives an uploaded blob's `signed_id` and returns the Trix attachment
|
|
714
|
+
# attributes to embed instead of the blob's own (at least `sgid` and `url`). Lets an app
|
|
715
|
+
# turn uploads into its own Action Text attachables, e.g. media library items. Replaces
|
|
716
|
+
# `blobUrlGenerator` when set.
|
|
717
|
+
# @example attachmentUrl: editor_attachments_url
|
|
718
|
+
string :attachmentUrl
|
|
719
|
+
|
|
720
|
+
# Page opened in a dialog by an "Insert from library" toolbar button. The page inserts a
|
|
721
|
+
# file by invoking the field's `insertAttachment` method with the attachment attributes
|
|
722
|
+
# (`components_invoke targetId: <field id>, name: 'insertAttachment', arguments: {...}`).
|
|
723
|
+
# @example libraryUrl: media_picks_url(target: 'post_body')
|
|
724
|
+
string :libraryUrl
|
|
725
|
+
|
|
726
|
+
# People offered when the user types `@`. Each item is
|
|
727
|
+
# `{ sgid:, value:, text:, avatar:, group: }`; only `value` is required. An item with an
|
|
728
|
+
# `sgid` is inserted as an Action Text attachment that `has_rich_text` resolves to the
|
|
729
|
+
# record (its model must include `ActionText::Attachable`). When the sgid does not resolve
|
|
730
|
+
# (a plain column, a deleted record), the attachment renders its own `@value` text. An
|
|
731
|
+
# item without an `sgid` is inserted as plain `@value` text.
|
|
732
|
+
# @example mentionList: users.map { |u| { sgid: u.attachable_sgid, value: u.name } }
|
|
733
|
+
array :mentionList
|
|
734
|
+
|
|
735
|
+
# Endpoint searched as the user types after `@` (`GET <url>?term=...`), returning
|
|
736
|
+
# `{ items: [...] }` in the `mentionList` item shape. Replaces filtering `mentionList`.
|
|
737
|
+
# @example mentionUrl: mention_searches_url
|
|
738
|
+
string :mentionUrl
|
|
739
|
+
|
|
740
|
+
# Hides the formatting toolbar, e.g. for a chat input. Keyboard shortcuts (Ctrl/Cmd+B, …)
|
|
741
|
+
# and pasting or dropping files (when uploads are configured) still work.
|
|
742
|
+
bool :hideToolbar
|
|
743
|
+
|
|
744
|
+
# Enter submits the enclosing form and Shift+Enter inserts a line break. While a mention
|
|
745
|
+
# list is open, Enter picks from it instead.
|
|
746
|
+
bool :submitOnEnter
|
|
747
|
+
|
|
748
|
+
def created
|
|
749
|
+
super
|
|
750
|
+
file_upload_error_handler_on_create
|
|
751
|
+
end
|
|
752
|
+
|
|
753
|
+
# Override
|
|
754
|
+
def determine_value(context, prop)
|
|
755
|
+
value = super
|
|
756
|
+
value.is_a?(::ActionText::RichText) ? value.to_trix_html : value
|
|
757
|
+
end
|
|
666
758
|
end
|
|
667
759
|
|
|
668
760
|
class Select < AbstractField
|
|
@@ -918,10 +1010,16 @@ class Glib::JsonUi::ViewBuilder
|
|
|
918
1010
|
# @example Offered saved signature
|
|
919
1011
|
# # The app composes the menu on the empty box from generic pieces:
|
|
920
1012
|
# # `onClick` runs while the field is blank, `popovers_show
|
|
921
|
-
# # anchor: 'pointer'` opens it at the tap point,
|
|
922
|
-
# #
|
|
923
|
-
# #
|
|
924
|
-
# #
|
|
1013
|
+
# # anchor: 'pointer'` opens it at the tap point,
|
|
1014
|
+
# # `components_invoke action_setSignature` applies a provided
|
|
1015
|
+
# # signature as a USER gesture (the form's dirty tracking and onChange
|
|
1016
|
+
# # hooks fire, so a pristine form becomes dirty), and
|
|
1017
|
+
# # `components_invoke action_open` opens the dialog. The action takes the
|
|
1018
|
+
# # signature as REQUIRED `arguments: { value, fileUrl }` -- the field
|
|
1019
|
+
# # carries no saved signature of its own. A plain `logics_set` of the same
|
|
1020
|
+
# # id previews it too but is the deliberate dirty-tracking non-trigger,
|
|
1021
|
+
# # for flows that fill the field without a user gesture.
|
|
1022
|
+
# # See the garage page for the full two-row composition.
|
|
925
1023
|
# form.fields_sign \
|
|
926
1024
|
# id: 'signature_offered',
|
|
927
1025
|
# name: 'user[signature_offered]',
|
|
@@ -934,14 +1032,14 @@ class Glib::JsonUi::ViewBuilder
|
|
|
934
1032
|
# body.panels_horizontal styleClasses: ['popover-menu-item'], align: 'middle',
|
|
935
1033
|
# childViews: ->(row) { row.label text: 'Use my saved signature' },
|
|
936
1034
|
# onClick: ->(sub) do
|
|
937
|
-
# sub.
|
|
1035
|
+
# sub.components_invoke targetId: 'signature_offered', name: 'action_setSignature',
|
|
1036
|
+
# arguments: { value: 'saved-signed-id', fileUrl: signature_url }
|
|
938
1037
|
# end
|
|
939
1038
|
# end
|
|
940
1039
|
# end
|
|
941
1040
|
# end,
|
|
942
1041
|
# draw: {
|
|
943
1042
|
# hint: 'Draw it once. We keep it for next time.',
|
|
944
|
-
# savedSignature: { value: 'saved-signed-id', fileUrl: signature_url },
|
|
945
1043
|
# saveOption: { name: 'user[save_signature_offered]', label: 'Save this signature for next time' }
|
|
946
1044
|
# }
|
|
947
1045
|
#
|
|
@@ -982,9 +1080,12 @@ class Glib::JsonUi::ViewBuilder
|
|
|
982
1080
|
# is a line under the canvas, shown only while the canvas is blank;
|
|
983
1081
|
# `placeholder` replaces the in-canvas "Draw your signature here" cue;
|
|
984
1082
|
# `confirmedHint` is the line under a painted (read-only) drawing on reopen;
|
|
985
|
-
# `savedSignature` is plain data
|
|
986
|
-
#
|
|
987
|
-
#
|
|
1083
|
+
# `savedSignature` is plain data serving ONE path: when an external
|
|
1084
|
+
# `logics_set` writes the field's value to `value` (not `action_setSignature`,
|
|
1085
|
+
# which takes its signature as arguments) the box previews `fileUrl`; a
|
|
1086
|
+
# `logics_set` stays a dirty-tracking non-trigger. Omit it unless the app
|
|
1087
|
+
# offers a signature through `logics_set`; `saveOption` is
|
|
1088
|
+
# a checkbox shown under fresh ink, in the
|
|
988
1089
|
# fields_check shape, whose tick is submitted under `saveOption[:name]` as a
|
|
989
1090
|
# SECOND hidden input -- the one exception to the field's single-param
|
|
990
1091
|
# contract, because a boolean cannot share the input that carries the signed
|
|
@@ -227,6 +227,35 @@ module Glib
|
|
|
227
227
|
class Html < AbstractText
|
|
228
228
|
end
|
|
229
229
|
|
|
230
|
+
# Renders Action Text content the way Rails' `rich_text.to_s` does: sanitized HTML
|
|
231
|
+
# with attachments expanded through their partials, styled as Trix content.
|
|
232
|
+
#
|
|
233
|
+
# @example Display a `has_rich_text` attribute
|
|
234
|
+
# panel.actionText richText: @post.body
|
|
235
|
+
#
|
|
236
|
+
# @see Fields::ActionText Field that edits the content
|
|
237
|
+
class ActionText < View
|
|
238
|
+
# An `ActionText::RichText` (a `has_rich_text` attribute), `ActionText::Content`, or the
|
|
239
|
+
# HTML one of them rendered.
|
|
240
|
+
def richText(rich_text)
|
|
241
|
+
json.set! 'html', ::ActionText::Content.with_renderer(html_renderer) { rich_text.to_s }
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
private
|
|
245
|
+
# Action Text renders through the current controller by default. Here that is a
|
|
246
|
+
# namespaced JSON controller, so a content attachment (e.g. a mention whose record is
|
|
247
|
+
# gone) would be looked up as `glib/action_text/contents/_content.json` and raise.
|
|
248
|
+
# A host-level HTML renderer resolves partials the way an HTML page would.
|
|
249
|
+
def html_renderer
|
|
250
|
+
request = page.context.request
|
|
251
|
+
::ApplicationController.renderer.new(
|
|
252
|
+
http_host: request.host_with_port,
|
|
253
|
+
https: request.ssl?,
|
|
254
|
+
script_name: request.script_name
|
|
255
|
+
)
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
230
259
|
class Label < AbstractText
|
|
231
260
|
# hash :actionCable
|
|
232
261
|
# string :format
|