trek 2.5.0 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.node-version +1 -1
- data/AGENTS.md +18 -14
- data/CHANGELOG.md +88 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +135 -124
- data/Makefile +9 -1
- data/README.md +17 -21
- data/app/components/trek/dashboard/tile_component/tile_component.css +9 -0
- data/app/components/trek/dashboard/tile_component/tile_component.html.slim +4 -2
- data/app/components/trek/dashboard/tile_component.rb +12 -2
- data/app/components/trek/form/content_editor_component/content_editor_component.css +9 -8
- data/app/components/trek/form/content_editor_component/content_editor_component.html.slim +19 -93
- data/app/components/trek/form/content_editor_component/content_editor_component.js +94 -251
- data/app/components/trek/form/content_editor_component/extensions/block_view.js +40 -0
- data/app/components/trek/form/content_editor_component/extensions/image_block.js +28 -26
- data/app/components/trek/form/content_editor_component/extensions/prompts_block.js +15 -26
- data/app/components/trek/form/content_editor_component/extensions/table_of_contents.js +1 -3
- data/app/components/trek/form/content_editor_component.rb +15 -0
- data/app/components/trek/form/image_field_component/image_field_component.css +40 -1
- data/app/components/trek/form/image_field_component/image_field_component.html.slim +0 -9
- data/app/components/trek/form/image_field_component/image_field_component.js +1 -2
- data/app/components/trek/form/image_field_component.rb +36 -9
- data/app/components/trek/form/password_strength_component/password_strength_component.css +2 -0
- data/app/components/trek/form/sound_field_component/sound_field_component.js +1 -2
- data/app/components/trek/security_check_component/security_check_component.css +69 -0
- data/app/components/trek/security_check_component/security_check_component.html.slim +19 -0
- data/app/components/trek/security_check_component/security_check_component.js +15 -0
- data/app/components/trek/security_check_component.rb +19 -0
- data/app/content/trek/content/cleaner.rb +53 -0
- data/app/content/trek/content/document.rb +2 -2
- data/app/content/trek/content/list_item.rb +1 -1
- data/app/content/trek/content/paragraph.rb +7 -2
- data/app/content/trek/content/prompts_block.rb +1 -2
- data/app/content/trek/content.rb +6 -0
- data/app/controllers/concerns/trek/auditable.rb +5 -2
- data/app/controllers/concerns/trek/localization.rb +6 -2
- data/app/controllers/concerns/trek/reorderable.rb +24 -6
- data/app/controllers/trek/csp_reports_controller.rb +14 -1
- data/app/controllers/trek/panels/prompts_controller.rb +1 -1
- data/app/controllers/trek/resource_controller.rb +5 -5
- data/app/jobs/trek/purge_expired_sessions_job.rb +4 -3
- data/app/jobs/trek/purge_expired_sign_in_codes_job.rb +15 -0
- data/app/models/concerns/trek/contentable.rb +15 -1
- data/app/models/concerns/trek/users/sign_in_code.rb +70 -0
- data/app/models/concerns/trek/users/sign_in_lockout.rb +4 -2
- data/app/policies/trek/security_check_policy.rb +8 -0
- data/app/uploaders/image_uploader.rb +77 -15
- data/app/views/trek/panels/links/_form.html.slim +2 -4
- data/app/views/trek/panels/prompts/create.turbo_stream.slim +0 -1
- data/config/locales/trek.en.yml +97 -11
- data/config/locales/trek.fr.yml +97 -11
- data/docs/.vitepress/config.mjs +5 -1
- data/docs/background-jobs.md +74 -0
- data/docs/content-editor.md +219 -0
- data/docs/customize.md +2 -0
- data/docs/deploy.md +69 -6
- data/docs/getting-started.md +16 -18
- data/docs/index.md +2 -2
- data/docs/personal-data.md +61 -0
- data/docs/proxies.md +2 -2
- data/docs/reference/components.md +4 -4
- data/docs/reference/concerns/contentable.md +10 -4
- data/docs/reference/concerns/formattable.md +1 -1
- data/docs/reference/concerns/fragmentable.md +12 -6
- data/docs/reference/concerns/orderable.md +2 -2
- data/docs/reference/concerns/search-engine-optimizable.md +1 -1
- data/docs/reference/concerns/searchable.md +14 -1
- data/docs/reference/concerns/sectionable.md +7 -3
- data/docs/reference/concerns/versionable.md +1 -1
- data/docs/reference/controllers.md +33 -1
- data/docs/reference/environment-variables.md +3 -2
- data/docs/reference/formatters.md +4 -31
- data/docs/reference/forms.md +7 -4
- data/docs/reference/generators/admin-user.md +1 -1
- data/docs/reference/generators/audit-log.md +12 -13
- data/docs/reference/generators/install.md +23 -11
- data/docs/reference/generators/public-accounts.md +159 -0
- data/docs/reference/generators/scaffold.md +28 -9
- data/docs/reference/generators/security-headers.md +5 -4
- data/docs/reference/generators/taxonomies.md +1 -1
- data/docs/reference/icons.md +5 -3
- data/docs/reference/index.md +10 -7
- data/docs/reference/models/current.md +5 -3
- data/docs/reference/models/page-version.md +1 -1
- data/docs/reference/models/user.md +7 -8
- data/docs/reference/uploaders.md +25 -0
- data/docs/reference/validators.md +1 -1
- data/docs/security.md +30 -9
- data/docs/what-is-trek.md +4 -4
- data/lib/generators/trek/USAGE +1 -1
- data/lib/generators/trek/audit_log_generator.rb +62 -0
- data/lib/generators/trek/helpers.rb +17 -0
- data/lib/generators/trek/install/admin/routes_generator.rb +2 -1
- data/lib/generators/trek/install/admin/security_check_generator.rb +36 -0
- data/lib/generators/trek/install/admin/users_generator.rb +6 -1
- data/lib/generators/trek/install/audit_log_generator.rb +9 -45
- data/lib/generators/trek/install/ci_generator.rb +19 -0
- data/lib/generators/trek/install/good_job_generator.rb +161 -0
- data/lib/generators/trek/install/model_specs_generator.rb +3 -3
- data/lib/generators/trek/install/postcss_generator.rb +1 -2
- data/lib/generators/trek/install/ruby_generator.rb +1 -1
- data/lib/generators/trek/install/scalingo_generator.rb +7 -45
- data/lib/generators/trek/install/translations_generator.rb +1 -2
- data/lib/generators/trek/install_generator.rb +18 -2
- data/lib/generators/trek/public_accounts_generator.rb +294 -0
- data/lib/generators/trek/scaffold_generator.rb +22 -21
- data/lib/generators/trek/scalingo_generator.rb +67 -0
- data/lib/generators/trek/templates/.gitlab-ci.yml +10 -1
- data/lib/generators/trek/templates/AGENTS.md +2 -2
- data/lib/generators/trek/templates/Makefile +1 -0
- data/lib/generators/trek/templates/config/i18n-tasks.yml.erb +0 -8
- data/lib/generators/trek/templates/controllers/admin/password_renewals_controller.rb +11 -0
- data/lib/generators/trek/templates/controllers/admin/security_checks_controller.rb +11 -0
- data/lib/generators/trek/templates/controllers/admin/user_sessions_controller.rb +1 -1
- data/lib/generators/trek/templates/controllers/admin/users_controller.rb +0 -8
- data/lib/generators/trek/templates/controllers/concerns/trek/authentication.rb +13 -4
- data/lib/generators/trek/templates/initializers/content_security_policy.rb +3 -2
- data/lib/generators/trek/templates/initializers/good_job.rb.tt +40 -0
- data/lib/generators/trek/templates/jobs/mail_delivery_job.rb +6 -0
- data/lib/generators/trek/templates/layouts/admin.html.slim +10 -0
- data/lib/generators/trek/templates/mailers/admin_mailer.rb +4 -2
- data/lib/generators/trek/templates/package.json.tt +1 -1
- data/lib/generators/trek/templates/policies/security_check.rb +4 -0
- data/lib/generators/trek/templates/public_accounts/api/authentication.rb.tt +76 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/accounts_controller.rb.tt +22 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/active_sessions_controller.rb.tt +21 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/base_controller.rb.tt +71 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/email_changes_controller.rb.tt +55 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/email_confirmations_controller.rb.tt +19 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/password_resets_controller.rb.tt +28 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/passwords_controller.rb.tt +17 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/registrations_controller.rb.tt +17 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/sessions_controller.rb.tt +57 -0
- data/lib/generators/trek/templates/public_accounts/api/controllers/sign_in_codes_controller.rb.tt +20 -0
- data/lib/generators/trek/templates/public_accounts/jobs/sign_in_code_job.rb.tt +23 -0
- data/lib/generators/trek/templates/public_accounts/locales/accounts.en.yml.tt +215 -0
- data/lib/generators/trek/templates/public_accounts/locales/accounts.fr.yml.tt +215 -0
- data/lib/generators/trek/templates/public_accounts/mailers/account_mailer.rb.tt +85 -0
- data/lib/generators/trek/templates/public_accounts/migrations/create_accounts.rb.tt +46 -0
- data/lib/generators/trek/templates/public_accounts/models/account/session.rb.tt +47 -0
- data/lib/generators/trek/templates/public_accounts/models/account/sign_in_code.rb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/models/account.rb.tt +87 -0
- data/lib/generators/trek/templates/public_accounts/spec/api/accounts_spec.rb.tt +90 -0
- data/lib/generators/trek/templates/public_accounts/spec/api/sign_ins_spec.rb.tt +188 -0
- data/lib/generators/trek/templates/public_accounts/spec/models/account/sign_in_code_spec.rb.tt +66 -0
- data/lib/generators/trek/templates/public_accounts/spec/models/account_spec.rb.tt +129 -0
- data/lib/generators/trek/templates/public_accounts/spec/web/accounts_spec.rb.tt +126 -0
- data/lib/generators/trek/templates/public_accounts/spec/web/authentication_spec.rb.tt +43 -0
- data/lib/generators/trek/templates/public_accounts/spec/web/sign_ins_spec.rb.tt +237 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.en.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.en.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.fr.html.slim.tt +13 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change.fr.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.en.html.slim.tt +9 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.en.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.fr.html.slim.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_change_code.fr.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.en.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.en.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.fr.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/email_confirmation.fr.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.en.html.slim.tt +10 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.en.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.fr.html.slim.tt +13 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/password_reset.fr.text.erb.tt +8 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.en.html.slim.tt +9 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.en.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.fr.html.slim.tt +9 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_code.fr.text.erb.tt +11 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.en.html.slim.tt +23 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.en.text.erb.tt +14 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.fr.html.slim.tt +24 -0
- data/lib/generators/trek/templates/public_accounts/views/mailer/sign_in_locked.fr.text.erb.tt +14 -0
- data/lib/generators/trek/templates/public_accounts/web/authentication.rb.tt +97 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/accounts_controller.rb.tt +33 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/active_sessions_controller.rb.tt +15 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/base_controller.rb.tt +52 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/email_changes_controller.rb.tt +85 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/email_confirmations_controller.rb.tt +19 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/password_resets_controller.rb.tt +41 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/passwords_controller.rb.tt +23 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/registrations_controller.rb.tt +24 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/sessions_controller.rb.tt +85 -0
- data/lib/generators/trek/templates/public_accounts/web/controllers/sign_in_codes_controller.rb.tt +32 -0
- data/lib/generators/trek/templates/public_accounts/web/views/_flash.html.slim.tt +5 -0
- data/lib/generators/trek/templates/public_accounts/web/views/accounts/show.html.slim.tt +52 -0
- data/lib/generators/trek/templates/public_accounts/web/views/email_changes/edit.html.slim.tt +17 -0
- data/lib/generators/trek/templates/public_accounts/web/views/email_changes/new.html.slim.tt +15 -0
- data/lib/generators/trek/templates/public_accounts/web/views/password_resets/edit.html.slim.tt +29 -0
- data/lib/generators/trek/templates/public_accounts/web/views/password_resets/new.html.slim.tt +15 -0
- data/lib/generators/trek/templates/public_accounts/web/views/passwords/edit.html.slim.tt +28 -0
- data/lib/generators/trek/templates/public_accounts/web/views/registrations/new.html.slim.tt +30 -0
- data/lib/generators/trek/templates/public_accounts/web/views/sessions/new.html.slim.tt +40 -0
- data/lib/generators/trek/templates/public_accounts/web/views/sign_in_codes/new.html.slim.tt +17 -0
- data/lib/generators/trek/templates/spec/jobs/mail_delivery_job_spec.rb +11 -0
- data/lib/generators/trek/templates/spec/mailers/admin_mailer_spec.rb +10 -0
- data/lib/generators/trek/templates/spec/requests/admin/fragments_spec.rb +1 -1
- data/lib/generators/trek/templates/spec/requests/admin/good_job_spec.rb +34 -0
- data/lib/generators/trek/templates/spec/requests/admin/pages_spec.rb +12 -1
- data/lib/generators/trek/templates/spec/requests/admin/panels_spec.rb +16 -0
- data/lib/generators/trek/templates/spec/requests/admin/password_renewal_spec.rb +2 -2
- data/lib/generators/trek/templates/spec/requests/admin/security_checks_spec.rb +24 -0
- data/lib/generators/trek/templates/spec/requests/admin/sign_in_lockout_spec.rb +1 -1
- data/lib/generators/trek/templates/spec/requests/admin/sign_in_notices_spec.rb +33 -0
- data/lib/generators/trek/templates/spec/requests/admin/user_sessions_spec.rb +2 -2
- data/lib/generators/trek/templates/views/admin/pages/_form.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin/security_checks/show.html.slim +9 -0
- data/lib/generators/trek/templates/views/admin/user_password_resets/edit.html.slim +6 -1
- data/lib/generators/trek/templates/views/admin/user_sessions/new.html.slim +4 -1
- data/lib/generators/trek/templates/views/admin/users/index.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.en.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.en.text.erb +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.fr.html.slim +1 -1
- data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.fr.text.erb +1 -1
- data/lib/tasks/trek/attachments.rake +12 -0
- data/lib/tasks/trek/security.rake +10 -0
- data/lib/trek/csp_reports.rb +22 -4
- data/lib/trek/disposable_email_domains.rb +9 -20
- data/lib/trek/engine.rb +5 -0
- data/lib/trek/json_compatibility.rb +20 -0
- data/lib/trek/security_check.rb +241 -0
- data/lib/trek/stored_image_metadata.rb +88 -0
- data/lib/trek/typography_formatter.rb +35 -4
- data/lib/trek/version.rb +1 -1
- data/lib/trek.rb +2 -1
- data/package.json +16 -13
- data/postcss.config.js +0 -3
- data/trek.gemspec +6 -7
- data/vitest.config.mjs +24 -0
- data/yarn.lock +1667 -1010
- metadata +122 -33
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// The editor's view of a block edited in a panel (image, prompt): a button opening the panel with the
|
|
2
|
+
// block's attributes. Clicking it selects the block, so that the panel's response replaces it. Built with
|
|
3
|
+
// DOM nodes rather than HTML, so that the attributes, typed by authors, stay text.
|
|
4
|
+
export function blockView({
|
|
5
|
+
tag,
|
|
6
|
+
param,
|
|
7
|
+
actions,
|
|
8
|
+
attributes,
|
|
9
|
+
editor,
|
|
10
|
+
getPos,
|
|
11
|
+
render,
|
|
12
|
+
}) {
|
|
13
|
+
const dom = document.createElement(tag);
|
|
14
|
+
const button = document.createElement("button");
|
|
15
|
+
button.type = "button";
|
|
16
|
+
button.dataset.action = actions;
|
|
17
|
+
button.dataset.params = new URLSearchParams(
|
|
18
|
+
Object.entries(attributes).map(([name, value]) => [
|
|
19
|
+
`${param}[${name}]`,
|
|
20
|
+
value ?? "",
|
|
21
|
+
])
|
|
22
|
+
).toString();
|
|
23
|
+
// Before the Stimulus actions, which run on the same click and open the panel
|
|
24
|
+
button.addEventListener("click", () => {
|
|
25
|
+
const pos = getPos();
|
|
26
|
+
if (pos !== undefined) editor.commands.setNodeSelection(pos);
|
|
27
|
+
});
|
|
28
|
+
render(button);
|
|
29
|
+
dom.append(button);
|
|
30
|
+
return { dom };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function element(tag, properties = {}, ...children) {
|
|
34
|
+
const node = document.createElement(tag);
|
|
35
|
+
Object.entries(properties).forEach(([name, value]) => {
|
|
36
|
+
if (value !== null && value !== undefined) node.setAttribute(name, value);
|
|
37
|
+
});
|
|
38
|
+
node.append(...children);
|
|
39
|
+
return node;
|
|
40
|
+
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { Node, mergeAttributes } from "@tiptap/core";
|
|
2
|
-
|
|
3
|
-
function attributesToParams(attributes) {
|
|
4
|
-
const params = Object.fromEntries(
|
|
5
|
-
Object.entries(attributes).map(([k, v]) => [`image[${k}]`, v])
|
|
6
|
-
);
|
|
7
|
-
return new URLSearchParams(params).toString();
|
|
8
|
-
}
|
|
2
|
+
import { blockView, element } from "./block_view.js";
|
|
9
3
|
|
|
10
4
|
export default Node.create({
|
|
11
5
|
name: "imageBlock",
|
|
@@ -48,24 +42,32 @@ export default Node.create({
|
|
|
48
42
|
},
|
|
49
43
|
|
|
50
44
|
addNodeView() {
|
|
51
|
-
return ({ node }) =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
45
|
+
return ({ node, editor, getPos }) =>
|
|
46
|
+
blockView({
|
|
47
|
+
tag: "image-block",
|
|
48
|
+
param: "image",
|
|
49
|
+
actions:
|
|
50
|
+
"trek--form--content-editor#toggleImage trek--layout#openPanel",
|
|
51
|
+
attributes: node.attrs,
|
|
52
|
+
editor,
|
|
53
|
+
getPos,
|
|
54
|
+
render: (button) => {
|
|
55
|
+
button.append(
|
|
56
|
+
element(
|
|
57
|
+
"span",
|
|
58
|
+
{
|
|
59
|
+
class: "c-trek--form--content-editor-content-image",
|
|
60
|
+
"data-size": node.attrs.size,
|
|
61
|
+
},
|
|
62
|
+
element("img", {
|
|
63
|
+
src: node.attrs.file_url,
|
|
64
|
+
alt: node.attrs.alt ?? "",
|
|
65
|
+
})
|
|
66
|
+
)
|
|
67
|
+
);
|
|
68
|
+
if (node.attrs.text)
|
|
69
|
+
button.append(element("span", {}, node.attrs.text));
|
|
70
|
+
},
|
|
71
|
+
});
|
|
70
72
|
},
|
|
71
73
|
});
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { Node, mergeAttributes } from "@tiptap/core";
|
|
2
|
-
|
|
3
|
-
function attributesToParams(attributes) {
|
|
4
|
-
const params = Object.fromEntries(
|
|
5
|
-
Object.entries(attributes).map(([k, v]) => [`prompt[${k}]`, v])
|
|
6
|
-
);
|
|
7
|
-
return new URLSearchParams(params).toString();
|
|
8
|
-
}
|
|
2
|
+
import { blockView } from "./block_view.js";
|
|
9
3
|
|
|
10
4
|
export default Node.create({
|
|
11
5
|
name: "promptsBlock",
|
|
@@ -14,9 +8,6 @@ export default Node.create({
|
|
|
14
8
|
|
|
15
9
|
addAttributes() {
|
|
16
10
|
return {
|
|
17
|
-
color: {
|
|
18
|
-
default: null,
|
|
19
|
-
},
|
|
20
11
|
href: {
|
|
21
12
|
default: null,
|
|
22
13
|
},
|
|
@@ -45,21 +36,19 @@ export default Node.create({
|
|
|
45
36
|
},
|
|
46
37
|
|
|
47
38
|
addNodeView() {
|
|
48
|
-
return ({ node }) =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
node.attrs
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
};
|
|
39
|
+
return ({ node, editor, getPos }) =>
|
|
40
|
+
blockView({
|
|
41
|
+
tag: "prompts-block",
|
|
42
|
+
param: "prompt",
|
|
43
|
+
actions:
|
|
44
|
+
"trek--form--content-editor#togglePrompts trek--layout#openPanel",
|
|
45
|
+
attributes: node.attrs,
|
|
46
|
+
editor,
|
|
47
|
+
getPos,
|
|
48
|
+
render: (button) => {
|
|
49
|
+
button.title = node.attrs.title || "";
|
|
50
|
+
button.textContent = node.attrs.text;
|
|
51
|
+
},
|
|
52
|
+
});
|
|
64
53
|
},
|
|
65
54
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Extension } from "@tiptap/core";
|
|
2
|
-
import { Plugin, PluginKey } from "
|
|
2
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
3
|
import slugify from "slugify";
|
|
4
4
|
|
|
5
5
|
const isTargetNodeOfType = (node, type) => node.type === type;
|
|
@@ -19,13 +19,11 @@ export const TableOfContents = Extension.create({
|
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
21
|
renderHTML: (attributes) => {
|
|
22
|
-
console.log("renderHTML", attributes);
|
|
23
22
|
return {
|
|
24
23
|
id: attributes.id,
|
|
25
24
|
};
|
|
26
25
|
},
|
|
27
26
|
parseHTML: (element) => {
|
|
28
|
-
console.log("parseHTML", element);
|
|
29
27
|
return element.id;
|
|
30
28
|
},
|
|
31
29
|
},
|
|
@@ -35,6 +35,21 @@ module Trek
|
|
|
35
35
|
)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
# A toolbar button running a Tiptap command (`editor.chain().focus()[command]({ level })`), marked
|
|
39
|
+
# active when the selection has `active`, e.g. "bold", or "heading" with the button's level
|
|
40
|
+
def command_data(command, active: nil, level: nil)
|
|
41
|
+
{
|
|
42
|
+
action: stimulus_action("run"),
|
|
43
|
+
"#{identifier}-command-param": command,
|
|
44
|
+
"#{identifier}-level-param": level
|
|
45
|
+
}.compact.merge(active ? state_data(active) : {})
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# A button marked active when the selection has `name` (Tiptap's `isActive`)
|
|
49
|
+
def state_data(name)
|
|
50
|
+
{ stimulus_target_key => "stateButton", "state-name": name }
|
|
51
|
+
end
|
|
52
|
+
|
|
38
53
|
def content_data_attributes
|
|
39
54
|
{
|
|
40
55
|
action: stimulus_action("click", "focus")
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
width: 25rem;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
.
|
|
23
|
+
.original,
|
|
24
24
|
.preview img {
|
|
25
25
|
display: block;
|
|
26
26
|
height: 100%;
|
|
@@ -31,6 +31,45 @@
|
|
|
31
31
|
object-fit: contain;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/* The links to the original, opening and downloading it: icons over a darkened image, on hover and focus */
|
|
35
|
+
.original {
|
|
36
|
+
position: relative;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.original-actions {
|
|
40
|
+
--icon-size: 2rem;
|
|
41
|
+
|
|
42
|
+
align-items: center;
|
|
43
|
+
background-color: rgb(0 0 0 / 45%);
|
|
44
|
+
display: flex;
|
|
45
|
+
gap: 0.8rem;
|
|
46
|
+
inset: 0;
|
|
47
|
+
justify-content: center;
|
|
48
|
+
opacity: 0;
|
|
49
|
+
position: absolute;
|
|
50
|
+
transition: opacity 0.15s ease-in-out;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.original:hover .original-actions,
|
|
54
|
+
.original:focus-within .original-actions {
|
|
55
|
+
opacity: 1;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.original-action {
|
|
59
|
+
align-items: center;
|
|
60
|
+
border-radius: 0.4rem;
|
|
61
|
+
color: white;
|
|
62
|
+
display: flex;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
padding: 0.8rem;
|
|
65
|
+
transition: background-color 0.15s ease-in-out;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.original-action:hover,
|
|
69
|
+
.original-action:focus-visible {
|
|
70
|
+
background-color: rgb(255 255 255 / 20%);
|
|
71
|
+
}
|
|
72
|
+
|
|
34
73
|
.actions {
|
|
35
74
|
align-items: flex-start;
|
|
36
75
|
display: flex;
|
|
@@ -31,12 +31,3 @@
|
|
|
31
31
|
size: :narrow,
|
|
32
32
|
data: remove_button_data_attributes,
|
|
33
33
|
)
|
|
34
|
-
/ The uploaded file itself, the preview being a thumbnail
|
|
35
|
-
= render Trek::ButtonComponent.new( \
|
|
36
|
-
text: t("admin.actions.see_original"),
|
|
37
|
-
size: :narrow,
|
|
38
|
-
href: image.url,
|
|
39
|
-
target: "_blank",
|
|
40
|
-
rel: "noopener",
|
|
41
|
-
) do |button|
|
|
42
|
-
- button.with_icon("trek/external")
|
|
@@ -5,7 +5,6 @@ import Uppy from "@uppy/core";
|
|
|
5
5
|
import ThumbnailGenerator from "@uppy/thumbnail-generator";
|
|
6
6
|
import XHRUpload from "@uppy/xhr-upload";
|
|
7
7
|
import French from "@uppy/locales/lib/fr_FR";
|
|
8
|
-
import "@uppy/core/dist/style.css";
|
|
9
8
|
|
|
10
9
|
export class Controller extends BaseController {
|
|
11
10
|
static targets = [
|
|
@@ -69,7 +68,7 @@ export class Controller extends BaseController {
|
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
disconnect() {
|
|
72
|
-
this.uppy.
|
|
71
|
+
this.uppy.destroy();
|
|
73
72
|
this.uppy = null;
|
|
74
73
|
}
|
|
75
74
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "content_disposition"
|
|
4
|
+
|
|
3
5
|
module Trek
|
|
4
6
|
module Form
|
|
5
7
|
class ImageFieldComponent < ViewComponent::Form::FileFieldComponent
|
|
@@ -16,16 +18,29 @@ module Trek
|
|
|
16
18
|
|
|
17
19
|
private
|
|
18
20
|
|
|
21
|
+
# The thumbnail, with links opening the uploaded file in a new tab and downloading it. A file just picked,
|
|
22
|
+
# not yet saved, has no URL: the JS replaces the preview with its own thumbnail.
|
|
19
23
|
def preview
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
return render(Trek::IconComponent.new("trek/pic")) unless image&.exists?
|
|
25
|
+
|
|
26
|
+
tag.div(class: class_for("original")) do
|
|
27
|
+
safe_join([
|
|
28
|
+
image_tag(image_url, loading: "lazy", alt: ""),
|
|
29
|
+
tag.div(class: class_for("original-actions")) do
|
|
30
|
+
safe_join([
|
|
31
|
+
original_link(image.url, "trek/external", t("admin.actions.see_original"),
|
|
32
|
+
target: "_blank", rel: "noopener"),
|
|
33
|
+
original_link(download_url, "trek/download", t("admin.actions.download_original"),
|
|
34
|
+
download: image.original_filename.to_s)
|
|
35
|
+
])
|
|
36
|
+
end
|
|
37
|
+
])
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def original_link(url, icon, label, **options)
|
|
42
|
+
link_to url, class: class_for("original-action"), title: label, "aria-label": label, **options do
|
|
43
|
+
render Trek::IconComponent.new(icon, aria_hidden: true)
|
|
29
44
|
end
|
|
30
45
|
end
|
|
31
46
|
|
|
@@ -33,6 +48,18 @@ module Trek
|
|
|
33
48
|
Trek::ThumbnailHelper.thumbnail_url(image, 300, 150)
|
|
34
49
|
end
|
|
35
50
|
|
|
51
|
+
# The `download` attribute only applies to a file on the admin's own host. On S3, the file is served from
|
|
52
|
+
# the bucket's host, so it's a URL signed to answer as an attachment: signed for the bucket itself, without
|
|
53
|
+
# the `url_options` host (a CDN's), and valid for a day, as the page may stay open a while.
|
|
54
|
+
def download_url
|
|
55
|
+
image.url(
|
|
56
|
+
public: false,
|
|
57
|
+
host: nil,
|
|
58
|
+
expires_in: 1.day.to_i,
|
|
59
|
+
response_content_disposition: ContentDisposition.attachment(image.original_filename)
|
|
60
|
+
)
|
|
61
|
+
end
|
|
62
|
+
|
|
36
63
|
def image
|
|
37
64
|
object.public_send(:"#{method_name}")
|
|
38
65
|
end
|
|
@@ -23,9 +23,11 @@
|
|
|
23
23
|
transition: background-color 0.15s ease-out;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/* Room for the longest label, and its line before one is typed: the field doesn't move when it appears */
|
|
26
27
|
.label {
|
|
27
28
|
color: var(--slate-11);
|
|
28
29
|
font-size: 0.8em;
|
|
30
|
+
min-height: 1lh;
|
|
29
31
|
min-width: 8ch;
|
|
30
32
|
text-align: right;
|
|
31
33
|
}
|
|
@@ -5,7 +5,6 @@ import Uppy from "@uppy/core";
|
|
|
5
5
|
import ThumbnailGenerator from "@uppy/thumbnail-generator";
|
|
6
6
|
import XHRUpload from "@uppy/xhr-upload";
|
|
7
7
|
import French from "@uppy/locales/lib/fr_FR";
|
|
8
|
-
import "@uppy/core/dist/style.css";
|
|
9
8
|
|
|
10
9
|
export class Controller extends BaseController {
|
|
11
10
|
static targets = ["fileInput", "hiddenInput"];
|
|
@@ -48,7 +47,7 @@ export class Controller extends BaseController {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
disconnect() {
|
|
51
|
-
this.uppy.
|
|
50
|
+
this.uppy.destroy();
|
|
52
51
|
this.uppy = null;
|
|
53
52
|
}
|
|
54
53
|
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/* Use component-local class names and add them to HTML via #class_for(name) helper */
|
|
2
|
+
|
|
3
|
+
.root {
|
|
4
|
+
list-style: none;
|
|
5
|
+
margin: 0;
|
|
6
|
+
max-width: 96rem;
|
|
7
|
+
padding: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.result {
|
|
11
|
+
align-items: baseline;
|
|
12
|
+
border-top: 1px solid var(--slate-6);
|
|
13
|
+
display: flex;
|
|
14
|
+
gap: 1.2rem;
|
|
15
|
+
line-height: 1.4;
|
|
16
|
+
padding: 1.2rem 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.status {
|
|
20
|
+
align-self: center;
|
|
21
|
+
color: var(--slate-9);
|
|
22
|
+
display: flex;
|
|
23
|
+
flex: none;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
width: 2rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.icon {
|
|
29
|
+
height: 1.8rem;
|
|
30
|
+
width: 1.8rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.dot {
|
|
34
|
+
background-color: currentcolor;
|
|
35
|
+
border-radius: 50%;
|
|
36
|
+
height: 0.6rem;
|
|
37
|
+
width: 0.6rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.message {
|
|
41
|
+
color: var(--slate-12);
|
|
42
|
+
flex: 1;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.message code {
|
|
46
|
+
background-color: var(--slate-3);
|
|
47
|
+
border-radius: 0.3rem;
|
|
48
|
+
font-family: monospace;
|
|
49
|
+
font-size: 0.9em;
|
|
50
|
+
padding: 0.1rem 0.4rem;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.docs {
|
|
54
|
+
color: var(--slate-11);
|
|
55
|
+
font-size: 0.9em;
|
|
56
|
+
white-space: nowrap;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.result[data-status="ok"] .status {
|
|
60
|
+
color: var(--grass-11);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.result[data-status="warning"] .status {
|
|
64
|
+
color: var(--amber-11);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.result[data-status="failure"] .status {
|
|
68
|
+
color: var(--tomato-11);
|
|
69
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
ul(class=root_class)
|
|
2
|
+
- results.each do |result|
|
|
3
|
+
li(class=class_for("result") data-status=result.status)
|
|
4
|
+
span(class=class_for("status"))
|
|
5
|
+
- if (icon = ICONS[result.status])
|
|
6
|
+
= render Trek::IconComponent.new( \
|
|
7
|
+
icon,
|
|
8
|
+
classnames: class_for("icon"),
|
|
9
|
+
title: t(".statuses.#{result.status}"),
|
|
10
|
+
)
|
|
11
|
+
- else
|
|
12
|
+
span(class=class_for("dot") role="img" aria-label=t(".statuses.info"))
|
|
13
|
+
span(class=class_for("message"))
|
|
14
|
+
= formatted(result.message)
|
|
15
|
+
= link_to t(".docs"),
|
|
16
|
+
result.docs,
|
|
17
|
+
class: class_for("docs"),
|
|
18
|
+
target: "_blank",
|
|
19
|
+
rel: "noopener"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "./security_check_component.css";
|
|
2
|
+
|
|
3
|
+
// Add a Stimulus controller for this component.
|
|
4
|
+
// It will automatically registered and its name will be available
|
|
5
|
+
// via #component_name in the component class.
|
|
6
|
+
//
|
|
7
|
+
// import { Controller as BaseController } from "@hotwired/stimulus";
|
|
8
|
+
//
|
|
9
|
+
// export class Controller extends BaseController {
|
|
10
|
+
// connect() {
|
|
11
|
+
// }
|
|
12
|
+
//
|
|
13
|
+
// disconnect() {
|
|
14
|
+
// }
|
|
15
|
+
// }
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Trek
|
|
4
|
+
# The results of Trek::SecurityCheck, each with its status and a link to the docs explaining it
|
|
5
|
+
#
|
|
6
|
+
# = render Trek::SecurityCheckComponent.new(results: Trek::SecurityCheck.new(request:).results)
|
|
7
|
+
class SecurityCheckComponent < Trek::Component
|
|
8
|
+
# An info has no icon: a dot, as it calls for nothing
|
|
9
|
+
ICONS = { ok: "trek/check", warning: "trek/danger", failure: "trek/close" }.freeze
|
|
10
|
+
|
|
11
|
+
option :results
|
|
12
|
+
|
|
13
|
+
# The message, with the code it names between backticks (`ADMIN_ALLOWED_IPS`, a class…) in <code>.
|
|
14
|
+
# Escaped part by part: it holds the IP addresses of the request's headers.
|
|
15
|
+
def formatted(message)
|
|
16
|
+
safe_join(message.split(/`([^`]+)`/).each_with_index.map { |part, index| index.odd? ? tag.code(part) : part })
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Trek
|
|
2
|
+
module Content
|
|
3
|
+
# Removes from a document what rendering skips (Paragraph, ListItem, BulletList, OrderedList): empty
|
|
4
|
+
# paragraphs, empty list items, and lists left without items. Trek::Contentable calls it before saving.
|
|
5
|
+
#
|
|
6
|
+
# The document stays one the editor can open, without the schema adding anything back: an empty
|
|
7
|
+
# document keeps one paragraph, a list item keeps its first paragraph, which it needs before a nested
|
|
8
|
+
# list, and a node left with only empty paragraphs, like a quote, is kept as it was. Whatever the schema
|
|
9
|
+
# doesn't know, node types or attributes of other Tiptap extensions, is kept.
|
|
10
|
+
class Cleaner
|
|
11
|
+
LISTS = %i[bullet_list ordered_list].freeze
|
|
12
|
+
|
|
13
|
+
# A Prosemirror::Document, cleaned
|
|
14
|
+
def call(document)
|
|
15
|
+
root = document.root
|
|
16
|
+
content = clean_content(root.content)
|
|
17
|
+
content = [Prosemirror::Node.new(type: :paragraph)] if content.empty?
|
|
18
|
+
Prosemirror::Document.new(content == root.content ? root : root.with(content:), schema: document.schema)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def clean_content(nodes)
|
|
24
|
+
nodes.filter_map { |node| clean(node) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# The node, cleaned, or nil to remove it
|
|
28
|
+
def clean(node)
|
|
29
|
+
return if empty_paragraph?(node)
|
|
30
|
+
return node if node.text? || node.content.empty?
|
|
31
|
+
return clean_list_item(node) if node.type == :list_item
|
|
32
|
+
|
|
33
|
+
content = clean_content(node.content)
|
|
34
|
+
return content.presence && node.with(content:) if LISTS.include?(node.type)
|
|
35
|
+
return node if content.empty? || content == node.content
|
|
36
|
+
|
|
37
|
+
node.with(content:)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def clean_list_item(item)
|
|
41
|
+
return if ListItem.empty?(item)
|
|
42
|
+
|
|
43
|
+
first, *rest = item.content
|
|
44
|
+
content = [empty_paragraph?(first) ? first : clean(first), *clean_content(rest)]
|
|
45
|
+
content == item.content ? item : item.with(content:)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def empty_paragraph?(node)
|
|
49
|
+
node.type == :paragraph && Paragraph.empty?(node)
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -3,7 +3,7 @@ module Trek
|
|
|
3
3
|
# Empty list items, with no content or only empty paragraphs, render nothing, like empty paragraphs.
|
|
4
4
|
class ListItem < Prosemirror::Nodes::ListItem
|
|
5
5
|
def self.empty?(node)
|
|
6
|
-
node.content.all? { |child| child.type == :paragraph &&
|
|
6
|
+
node.content.all? { |child| child.type == :paragraph && Paragraph.empty?(child) }
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
# Whether a list has no item to render: only empty items, and whitespace.
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
module Trek
|
|
2
2
|
module Content
|
|
3
|
-
# Empty paragraphs, often left by the editor, render nothing
|
|
3
|
+
# Empty paragraphs, often left by the editor, render nothing: with no content, or only line breaks
|
|
4
|
+
# (Shift+Enter), which would show as a blank space.
|
|
4
5
|
class Paragraph < Prosemirror::Nodes::Paragraph
|
|
6
|
+
def self.empty?(node)
|
|
7
|
+
node.content.all? { |child| child.type == :hard_break }
|
|
8
|
+
end
|
|
9
|
+
|
|
5
10
|
def view_template(&)
|
|
6
|
-
p(&) unless
|
|
11
|
+
p(&) unless self.class.empty?(node)
|
|
7
12
|
end
|
|
8
13
|
end
|
|
9
14
|
end
|
|
@@ -9,13 +9,12 @@ module Trek
|
|
|
9
9
|
prop :href, _String?
|
|
10
10
|
prop :target, _String?
|
|
11
11
|
prop :title, _String?
|
|
12
|
-
prop :color, _String?(/\A[\w-]+\z/)
|
|
13
12
|
|
|
14
13
|
def view_template
|
|
15
14
|
href = @href.present? && safe_url(@href)
|
|
16
15
|
return if !href || @text.blank?
|
|
17
16
|
|
|
18
|
-
a(href:, target: @target, title: @title
|
|
17
|
+
a(href:, target: @target, title: @title) { @text }
|
|
19
18
|
end
|
|
20
19
|
end
|
|
21
20
|
end
|
data/app/content/trek/content.rb
CHANGED
|
@@ -20,6 +20,12 @@ module Trek
|
|
|
20
20
|
@default_schema = nil
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
# The content without what rendering skips (see Cleaner), as a Hash. Problems with the content are
|
|
24
|
+
# reported when it's rendered, not when it's cleaned.
|
|
25
|
+
def clean(json)
|
|
26
|
+
Cleaner.new.call(schema.with_options(on_invalid: nil).parse(json)).to_h
|
|
27
|
+
end
|
|
28
|
+
|
|
23
29
|
def default_schema
|
|
24
30
|
Prosemirror::Schema.tiptap(
|
|
25
31
|
case: :camel,
|
|
@@ -6,7 +6,7 @@ module Trek
|
|
|
6
6
|
# status, or the class of the error raised).
|
|
7
7
|
#
|
|
8
8
|
# Only mutations are recorded: GET and HEAD are skipped, unless a controller sets
|
|
9
|
-
# `self.audit_reads = true`. A read on sensitive data can be logged explicitly with `audit!`.
|
|
9
|
+
# `self.audit_reads = true`, and so are the actions of `audit_read_actions`. A read on sensitive data can be logged explicitly with `audit!`.
|
|
10
10
|
#
|
|
11
11
|
# Auditing never breaks the request: a failed write is reported through `Rails.error`.
|
|
12
12
|
# FEATURE_AUDIT_LOG=false switches it off, read on each request.
|
|
@@ -15,6 +15,9 @@ module Trek
|
|
|
15
15
|
|
|
16
16
|
included do
|
|
17
17
|
class_attribute :audit_reads, default: false
|
|
18
|
+
# Actions that only read although they're not a GET, e.g. hotwire_combobox's `chips`, which a
|
|
19
|
+
# multiselect requests with a POST: skipped as reads are.
|
|
20
|
+
class_attribute :audit_read_actions, default: []
|
|
18
21
|
# The parameters whose values are recorded, at any depth; the others are recorded by name only,
|
|
19
22
|
# so the log doesn't copy the data the forms send. `config.filter_parameters` still applies.
|
|
20
23
|
class_attribute :audit_param_values, default: %w[id role]
|
|
@@ -49,7 +52,7 @@ module Trek
|
|
|
49
52
|
|
|
50
53
|
# Rails answers `get?` with false for a HEAD, which uptime monitors use.
|
|
51
54
|
def read_only_request?
|
|
52
|
-
request.get? || request.head?
|
|
55
|
+
request.get? || request.head? || audit_read_actions.map(&:to_s).include?(action_name)
|
|
53
56
|
end
|
|
54
57
|
|
|
55
58
|
def write_audit_log(action: action_name, target: audit_target, status: nil, error: nil)
|