trek 2.3.2 → 2.5.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.
Files changed (221) hide show
  1. checksums.yaml +4 -4
  2. data/.node-version +1 -1
  3. data/.yarn/releases/yarn-4.18.1.cjs +1000 -0
  4. data/.yarnrc.yml +3 -5
  5. data/AGENTS.md +12 -8
  6. data/CHANGELOG.md +73 -0
  7. data/Gemfile.lock +226 -171
  8. data/Makefile +38 -1
  9. data/README.md +2 -2
  10. data/app/assets/icons/trek/passkey.svg +5 -0
  11. data/app/assets/stylesheets/trek/base.css +6 -0
  12. data/app/components/trek/entries/item_component/item_component.css +6 -0
  13. data/app/components/trek/form/image_field_component/image_field_component.html.slim +9 -0
  14. data/app/components/trek/form/image_field_component.rb +1 -5
  15. data/app/components/trek/form/password_strength_component/password_strength_component.css +56 -0
  16. data/app/components/trek/form/password_strength_component/password_strength_component.html.slim +8 -0
  17. data/app/components/trek/form/password_strength_component/password_strength_component.js +74 -0
  18. data/app/components/trek/form/password_strength_component.rb +29 -0
  19. data/app/components/trek/gate_component/gate_component.css +7 -0
  20. data/app/components/trek/icon/sprite_component.rb +3 -2
  21. data/app/components/trek/list/item_component.rb +1 -1
  22. data/app/components/trek/list/tree/item_component.rb +2 -2
  23. data/app/components/trek/search_component/search_component.html.slim +2 -1
  24. data/app/components/trek/search_component.rb +9 -1
  25. data/app/components/trek/section_component/section_component.css +22 -0
  26. data/app/components/trek/section_component/section_component.html.slim +5 -0
  27. data/app/components/trek/section_component/section_component.js +1 -0
  28. data/app/components/trek/section_component.rb +14 -0
  29. data/app/content/trek/content/bullet_list.rb +10 -0
  30. data/app/content/trek/content/document.rb +33 -0
  31. data/app/content/trek/content/image_block.rb +52 -0
  32. data/app/content/trek/content/link_resolver.rb +33 -0
  33. data/app/content/trek/content/list_item.rb +19 -0
  34. data/app/content/trek/content/ordered_list.rb +10 -0
  35. data/app/content/trek/content/paragraph.rb +10 -0
  36. data/app/content/trek/content/prompts_block.rb +22 -0
  37. data/app/content/trek/content.rb +32 -0
  38. data/app/controllers/concerns/trek/auditable.rb +103 -0
  39. data/app/controllers/concerns/trek/filters.rb +2 -0
  40. data/app/controllers/concerns/trek/passkeys.rb +37 -0
  41. data/app/controllers/concerns/trek/reorderable.rb +14 -3
  42. data/app/controllers/trek/csp_reports_controller.rb +59 -0
  43. data/app/controllers/trek/panels/base_controller.rb +3 -0
  44. data/app/controllers/trek/panels/links_controller.rb +1 -1
  45. data/app/controllers/trek/panels/prompts_controller.rb +1 -1
  46. data/app/controllers/trek/resource_controller.rb +7 -1
  47. data/app/helpers/trek/audit_logs_helper.rb +21 -0
  48. data/app/helpers/trek/thumbnail_helper.rb +11 -0
  49. data/app/helpers/trek/user_agents_helper.rb +36 -0
  50. data/app/javascript/controllers/index.js +3 -0
  51. data/app/javascript/controllers/passkey_controller.js +118 -0
  52. data/app/javascript/trek.js +4 -0
  53. data/app/jobs/trek/audit_log/purge_job.rb +18 -0
  54. data/app/jobs/trek/purge_expired_sessions_job.rb +14 -0
  55. data/app/jobs/trek/resolve_session_hostname_job.rb +17 -0
  56. data/app/models/concerns/trek/audit_log.rb +30 -0
  57. data/app/models/concerns/trek/contentable.rb +9 -14
  58. data/app/models/concerns/trek/pageable.rb +10 -1
  59. data/app/models/concerns/trek/users/passkeys.rb +75 -0
  60. data/app/models/concerns/trek/users/password_history.rb +51 -0
  61. data/app/models/concerns/trek/users/password_policy.rb +85 -0
  62. data/app/models/concerns/trek/users/password_renewal.rb +51 -0
  63. data/app/models/concerns/trek/users/session_lifetime.rb +39 -0
  64. data/app/models/concerns/trek/users/sign_in_lockout.rb +67 -0
  65. data/app/models/concerns/trek/users/sign_ins.rb +31 -0
  66. data/app/models/concerns/trek/users/validations.rb +3 -2
  67. data/app/models/trek/feature.rb +6 -0
  68. data/app/models/trek/pwned_passwords.rb +40 -0
  69. data/app/models/trek/user_session.rb +10 -0
  70. data/app/policies/trek/audit_log_policy.rb +34 -0
  71. data/app/policies/trek/user_policy.rb +5 -0
  72. data/app/validators/not_disposable_validator.rb +18 -0
  73. data/app/views/trek/panels/images/_form.html.slim +1 -1
  74. data/app/views/trek/panels/images/create.turbo_stream.slim +1 -1
  75. data/app/views/trek/panels/links/_form.html.slim +1 -1
  76. data/app/views/trek/panels/prompts/_form.html.slim +1 -1
  77. data/config/brakeman.ignore +22 -0
  78. data/config/i18n-tasks.yml +7 -0
  79. data/config/locales/trek.en.yml +167 -39
  80. data/config/locales/trek.fr.yml +168 -40
  81. data/docs/.vitepress/config.mjs +8 -3
  82. data/docs/deploy.md +2 -0
  83. data/docs/getting-started.md +3 -3
  84. data/docs/proxies.md +53 -0
  85. data/docs/reference/components.md +1 -0
  86. data/docs/reference/concerns/contentable.md +2 -1
  87. data/docs/reference/controllers.md +1 -1
  88. data/docs/reference/environment-variables.md +2 -0
  89. data/docs/reference/formatters.md +31 -8
  90. data/docs/reference/generators/admin-user.md +1 -1
  91. data/docs/reference/generators/audit-log.md +113 -0
  92. data/docs/reference/generators/install.md +12 -3
  93. data/docs/reference/generators/security-headers.md +109 -0
  94. data/docs/reference/index.md +3 -0
  95. data/docs/reference/models/fragment.md +1 -0
  96. data/docs/reference/models/tag.md +4 -2
  97. data/docs/reference/models/user.md +123 -3
  98. data/docs/reference/validators.md +94 -0
  99. data/docs/security.md +90 -0
  100. data/docs/what-is-trek.md +4 -4
  101. data/lefthook.yml +8 -0
  102. data/lib/generators/trek/helpers.rb +13 -5
  103. data/lib/generators/trek/install/admin/user_password_resets_generator.rb +5 -0
  104. data/lib/generators/trek/install/admin/user_sessions_generator.rb +5 -0
  105. data/lib/generators/trek/install/admin/users_generator.rb +23 -0
  106. data/lib/generators/trek/install/admin_generator.rb +8 -0
  107. data/lib/generators/trek/install/appsignal_generator.rb +1 -1
  108. data/lib/generators/trek/install/audit_log_generator.rb +56 -0
  109. data/lib/generators/trek/install/authentication_generator.rb +78 -4
  110. data/lib/generators/trek/install/authorization_generator.rb +1 -1
  111. data/lib/generators/trek/install/esbuild_generator.rb +1 -2
  112. data/lib/generators/trek/install/mailer_generator.rb +18 -0
  113. data/lib/generators/trek/install/model_specs_generator.rb +6 -4
  114. data/lib/generators/trek/install/postcss_generator.rb +1 -4
  115. data/lib/generators/trek/install/postmark_generator.rb +2 -2
  116. data/lib/generators/trek/install/security_headers_generator.rb +49 -0
  117. data/lib/generators/trek/install/specs_generator.rb +11 -0
  118. data/lib/generators/trek/install/user_generator.rb +1 -1
  119. data/lib/generators/trek/install/yarn_generator.rb +1 -1
  120. data/lib/generators/trek/install_generator.rb +62 -54
  121. data/lib/generators/trek/scaffold_generator.rb +13 -5
  122. data/lib/generators/trek/taxonomies_generator.rb +5 -0
  123. data/lib/generators/trek/templates/.gitlab-ci.yml +18 -2
  124. data/lib/generators/trek/templates/Makefile +1 -1
  125. data/lib/generators/trek/templates/controllers/admin/active_sessions_controller.rb +21 -0
  126. data/lib/generators/trek/templates/controllers/admin/audit_logs_controller.rb +30 -0
  127. data/lib/generators/trek/templates/controllers/admin/fragments_controller.rb +7 -0
  128. data/lib/generators/trek/templates/controllers/admin/panels/images_controller.rb +8 -0
  129. data/lib/generators/trek/templates/controllers/admin/panels/links_controller.rb +8 -0
  130. data/lib/generators/trek/templates/controllers/admin/panels/prompts_controller.rb +8 -0
  131. data/lib/generators/trek/templates/controllers/admin/passkey_sessions_controller.rb +41 -0
  132. data/lib/generators/trek/templates/controllers/admin/passkeys_controller.rb +37 -0
  133. data/lib/generators/trek/templates/controllers/admin/user_password_resets_controller.rb +4 -4
  134. data/lib/generators/trek/templates/controllers/admin/user_sessions_controller.rb +53 -4
  135. data/lib/generators/trek/templates/controllers/admin/users_controller.rb +20 -0
  136. data/lib/generators/trek/templates/controllers/concerns/trek/authentication.rb +58 -7
  137. data/lib/generators/trek/templates/helpers/application_helper.rb +0 -4
  138. data/lib/generators/trek/templates/initializers/audit_log.rb +11 -0
  139. data/lib/generators/trek/templates/initializers/content_security_policy.rb +49 -0
  140. data/lib/generators/trek/templates/initializers/permissions_policy.rb +19 -0
  141. data/lib/generators/trek/templates/jobs/admin/password_reset_job.rb +9 -0
  142. data/lib/generators/trek/templates/layouts/admin/auth.html.slim +0 -5
  143. data/lib/generators/trek/templates/layouts/admin.html.slim +0 -3
  144. data/lib/generators/trek/templates/mailers/admin/passwords_mailer.rb +1 -1
  145. data/lib/generators/trek/templates/mailers/admin_mailer.rb +28 -1
  146. data/lib/generators/trek/templates/migrations/audit_logs.rb.erb +27 -0
  147. data/lib/generators/trek/templates/migrations/tags.rb.erb +6 -1
  148. data/lib/generators/trek/templates/migrations/user_passkeys.rb.erb +24 -0
  149. data/lib/generators/trek/templates/migrations/user_password_renewal.rb.erb +8 -0
  150. data/lib/generators/trek/templates/migrations/user_previous_passwords.rb.erb +10 -0
  151. data/lib/generators/trek/templates/migrations/user_session_tracking.rb.erb +11 -0
  152. data/lib/generators/trek/templates/migrations/user_sign_in_lockout.rb.erb +7 -0
  153. data/lib/generators/trek/templates/migrations/user_sign_ins.rb.erb +13 -0
  154. data/lib/generators/trek/templates/models/audit_log.rb +3 -0
  155. data/lib/generators/trek/templates/models/fragment.rb +14 -0
  156. data/lib/generators/trek/templates/models/tag_category.rb +2 -1
  157. data/lib/generators/trek/templates/models/user/passkey.rb +17 -0
  158. data/lib/generators/trek/templates/models/user/previous_password.rb +4 -0
  159. data/lib/generators/trek/templates/models/user/session.rb +8 -0
  160. data/lib/generators/trek/templates/policies/audit_log.rb +4 -0
  161. data/lib/generators/trek/templates/spec/mailers/admin/passwords_mailer_spec.rb +16 -0
  162. data/lib/generators/trek/templates/spec/mailers/admin_mailer_spec.rb +51 -0
  163. data/lib/generators/trek/templates/spec/models/audit_log_spec.rb +43 -0
  164. data/lib/generators/trek/templates/spec/models/tag_spec.rb +52 -0
  165. data/lib/generators/trek/templates/spec/models/user/session_spec.rb +68 -0
  166. data/lib/generators/trek/templates/spec/models/user_spec.rb +142 -4
  167. data/lib/generators/trek/templates/spec/requests/admin/active_sessions_spec.rb +120 -0
  168. data/lib/generators/trek/templates/spec/requests/admin/audit_logs_spec.rb +149 -0
  169. data/lib/generators/trek/templates/spec/requests/admin/fragments_spec.rb +26 -2
  170. data/lib/generators/trek/templates/spec/requests/admin/pages_spec.rb +8 -0
  171. data/lib/generators/trek/templates/spec/requests/admin/panels_spec.rb +54 -0
  172. data/lib/generators/trek/templates/spec/requests/admin/passkey_sessions_spec.rb +103 -0
  173. data/lib/generators/trek/templates/spec/requests/admin/passkeys_spec.rb +104 -0
  174. data/lib/generators/trek/templates/spec/requests/admin/password_renewal_spec.rb +83 -0
  175. data/lib/generators/trek/templates/spec/requests/admin/sign_in_lockout_spec.rb +95 -0
  176. data/lib/generators/trek/templates/spec/requests/admin/sign_in_notices_spec.rb +95 -0
  177. data/lib/generators/trek/templates/spec/requests/admin/user_password_resets_spec.rb +43 -6
  178. data/lib/generators/trek/templates/spec/requests/admin/user_sessions_spec.rb +25 -2
  179. data/lib/generators/trek/templates/views/admin/audit_logs/index.html.slim +35 -0
  180. data/lib/generators/trek/templates/views/admin/audit_logs/show.html.slim +50 -0
  181. data/lib/generators/trek/templates/views/admin/fragments/index.html.slim +14 -3
  182. data/lib/generators/trek/templates/views/admin/user_password_resets/edit.html.slim +16 -6
  183. data/lib/generators/trek/templates/views/admin/user_password_resets/new.html.slim +2 -1
  184. data/lib/generators/trek/templates/views/admin/user_sessions/new.html.slim +27 -1
  185. data/lib/generators/trek/templates/views/admin/users/_passkeys.html.slim +67 -0
  186. data/lib/generators/trek/templates/views/admin/users/_properties.html.slim +21 -0
  187. data/lib/generators/trek/templates/views/admin/users/_sessions.html.slim +70 -0
  188. data/lib/generators/trek/templates/views/admin/users/index.html.slim +13 -0
  189. data/lib/generators/trek/templates/views/admin/users/show.html.slim +10 -21
  190. data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.en.html.slim +22 -0
  191. data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.en.text.erb +16 -0
  192. data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.fr.html.slim +22 -0
  193. data/lib/generators/trek/templates/views/admin_mailer/new_sign_in.fr.text.erb +16 -0
  194. data/lib/generators/trek/templates/views/admin_mailer/sign_in_locked.en.html.slim +17 -0
  195. data/lib/generators/trek/templates/views/admin_mailer/sign_in_locked.en.text.erb +10 -0
  196. data/lib/generators/trek/templates/views/admin_mailer/sign_in_locked.fr.html.slim +18 -0
  197. data/lib/generators/trek/templates/views/admin_mailer/sign_in_locked.fr.text.erb +10 -0
  198. data/lib/trek/admin_ip_allowlist.rb +52 -0
  199. data/lib/trek/csp_reports.rb +99 -0
  200. data/lib/trek/data/common_passwords.txt +857 -0
  201. data/lib/trek/data/passkey_providers.json +404 -0
  202. data/lib/trek/disposable_email_domains.rb +53 -0
  203. data/lib/trek/engine.rb +18 -1
  204. data/lib/trek/passkey_providers.rb +19 -0
  205. data/lib/trek/reverse_dns.rb +27 -0
  206. data/lib/trek/saved_attachments_reload.rb +2 -1
  207. data/lib/trek/version.rb +1 -1
  208. data/lib/trek.rb +14 -1
  209. data/package.json +3 -5
  210. data/renovate.json +12 -1
  211. data/trek.gemspec +6 -3
  212. data/yarn.lock +2273 -2573
  213. metadata +160 -17
  214. data/.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs +0 -541
  215. data/.yarn/releases/yarn-3.8.0.cjs +0 -875
  216. data/app/formatters/prosemirror_to_html/global_id_to_links_formatter.rb +0 -19
  217. data/app/formatters/prosemirror_to_html/nodes/image_block.rb +0 -44
  218. data/app/formatters/prosemirror_to_html/nodes/prompts_block.rb +0 -28
  219. data/app/formatters/prosemirror_to_html/remove_empty_paragraphs_formatter.rb +0 -11
  220. data/app/models/prosemirror.rb +0 -23
  221. data/lib/generators/trek/templates/models/user_session.rb +0 -3
data/.yarnrc.yml CHANGED
@@ -1,7 +1,5 @@
1
- nodeLinker: node-modules
1
+ enableGlobalCache: false
2
2
 
3
- plugins:
4
- - path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
5
- spec: "@yarnpkg/plugin-interactive-tools"
3
+ nodeLinker: node-modules
6
4
 
7
- yarnPath: .yarn/releases/yarn-3.8.0.cjs
5
+ yarnPath: .yarn/releases/yarn-4.18.1.cjs
data/AGENTS.md CHANGED
@@ -8,8 +8,8 @@ Trek is a customizable CMS for Ruby on Rails, shipped as a **Ruby gem** (`trek`)
8
8
 
9
9
  ## Tech stack
10
10
 
11
- - **Ruby** `>= 3.1` (RuboCop targets 3.4) · **Rails** `>= 6.0, < 8.2` (lockfile 8.1.3; host apps need 7.0+)
12
- - **Node** 22.21.1 (`.node-version`) · **Yarn** 3.8.0 (berry) · **PostgreSQL** 12+ · **libvips** for images
11
+ - **Ruby** `>= 3.3` (RuboCop targets 3.4) · **Rails** `>= 8.0, < 8.2` (lockfile 8.1.4)
12
+ - **Node** 24.22.0 (`.node-version`) · **Yarn** 4.18.1 with its defaults: no install scripts, no package published less than a day ago · **PostgreSQL** 12+ · **libvips** for images
13
13
  - Backend: `action_policy`, `closure_tree`, `acts_as_list`, `mobility` + `i18n-tasks`, `shrine` (+ blurhash/image_processing/aws-sdk-s3), `view_component` + `slim-rails` + `lookbook`, `kaminari`, `deepl-rb`
14
14
  - Frontend: **esbuild** (`esbuild.config.js`) + **PostCSS** (`postcss.config.js`); Stimulus/Turbo, TipTap, Uppy, Tom Select, SortableJS
15
15
  - Tests: **RSpec** (`rspec-rails`, capybara, simplecov) · Docs: **VitePress** (`docs/`)
@@ -22,8 +22,10 @@ bin/console # IRB with trek loaded
22
22
  rake # default: spec + rubocop
23
23
  rake spec # run tests (or: bundle exec rspec)
24
24
  COVERAGE=1 bundle exec rspec # tests + SimpleCov report in coverage/ (fails under the minimum set in spec/spec_helper.rb)
25
- make lint # all linters below
26
- make fix # rubocop/eslint/stylelint/prettier autocorrect
25
+ make lint # all linters below (make -k lint to run them all despite a failure)
26
+ make security # brakeman + bundler-audit
27
+ make fix # rubocop/eslint/stylelint/prettier autocorrect, then make i18n-normalize
28
+ make i18n-normalize # sort the locale keys (i18n-tasks normalize), then Prettier them; CI checks it
27
29
  make release # bump version (version.rb + package.json), stamp CHANGELOG, tag, push gem + npm
28
30
  yarn docs:dev # VitePress docs locally
29
31
  ```
@@ -42,14 +44,14 @@ Security: `bundle exec brakeman` · `bundle exec bundle-audit check --update`
42
44
 
43
45
  ## Structure
44
46
 
45
- - `app/` — engine code, namespaced under `trek/`: `components/` (ViewComponents), `controllers/`, `forms/`, `models/`, `policies/` (ActionPolicy), `uploaders/` (Shrine), `views/`, `javascript/` (Stimulus)
47
+ - `app/` — engine code, namespaced under `trek/`: `components/` (ViewComponents), `controllers/`, `forms/`, `models/`, `policies/` (ActionPolicy), `uploaders/` (Shrine), `validators/` (top-level, e.g. `NotDisposableValidator`), `views/`, `javascript/` (Stimulus)
46
48
  - `lib/generators/trek/` — the heart of the gem: `install/` (~30 generators), `scaffold_generator.rb`, `admin/`, `templates/`
47
49
  - `lib/trek/` — `engine.rb`, `version.rb`, `i18n_keys_resolver.rb`, `typography_formatter.rb`
48
50
  - `config/locales/` — `trek.en.yml`, `trek.fr.yml`
49
51
  - `spec/` — RSpec suite, two kinds of spec:
50
52
  - **isolated** (`require_relative` the file under test, stub its host): concerns, helpers, simple components
51
53
  - **Rails** (`require "rails_helper"`): boots `spec/dummy`, a minimal host app on PostgreSQL (`trek_test`, or `DATABASE_URL`). Its models, migrations, Shrine initializer and the whole admin (controllers, views, routes, policies, mailers) are not committed: `spec/dummy/lib/generated_files.rb` runs Trek's own generator steps into `tmp/dummy` on every boot, and the database is rebuilt from them. A new model or migration template must be added to its `STEPS`, or `spec/dummy/generated_files_spec.rb` fails.
52
- - **Host-app specs**: model and admin request specs and their [Oaken](https://github.com/kaspth/oaken) seeds are templates (`lib/generators/trek/templates/{spec/models,spec/requests,db/seeds}/`), installed in host apps by `trek:install:model_specs` and run by Trek's suite from `tmp/dummy` (`spec/dummy/generated_specs_spec.rb`); test data comes from `users.create`, `pages.create` and `seed "cases/…"`, not factories. Write specs for Trek's models there, in host-app style (no `frozen_string_literal`, Ruby 3.1-compatible — no bare `it` block parameter), so host apps get them too.
54
+ - **Host-app specs**: model, admin request, policy and mailer specs and their [Oaken](https://github.com/kaspth/oaken) seeds are templates (`lib/generators/trek/templates/{spec/models,spec/requests,spec/policies,spec/mailers,db/seeds}/`), installed in host apps by `trek:install:model_specs` and run by Trek's suite from `tmp/dummy` (`spec/dummy/generated_specs_spec.rb`); test data comes from `users.create`, `pages.create` and `seed "cases/…"`, not factories. Write specs for Trek's models there, in host-app style (no `frozen_string_literal`, Ruby 3.3-compatible — no bare `it` block parameter), so host apps get them too.
53
55
  - **Generators** (`spec/trek/generators_spec.rb`): every generator runs on a copy of a real `rails new` app (`spec/support/generators.rb`, built once per run into `tmp/generator_skeleton`), then again to check it changes nothing. Shell-outs are recorded in `shell_commands`, not run. A new generator is picked up automatically; if it needs arguments, an earlier Trek step or a starting file, add it to the spec's `arguments`, `prerequisites` or `setups`.
54
56
  - Both kinds run in one process, so an isolated spec must restore any global it changes (`I18n`, `Shrine` storages…). `spec_helper` loads Rails and Action View before Trek, as a host app does: several dependencies (ActionPolicy, Slim, ViewComponent) configure themselves from what is already loaded.
55
57
  - `docs/` — VitePress site
@@ -60,6 +62,8 @@ Security: `bundle exec brakeman` · `bundle exec bundle-audit check --update`
60
62
  - **Slim** linted via slim_lint; **JS/CSS** via ESLint + Stylelint + Prettier 2.8.8
61
63
  - **i18n**: keep English + French locales in sync (`config/locales/trek.*.yml`); DeepL auto-translation via `DEEPL_AUTH_KEY`
62
64
  - **Versioning**: version lives in both `lib/trek/version.rb` and `package.json` — keep in sync via `make release`
63
- - **CHANGELOG.md**: Keep-a-Changelog format. **Every MR must add an `[Unreleased]` entry.** Keep entries short: one or two sentences on what changed for host apps, not how it was found or fixed — the MR description holds the details. When the change requires action in the host app on upgrade, end the entry with a bold `**Upgrade note:**` label followed by what to do. Use the same label when the change lets host apps remove or simplify existing patches or custom implementations (e.g. "**Upgrade note:** you can now drop your custom …") — never as an unlabelled trailing sentence.
65
+ - **CHANGELOG.md**: Keep-a-Changelog format. **Every MR must add an `[Unreleased]` entry**, except one that only changes specs. Keep entries short: one or two sentences on what changed for host apps, not how it was found or fixed — the MR description holds the details. When the change requires action in the host app on upgrade, end the entry with a bold `**Upgrade note:**` label followed by what to do. Use the same label when the change lets host apps remove or simplify existing patches or custom implementations (e.g. "**Upgrade note:** you can now drop your custom …") — never as an unlabelled trailing sentence.
66
+ - **Generated model names**: a new model template belonging to another model is nested under it, in `models/<owner>/` (`User::Session`, `User::PreviousPassword`), not prefixed (`UserSession`). Nested in an Active Record model, it keeps the prefixed table name (`user_sessions`) and its owner's `has_many` finds it without `class_name:`. The older `PagePath`, `PageVersion` and `TagCategory` move in Trek 3 (#248).
67
+ - **Generators' npm packages**: the install generators' `NPM_DEPENDENCIES` (`lib/generators/trek/install/*_generator.rb`) add to host apps the packages needed by the config files they copy from Trek's root (`esbuild.config.js`, `postcss.config.js`, `.eslintrc.json`, `.stylelintrc.json`, `lefthook.yml`). When a package is bumped in Trek's `package.json` — by hand or by Renovate, which doesn't touch the generators — bump its range in the generator in the same MR, or new apps get a version the copied config may not work with (as esbuild 0.15 did). List only packages those configs or the generated scripts use.
64
68
  - **Public code**: Trek ships publicly (gem, npm, docs), so nothing committed may mention a client or project name, nor a client's domain models or business logic — not in code, comments, specs, templates, docs, CHANGELOG or commit messages. Use neutral examples (`Page`, `Shop::Product`, an engine's `Blog::Post`). Client context belongs in GitLab issues and MR descriptions only.
65
- - **CI**: GitLab CI (`.gitlab-ci.yml`), stages build → lint → security → test → deploy; docs deploy to Netlify; deps via Renovate
69
+ - **CI**: GitLab CI (`.gitlab-ci.yml`), stages build → lint (one job: `make -k lint security i18n-check`) → test → deploy, the test jobs starting without waiting for lint; docs deploy to Netlify; deps via Renovate
data/CHANGELOG.md CHANGED
@@ -1,5 +1,78 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [2.5.0] - 2026-10-25
4
+
5
+ ### Changed
6
+
7
+ - **Security:** rich text is rendered with the [`prosemirror`](https://github.com/etaminstudio/prosemirror) gem instead of `prosemirror_to_html`, which had two XSS advisories: HTML is escaped as it is built, attributes are typed, and links and images only allow `http`, `https`, `mailto`, `tel` and relative URLs. The content editor's image and prompt blocks render out of the box (`Trek::Content::ImageBlock`, `Trek::Content::PromptsBlock`), empty list items and lists are skipped like empty paragraphs, invalid content is reported to `Rails.error`, with the record holding it in the context (`trek_content: "Page#12"`, a tag in AppSignal), and the records that a page's links point to load at once, with one query per model. See [Rich text rendering](https://trek.etamin.studio/reference/formatters#rich-text-rendering). **Upgrade note:** the `Prosemirror` model and the `ProsemirrorToHtml` formatters are removed: call `formatted_content`, or `Trek::Content.schema.parse(content).to_html`, instead of `Prosemirror.new.format_content`, and rewrite the app's `ProsemirrorToHtml` nodes as node types registered in `Trek::Content.schema` (see [Custom blocks](https://trek.etamin.studio/reference/formatters#custom-blocks)).
8
+ - Trek requires **Rails 8.0** or later (was 6.0) and **Ruby 3.3** (was 3.1: Rails 8 needs 3.2, and the `prosemirror` gem 3.3). Its authentication already relied on Rails 8: `has_secure_password`'s `:password_reset` token and `password_reset_token`, without which a password reset fails on Rails 7.2 (`KeyError: key not found: :password_reset`) and so does a password renewal (`NoMethodError`). **Upgrade note:** an app on Rails 7 upgrades Rails before Trek (see the [Rails 8.0 upgrade guide](https://guides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rails-7-2-to-rails-8-0)); meanwhile, it can declare the token in `app/models/user.rb`, after `has_secure_password`: `generates_token_for(:password_reset, expires_in: 15.minutes) { password_salt&.last(10) }` and `def password_reset_token = generate_token_for(:password_reset)`.
9
+ - Trek is now developed and tested against **css_parser 3.3** (was 3.0), which Lookbook, a Trek dependency, brings in: 3.2 and 3.3 fix a ReDoS on an unclosed CSS function ([GHSA-84w7-hpvm-rxx2](https://github.com/premailer/css_parser/security/advisories/GHSA-84w7-hpvm-rxx2)) and a local file read through `@import` ([GHSA-w3mx-4vv9-hjpg](https://github.com/premailer/css_parser/security/advisories/GHSA-w3mx-4vv9-hjpg)). **Upgrade note:** run `bundle update css_parser` if the app's `Gemfile.lock` has an older one.
10
+ - Trek is now developed and tested against **crass 1.0.8** (was 1.0.7), which Loofah and rails-html-sanitizer bring in to sanitize CSS: it fixes a CSS sanitizer bypass through bad URLs ([GHSA-pq4g-8rxf-4g29](https://github.com/rgrove/crass/security/advisories/GHSA-pq4g-8rxf-4g29)). **Upgrade note:** run `bundle update crass` if the app's `Gemfile.lock` has an older one.
11
+ - The generators no longer print RuboCop's report when they autocorrect the files they inject code into, only an `autocorrect` line per file; an offense RuboCop can't correct is still shown, and stops the install.
12
+ - Trek's own CI is faster: its linters and security checks run in one job (`make -k lint security i18n-check`, with a `make` target per tool), the tests no longer wait for them, and the generated app's install keeps its gems and Rails in a cache, one per Ruby version, and is skipped for changes to the docs or the repository's tooling; it no longer installs Trek's own gems and packages first. Nothing changes for host apps.
13
+ - The admin's fragments index shows each fragment's title, its key (`namespace.key`) and the start of its content, with `Trek::EntriesComponent`, instead of only its key, and has a search box matching the key, the title or the content's text (`Fragment.search`). **Upgrade note:** to get them, copy from Trek's templates (`lib/generators/trek/templates/`) `views/admin/fragments/index.html.slim`, the `search` scope of `models/fragment.rb`, and `controllers/admin/fragments_controller.rb`.
14
+
15
+ ### Fixed
16
+
17
+ - Since 0.1.18, rendering rich text that links to a page raised `NoMethodError: undefined method 'page_url'`: page links are turned into URLs with `url_for`, which needs `Trek::PagePathHelper`, no longer included. An app's own `direct :page` route still takes precedence. **Upgrade note:** you can now drop initializers that include `Trek::PagePathHelper` in `ProsemirrorToHtml::GlobalIdToLinksFormatter`.
18
+ - Since 2.4.0, the site's links to pageable records (`Trek::Pageable`) used their id instead of their page's slug: `to_param` took the admin IP allowlist middleware, in the stack of every request, for an admin caller.
19
+ - The content editor's link, image and prompt panels opened empty ("Content missing"): the installer routed them to `Admin::Panels` controllers it didn't generate. It now generates them, subclasses of `Trek::Panels::*` that serve Trek's panels under the app's routes. The panels' titles, field labels and image sizes are translated, and the link panel no longer needs `OpenStruct`, which Ruby doesn't load by default since 3.5. **Upgrade note:** run `rails g trek:install:admin` and keep only its new `app/controllers/admin/panels/*_controller.rb`, or copy them from Trek's templates (`lib/generators/trek/templates/controllers/admin/panels`); you can then drop your own translations of `trek.panels.*.form.title`, of `activemodel.attributes.trek/content_editor/*` and of the image sizes, and the `ostruct` gem if nothing else needs it. Re-run `rails g trek:install:model_specs` for the new `spec/requests/admin/panels_spec.rb`.
20
+ - `Trek::Reorderable` gives the views `reorder_path`, which the scaffolded index's commented-out reorder form uses, and reorders without Prosopite taking acts_as_list's repeated queries for an N+1. **Upgrade note:** you can now drop your own `helper_method :reorder_path` and Prosopite pause around `reorder`.
21
+ - The admin's lists, the pages' tree and the content editor's image panel raised `NoMethodError: undefined method 'derivation_url'` on an image when the image uploader doesn't load Shrine's derivation endpoint, as the generated `ImageUploader` doesn't: they show the image itself instead, as the image field already did (`Trek::ThumbnailHelper.thumbnail_url`). **Upgrade note:** you can now drop the derivation endpoint if you enabled it only for these thumbnails.
22
+ - The specs installed by `trek:install:model_specs` pass in an app whose default locale isn't English: the three examples reading browser descriptions ("Firefox on Windows") use an English-speaking user. **Upgrade note:** re-run `rails g trek:install:model_specs`, or drop your own locale workarounds in `spec/mailers/admin_mailer_spec.rb`, `spec/requests/admin/sign_in_notices_spec.rb` and `spec/requests/admin/active_sessions_spec.rb`.
23
+ - `trek:scaffold` passes the attributes to the model generator as given: it dropped their indexes (`slug:string:uniq`, `isbn:string:index`), references' options (`author:references{polymorphic}`) and decimals' precision (`price:decimal{10,2}`).
24
+ - The generated `Makefile` lints every Slim template: unquoted, `make`'s shell expanded `app/**/*.slim` one directory deep only, so `make lint` skipped what CI caught. **Upgrade note:** quote the pattern in your `Makefile`'s `lint` target: `bundle exec slim-lint "app/**/*.slim"`.
25
+ - `trek:install:specs` includes the matchers of rspec-html-matchers (`have_tag`, `with_tag`), which it adds to the Gemfile, in `spec/rails_helper.rb`. **Upgrade note:** add `config.include RSpecHtmlMatchers` to the `RSpec.configure` block of `spec/rails_helper.rb` to use them.
26
+ - `Trek::SearchComponent` labels its field in the admin's language by default (it was always « Rechercher »), and its label is tied to the field, which has an id of its own: clicking the label focuses the field, and screen readers announce the field by its label.
27
+
28
+ ## [2.4.0] - 2026-10-16
29
+
30
+ ### Added
31
+
32
+ - `Trek::Form::ImageFieldComponent` (`f.image_field`) shows a « See original » button opening the uploaded image in a new tab.
33
+ - An audit log: `rails g trek:install:audit_log` installs an `AuditLog` model recording each mutation in the admin (author, request, target record, status), sign-ins included, and an admin list for the `admin` role; `Trek::AuditLog::PurgeJob` deletes rows past 6 months. See [Audit log](https://trek.etamin.studio/reference/generators/audit-log). **Upgrade note:** an app with its own audit log can drop its copy for Trek's, keeping its `audit_logs` table (see the docs' migration steps).
34
+ - `Trek::Filters` exposes `filter_params` to views, as `Trek::Scopes` does `scope_params`.
35
+ - Users can't reuse one of their last 5 passwords (`Trek::Users::PasswordHistory`, configurable with `password_history_size`). **Upgrade note:** copy `app/models/user/previous_password.rb` (`User::PreviousPassword`) and the `user_previous_passwords` migration from Trek's templates (`lib/generators/trek/templates/{models,migrations}`), run it, add `include Trek::Users::PasswordHistory` after `has_secure_password` in `app/models/user.rb`, and re-run `rails g trek:install:model_specs` for the new specs.
36
+ - Password expiry and renewal (`Trek::Users::PasswordRenewal`): an admin can ask every user for a new password after a suspected compromise, and `password_expires_after` (none by default) makes passwords expire. A user concerned is signed out and sent to the new password form, which states the rules and rates the password as it is typed (`Trek::Form::PasswordStrengthComponent`). **Upgrade note:** copy the `user_password_renewal` migration from Trek's templates (`lib/generators/trek/templates/migrations`) and run it, add `include Trek::Users::PasswordRenewal` after `has_secure_password` in `app/models/user.rb`, and take the changes to `require_authentication` in `app/controllers/concerns/trek/authentication.rb`, the `require_password_renewal` action of `Admin::UsersController`, its route (`post :require_password_renewal, on: :collection` in `resources :users`), and the `admin/users/index` and `admin/user_password_resets/edit` views from Trek's templates.
37
+ - Sessions expire after 48 hours without a request and 30 days after signing in (`Trek::Users::SessionLifetime`, configurable on `User::Session`), and users see their active sessions in a tab of their profile, to sign out any other or all of them; an IP address shows its host name on hover. Session activity is written at most every 5 minutes instead of on every request. **Upgrade note:** copy the `user_session_tracking` migration from Trek's templates (`lib/generators/trek/templates/migrations`) and run it; add `include Trek::Users::SessionLifetime` to `app/models/user/session.rb` (or `app/models/user_session.rb`); take Trek's changes to `app/controllers/concerns/trek/authentication.rb` (`find_session_by_cookie`, `start_new_session_for`, `track_last_activity`), to `Admin::UsersController#show` and to `app/views/admin/users/show.html.slim` (with its new `_properties` and `_sessions` partials); copy `app/controllers/admin/active_sessions_controller.rb` from Trek's templates and add its route (`resources :active_sessions, only: :destroy do delete :others, action: :destroy_others, on: :collection end` in the admin namespace); schedule `Trek::PurgeExpiredSessionsJob` daily.
38
+ - Users see their previous sign-in (date, browser, IP address) on their profile's Active sessions tab, and a sign-in from a browser that never signed in as them emails them (`Trek::Users::SignIns`, `new_sign_in_email`). **Upgrade note:** copy the `user_sign_ins` migration and the `admin_mailer/new_sign_in` views from Trek's templates and run the migration; add `include Trek::Users::SignIns` to `app/models/user.rb`; take Trek's changes to `app/controllers/concerns/trek/authentication.rb` (`record_sign_in_of` and the methods after it), `app/controllers/admin/user_sessions_controller.rb` (`create`, `sign_in_notice`), `app/mailers/admin_mailer.rb` (`new_sign_in`) and `app/views/admin/users/_sessions.html.slim`.
39
+ - `Trek::SectionComponent`: a titled section of a page (an `h2` labelling it), with an optional hint under the heading.
40
+ - `NotDisposableValidator` refuses email addresses from disposable providers, on any model: `validates :email, not_disposable: true`. The domains come from the `valid_email2` gem, which keeps them up to date. See [Validators](https://trek.etamin.studio/reference/validators).
41
+ - Failed sign-ins are throttled per account and per IP address over a longer window: after 5 failures in a row, an account's sign-in locks for 1 minute, doubled on each further failure up to 1 hour, and its user is emailed (`Trek::Users::SignInLockout`); an IP address gets 20 failures an hour, whatever the account. A locked account gets the same answer as a wrong password, and a failed or throttled sign-in now renders the form (422, 429) instead of redirecting, so the audit log counts it as a failure, on the account tried. See [Failed sign-ins](https://trek.etamin.studio/reference/models/user#failed-sign-ins), including why `Rails.cache` must be shared between servers. **Upgrade note:** copy the `user_sign_in_lockout` migration and the `admin_mailer/sign_in_locked` views from Trek's templates and run the migration; add `include Trek::Users::SignInLockout` to `app/models/user.rb`; take Trek's `app/controllers/admin/user_sessions_controller.rb` and the `sign_in_locked` method of `app/mailers/admin_mailer.rb`.
42
+ - Passkeys: users add and delete passkeys on a new tab of their profile, which names each after its password manager, and sign in with one instead of their password, from a button on the sign-in form or the email field's autofill (`Trek::Users::Passkeys`, `User::Passkey`, through the `webauthn` gem). The password keeps working. See [Passkeys](https://trek.etamin.studio/reference/models/user#passkeys). **Upgrade note:** copy `app/models/user/passkey.rb` and the `user_passkeys` migration from Trek's templates and run it; add `include Trek::Users::Passkeys` to `app/models/user.rb`; copy `app/controllers/admin/passkeys_controller.rb` and `app/controllers/admin/passkey_sessions_controller.rb`, and add their routes in the admin namespace (`resources :passkeys, only: %i[create destroy] do get :options, on: :collection end` and `resource :passkey_session, only: :create do get :options end`); take Trek's changes to `app/views/admin/user_sessions/new.html.slim`, `app/views/admin/users/show.html.slim` (with the new `_passkeys` partial) and `Admin::UsersController#show`; with the audit log, add `Admin::PasskeySessionsController` to `config/initializers/audit_log.rb`.
43
+ - A [Security and compliance](https://trek.etamin.studio/security) docs page maps Trek's security measures to ISO 27001's controls and NIS2's measures, and lists what stays with the app, its hosting and the organization.
44
+ - The [Security and compliance](https://trek.etamin.studio/security#cryptography) page lists the cryptography a generated app uses, and how each algorithm stands against a quantum computer.
45
+ - The generated GitLab CI has an `sbom` job, commented out, making a Software Bill of Materials (CycloneDX, with cdxgen) of the app's gems and npm packages, for a client who asks for one. See [Software Bill of Materials](https://trek.etamin.studio/reference/generators/install#software-bill-of-materials). **Upgrade note:** when a client asks for an SBOM, copy the `sbom` job from Trek's `lib/generators/trek/templates/.gitlab-ci.yml` into the app's `.gitlab-ci.yml`, uncommented.
46
+ - `ADMIN_ALLOWED_IPS` restricts the admin to IP addresses and ranges (e.g. `203.0.113.0/24, 2001:db8::/32`): from anywhere else, `/admin` and everything below it answer like an unknown URL, a 404. Off when unset. Behind a CDN, list its ranges in `trusted_proxies` first. See [Restricting the admin to IP addresses](https://trek.etamin.studio/proxies#restricting-the-admin-to-ip-addresses).
47
+ - Security headers: `rails g trek:install:security_headers`, which `trek:install` runs, sets up a Content Security Policy, report-only at first, allowing no inline script, and a `Permissions-Policy` header turning off the browser features the app doesn't use (camera, microphone, geolocation…). Violations are reported to `/csp-reports` (`Trek::CspReportsController`), which sends them to AppSignal, one incident per directive and blocked origin, and to the log, throttled against floods. It replaces Rails' commented-out example, but leaves an app's own policy. HSTS, from `force_ssl`, already covers subdomains; its `preload` option is documented. See [Security headers](https://trek.etamin.studio/reference/generators/security-headers). **Upgrade note:** run `rails g trek:install:security_headers`, browse the app with the console open and watch AppSignal's `csp` namespace, add the front office's third-party hosts, then set `content_security_policy_report_only` to `false`.
48
+
49
+ ### Changed
50
+
51
+ - Trek pins **Node 24.22.0** (was 24.18.0) in `.node-version`. **Upgrade note:** existing apps can set `24.22.0` in their `.node-version`.
52
+ - `trek:install:yarn` installs **Yarn 4.18.1** (was 4.18.0), and Trek's own development moves to it from Yarn 3, with its defaults: no install scripts, and no package published less than a day ago. **Upgrade note:** existing apps can upgrade with `yarn set version 4.18.1` followed by `yarn install`.
53
+ - Passwords follow the ANSSI's recommendations for a privileged access (`Trek::Users::PasswordPolicy`, included by `Trek::Users::Validations`): at least 12 characters, with a digit and a symbol below 20, and neither a common password, a keyboard or number sequence, nor the user's name or email; a Have I Been Pwned check is opt-in. Existing passwords keep working: the rules apply when one is set. **Upgrade note:** the rules are configurable in `app/models/user.rb` (`password_min_length`, `passphrase_length`, `password_check_pwned`); update seeds and specs whose passwords no longer pass.
54
+ - The generated signed-in browser model is `User::Session` (`user.sessions`), in the same `user_sessions` table. Apps generated before keep working with `UserSession`. **Upgrade note:** to follow, move `app/models/user_session.rb` to `app/models/user/session.rb` as `class User::Session`, replace `has_many :user_sessions` with `has_many :sessions` in `app/models/user.rb`, and update `UserSession.find_by` and `user.user_sessions` in `app/controllers/concerns/trek/authentication.rb` and `app/controllers/admin/user_password_resets_controller.rb`; no migration is needed.
55
+ - The admin's Inter font comes with Trek's npm package ([`@fontsource/inter`](https://fontsource.org/fonts/inter)), bundled into `admin.css`, instead of Google Fonts: visitors' browsers no longer contact Google, and the Content Security Policy needs no Google host. **Upgrade note:** remove `admin_webfonts_link_tag` from `app/helpers/application_helper.rb` and `app/views/layouts/admin.html.slim`, and the Google Fonts `link` tags from both admin layouts (`admin.html.slim`, `admin/auth.html.slim`); `esbuild.config.js` must have the `.woff` and `.woff2` file loaders, as Trek's has.
56
+
57
+ ### Deprecated
58
+
59
+ - `Trek::UserSession`, the sign-in form object Trek 2 no longer uses, warns and will be removed in Trek 3. **Upgrade note:** in a sign-in controller still building one, pass the params to `User.authenticate_by(email:, password:)` instead, as Trek's generated `Admin::UserSessionsController` does.
60
+
61
+ ### Changed
62
+
63
+ - The install generators no longer add `esbuild-plugin-import-glob`, `postcss-cli`, `postcss-nesting` and `postcss-url`, which no generated config uses. **Upgrade note:** you can drop them from the app's `package.json` (`yarn remove …`), except those its own `postcss.config.js`, `esbuild.config.js` or `package.json` scripts still use (e.g. `postcss-url` to rebase the URLs of `@import`-ed CSS).
64
+ - `rails g trek:install` runs Trek's own generators in its process instead of starting `rails generate` for each, which saves about two minutes.
65
+
66
+ ### Fixed
67
+
68
+ - The generated `.gitlab-ci.yml`'s commented-out deploy jobs point at `example.com` instead of a real site.
69
+ - A tag's key is unique within its category, as `Tag` validates it and the docs said: the generated `tags` migration's unique index on `key` alone refused the same key in two categories with `ActiveRecord::RecordNotUnique`. A tag category with tags can no longer be deleted, which left them without a category, and the admin now says why a deletion is refused instead of reporting it done. **Upgrade note:** in `app/models/tag_category.rb`, replace `dependent: :nullify` with `dependent: :restrict_with_error`. Check that no category has two tags with the same key, nor two tags without a category, then generate a migration (`bin/rails g migration TagKeyUniquePerCategory`) with `remove_index :tags, name: "index_tags_on_key", if_exists: true` (apps generated with Trek 0.1.9 or later have it), `add_index :tags, %i[category_id key], unique: true` and `add_index :tags, :key, unique: true, where: "category_id IS NULL", name: "index_tags_on_key_without_category"`. Copy `spec/models/tag_spec.rb` from Trek's templates for the specs.
70
+ - The notice after signing in is in the user's language, rather than the app's default one.
71
+ - The password reset request no longer reveals whether an email has an account: it answers every email the same way, and queues `Admin::PasswordResetJob` for each, which emails privileged users only, so the response takes as long either way. **Upgrade note:** copy `app/jobs/admin/password_reset_job.rb` from Trek's templates (`lib/generators/trek/templates/jobs/admin`), and in `Admin::UserPasswordResetsController#create`, replace the user lookup and `deliver_later` with `Admin::PasswordResetJob.perform_later(params[:email].to_s)`.
72
+ - Icons drawn in black (`stroke="#000000"`, such as the content editor's toolbar icons) stayed black in the dark theme, and in any colored context: since the sprite was sanitized in two passes, black was turned into `currentColor` before the icon's paths were inserted, so it never reached them. The substitution now runs once the paths are in.
73
+ - `trek:install:esbuild` installed esbuild 0.15, too old for the `esbuild.config.js` it copies: `yarn build --watch` (and `bin/dev`) crashed with `esbuild.context is not a function`. It now installs esbuild 0.28, as Trek does. **Upgrade note:** in an app generated by an earlier Trek 2, run `yarn add --dev esbuild@^0.28.0`.
74
+ - The generated invitation and password reset emails formatted the link's expiry (« 7 days ») in the app's default locale instead of the recipient's. `rails g trek:install:model_specs` now also installs mailer specs covering it. **Upgrade note:** in `app/mailers/admin_mailer.rb` and `app/mailers/admin/passwords_mailer.rb`, move the `@expiration_delay = …` line inside the `I18n.with_locale` block, before `mail`; re-run `rails g trek:install:model_specs` for the new specs.
75
+
3
76
  ## [2.3.2] - 2026-10-02
4
77
 
5
78
  ### Fixed