trek 2.4.0 → 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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/AGENTS.md +6 -5
  3. data/CHANGELOG.md +25 -0
  4. data/Gemfile.lock +192 -171
  5. data/Makefile +26 -1
  6. data/README.md +2 -2
  7. data/app/components/trek/form/image_field_component.rb +1 -5
  8. data/app/components/trek/list/item_component.rb +1 -1
  9. data/app/components/trek/list/tree/item_component.rb +2 -2
  10. data/app/components/trek/search_component/search_component.html.slim +2 -1
  11. data/app/components/trek/search_component.rb +9 -1
  12. data/app/content/trek/content/bullet_list.rb +10 -0
  13. data/app/content/trek/content/document.rb +33 -0
  14. data/app/content/trek/content/image_block.rb +52 -0
  15. data/app/content/trek/content/link_resolver.rb +33 -0
  16. data/app/content/trek/content/list_item.rb +19 -0
  17. data/app/content/trek/content/ordered_list.rb +10 -0
  18. data/app/content/trek/content/paragraph.rb +10 -0
  19. data/app/content/trek/content/prompts_block.rb +22 -0
  20. data/app/content/trek/content.rb +32 -0
  21. data/app/controllers/concerns/trek/reorderable.rb +14 -3
  22. data/app/controllers/trek/csp_reports_controller.rb +3 -6
  23. data/app/controllers/trek/panels/base_controller.rb +3 -0
  24. data/app/controllers/trek/panels/links_controller.rb +1 -1
  25. data/app/controllers/trek/panels/prompts_controller.rb +1 -1
  26. data/app/helpers/trek/thumbnail_helper.rb +11 -0
  27. data/app/models/concerns/trek/contentable.rb +9 -14
  28. data/app/models/concerns/trek/pageable.rb +10 -1
  29. data/app/views/trek/panels/images/_form.html.slim +1 -1
  30. data/app/views/trek/panels/images/create.turbo_stream.slim +1 -1
  31. data/app/views/trek/panels/links/_form.html.slim +1 -1
  32. data/app/views/trek/panels/prompts/_form.html.slim +1 -1
  33. data/config/locales/trek.en.yml +23 -0
  34. data/config/locales/trek.fr.yml +23 -0
  35. data/docs/getting-started.md +3 -3
  36. data/docs/reference/concerns/contentable.md +2 -1
  37. data/docs/reference/controllers.md +1 -1
  38. data/docs/reference/formatters.md +31 -8
  39. data/docs/reference/models/fragment.md +1 -0
  40. data/docs/what-is-trek.md +4 -4
  41. data/lib/generators/trek/helpers.rb +13 -5
  42. data/lib/generators/trek/install/admin_generator.rb +8 -0
  43. data/lib/generators/trek/install/appsignal_generator.rb +1 -1
  44. data/lib/generators/trek/install/authentication_generator.rb +1 -1
  45. data/lib/generators/trek/install/authorization_generator.rb +1 -1
  46. data/lib/generators/trek/install/postmark_generator.rb +2 -2
  47. data/lib/generators/trek/install/specs_generator.rb +11 -0
  48. data/lib/generators/trek/install/user_generator.rb +1 -1
  49. data/lib/generators/trek/scaffold_generator.rb +13 -5
  50. data/lib/generators/trek/templates/Makefile +1 -1
  51. data/lib/generators/trek/templates/controllers/admin/fragments_controller.rb +7 -0
  52. data/lib/generators/trek/templates/controllers/admin/panels/images_controller.rb +8 -0
  53. data/lib/generators/trek/templates/controllers/admin/panels/links_controller.rb +8 -0
  54. data/lib/generators/trek/templates/controllers/admin/panels/prompts_controller.rb +8 -0
  55. data/lib/generators/trek/templates/models/fragment.rb +14 -0
  56. data/lib/generators/trek/templates/spec/mailers/admin_mailer_spec.rb +2 -1
  57. data/lib/generators/trek/templates/spec/requests/admin/active_sessions_spec.rb +1 -0
  58. data/lib/generators/trek/templates/spec/requests/admin/fragments_spec.rb +26 -2
  59. data/lib/generators/trek/templates/spec/requests/admin/pages_spec.rb +8 -0
  60. data/lib/generators/trek/templates/spec/requests/admin/panels_spec.rb +54 -0
  61. data/lib/generators/trek/templates/spec/requests/admin/sign_in_notices_spec.rb +5 -3
  62. data/lib/generators/trek/templates/views/admin/fragments/index.html.slim +14 -3
  63. data/lib/trek/engine.rb +8 -3
  64. data/lib/trek/saved_attachments_reload.rb +2 -1
  65. data/lib/trek/version.rb +1 -1
  66. data/lib/trek.rb +1 -1
  67. data/package.json +1 -1
  68. data/renovate.json +1 -0
  69. data/trek.gemspec +3 -3
  70. data/yarn.lock +842 -880
  71. metadata +29 -14
  72. data/app/formatters/prosemirror_to_html/global_id_to_links_formatter.rb +0 -19
  73. data/app/formatters/prosemirror_to_html/nodes/image_block.rb +0 -44
  74. data/app/formatters/prosemirror_to_html/nodes/prompts_block.rb +0 -28
  75. data/app/formatters/prosemirror_to_html/remove_empty_paragraphs_formatter.rb +0 -11
  76. data/app/models/prosemirror.rb +0 -23
data/Makefile CHANGED
@@ -1,13 +1,38 @@
1
1
  .PHONY: *
2
2
 
3
- lint:
3
+ # One target per tool: `make -k lint` runs them all and reports every failure, as CI does.
4
+ lint: lint-ruby lint-slim lint-js lint-css lint-prettier lint-i18n
5
+
6
+ lint-ruby:
4
7
  bundle exec rubocop
8
+
9
+ lint-slim:
5
10
  bundle exec slim-lint "app/**/*.slim"
11
+
12
+ lint-js:
6
13
  yarn eslint "app/**/*.js"
14
+
15
+ lint-css:
7
16
  yarn stylelint "app/**/*.css"
17
+
18
+ lint-prettier:
8
19
  yarn prettier --check "{app,config,lib,spec}/**/*.{css,js,json,md,yml}"
20
+
21
+ # Locale parity: every base-locale key must be translated in the others. (Full `health` doesn't fit
22
+ # an engine: keys are used by host apps, and many components use relative keys that only resolve
23
+ # there.)
24
+ lint-i18n:
9
25
  bundle exec i18n-tasks missing -t diff
10
26
 
27
+ # One target per tool, as for lint
28
+ security: security-brakeman security-bundler-audit
29
+
30
+ security-brakeman:
31
+ bundle exec brakeman --no-exit-on-error
32
+
33
+ security-bundler-audit:
34
+ bundle exec bundle-audit check --update
35
+
11
36
  fix:
12
37
  bundle exec rubocop --autocorrect
13
38
  yarn eslint "app/**/*.js" --fix
data/README.md CHANGED
@@ -4,8 +4,8 @@ Trek is a modern content management system for Ruby on Rails, that is designed t
4
4
 
5
5
  ## Prerequisites
6
6
 
7
- - Rails 7.0+
8
- - Ruby 3.1+
7
+ - Rails 8.0+
8
+ - Ruby 3.3+
9
9
  - PostgreSQL 12+
10
10
  - Node 22+
11
11
  - Yarn 4.x
@@ -30,11 +30,7 @@ module Trek
30
30
  end
31
31
 
32
32
  def image_url
33
- if image.respond_to? :derivation
34
- image.derivation_url(:thumbnail, 300, 150)
35
- else
36
- image.url
37
- end
33
+ Trek::ThumbnailHelper.thumbnail_url(image, 300, 150)
38
34
  end
39
35
 
40
36
  def image
@@ -44,7 +44,7 @@ module Trek
44
44
 
45
45
  def image
46
46
  if item.image&.exists?
47
- image_tag item.image.derivation_url(:thumbnail, 80, 60),
47
+ image_tag Trek::ThumbnailHelper.thumbnail_url(item.image, 80, 60),
48
48
  loading: "lazy"
49
49
  else
50
50
  render Trek::IconComponent.new("trek/pic")
@@ -57,10 +57,10 @@ module Trek
57
57
 
58
58
  def image
59
59
  if node.image&.exists?
60
- image_tag node.image.derivation_url(:thumbnail, 80, 60),
60
+ image_tag Trek::ThumbnailHelper.thumbnail_url(node.image, 80, 60),
61
61
  loading: "lazy"
62
62
  elsif node.parent&.image&.exists?
63
- image_tag node.parent.image.derivation_url(:thumbnail, 80, 60),
63
+ image_tag Trek::ThumbnailHelper.thumbnail_url(node.parent.image, 80, 60),
64
64
  loading: "lazy"
65
65
  else
66
66
  render Trek::IconComponent.new("trek/pic")
@@ -1,7 +1,8 @@
1
1
  = form_with url: action, method: "get", class: root_class
2
- label(class=class_for("label") for="search") = label
2
+ label(class=class_for("label") for=input_id) = label_text
3
3
  div(class=class_for("wrapper"))
4
4
  input (
5
+ id=input_id
5
6
  name="search"
6
7
  type="text"
7
8
  value=value
@@ -3,7 +3,15 @@
3
3
  module Trek
4
4
  class SearchComponent < Trek::Component
5
5
  option :action
6
- option :label, default: proc { "Rechercher" }
6
+ option :label, optional: true
7
7
  option :value, optional: true
8
+
9
+ def label_text
10
+ label || t(".search")
11
+ end
12
+
13
+ def input_id
14
+ @input_id ||= "search-#{SecureRandom.hex(4)}"
15
+ end
8
16
  end
9
17
  end
@@ -0,0 +1,10 @@
1
+ module Trek
2
+ module Content
3
+ # A list with only empty items renders nothing.
4
+ class BulletList < Prosemirror::Nodes::BulletList
5
+ def view_template(&)
6
+ super unless ListItem.empty_list?(node)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,33 @@
1
+ module Trek
2
+ module Content
3
+ # A document with the record holding it. Problems reported to `Rails.error` while parsing or rendering it
4
+ # name the record in their context (`trek_content: "Page#12"`), which error trackers like AppSignal show as
5
+ # a tag. Documents are often rendered later than they're parsed, in a view, so the renderer sets it too.
6
+ class Document < Prosemirror::Document
7
+ def self.parse(record, json)
8
+ with_context(record) { new(Trek::Content.schema.parse(json).root, schema: Trek::Content.schema, record:) }
9
+ end
10
+
11
+ def self.with_context(record, &)
12
+ ActiveSupport::ExecutionContext.set(trek_content: "#{record.class.name}##{record.id}", &)
13
+ end
14
+
15
+ attr_reader :record
16
+
17
+ def initialize(root, record:, schema: Trek::Content.schema)
18
+ super(root, schema:)
19
+ @record = record
20
+ end
21
+
22
+ def to_phlex
23
+ Renderer.new(self)
24
+ end
25
+
26
+ class Renderer < Prosemirror::HTMLRenderer
27
+ def around_template(&)
28
+ Document.with_context(@document.record) { super }
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,52 @@
1
+ module Trek
2
+ module Content
3
+ # An image added with the content editor's image panel: a figure with its caption and credit.
4
+ # Subclass it to render the app's own component, for example with `derivation_url`:
5
+ #
6
+ # class ImageBlock < Trek::Content::ImageBlock
7
+ # def view_template
8
+ # render Components::Figure.new(image: image&.derivation_url(:thumbnail, 930, 1200), caption: @text)
9
+ # end
10
+ # end
11
+ class ImageBlock < Prosemirror::NodeType
12
+ group :block
13
+
14
+ prop :file_data, _String?
15
+ prop :alt, _String?
16
+ prop :text, _String?
17
+ prop :credit, _String?
18
+ prop :size, _Union?(*Trek::ContentEditor::Image::SIZES.map(&:to_s))
19
+
20
+ def view_template
21
+ return unless (src = image && safe_url(image.url))
22
+
23
+ figure(data_size: @size) do
24
+ img(src:, alt: @alt.to_s)
25
+ figcaption { caption } if @text.present? || @credit.present?
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ # The uploaded file, or nil when the node has none or its data is invalid.
32
+ def image
33
+ return if @file_data.blank?
34
+
35
+ @image ||= begin
36
+ object = Trek::ContentEditor::Image.new(file_data: @file_data)
37
+ ModelImageUploader::Attacher.from_model(object, :file).load_model(object, :file)
38
+ object.file
39
+ rescue JSON::ParserError, Shrine::Error => e
40
+ Rails.error.report(e, handled: true)
41
+ nil
42
+ end
43
+ end
44
+
45
+ def caption
46
+ plain(@text) if @text.present?
47
+ whitespace if @text.present? && @credit.present?
48
+ span { @credit } if @credit.present?
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,33 @@
1
+ module Trek
2
+ module Content
3
+ # Turns links to records, stored as GlobalIDs (`gid://app/Page/1`), into their URLs. Called with all the
4
+ # URLs of a document at once, it loads their records with one query per model. A record that doesn't
5
+ # exist resolves to nil, so its link is removed and its text kept.
6
+ class LinkResolver
7
+ # `url_for(page)` calls `page_url`. Included before the route helpers, so an app's own
8
+ # `direct :page` route takes precedence over Trek's helper.
9
+ include Trek::PagePathHelper
10
+ include Rails.application.routes.url_helpers
11
+
12
+ # A Hash from each URL to its resolved URL.
13
+ def call(urls)
14
+ records = locate(urls.select { |url| url.start_with?("gid://") })
15
+ urls.index_with { |url| url.start_with?("gid://") ? records[url]&.then { |record| url_for(record) } : url }
16
+ end
17
+
18
+ private
19
+
20
+ # The records of the GlobalIDs, by GlobalID. Records are matched by id rather than by their own
21
+ # GlobalID, which names their subclass. An unknown model raises NameError: its records are missing.
22
+ def locate(urls)
23
+ gids = urls.filter_map { |url| GlobalID.parse(url)&.then { |gid| [url, gid] } }
24
+ gids.group_by { |_url, gid| gid.model_name }.each_with_object({}) do |(_model, group), records|
25
+ found = GlobalID::Locator.locate_many(group.map(&:last), ignore_missing: true).index_by { |record| record.id.to_s }
26
+ group.each { |url, gid| records[url] = found[gid.model_id] }
27
+ rescue NameError
28
+ next
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,19 @@
1
+ module Trek
2
+ module Content
3
+ # Empty list items, with no content or only empty paragraphs, render nothing, like empty paragraphs.
4
+ class ListItem < Prosemirror::Nodes::ListItem
5
+ def self.empty?(node)
6
+ node.content.all? { |child| child.type == :paragraph && child.content.empty? }
7
+ end
8
+
9
+ # Whether a list has no item to render: only empty items, and whitespace.
10
+ def self.empty_list?(node)
11
+ node.content.all? { |child| child.text? ? child.text.strip.empty? : child.type == :list_item && empty?(child) }
12
+ end
13
+
14
+ def view_template(&)
15
+ li(&) unless self.class.empty?(node)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ module Trek
2
+ module Content
3
+ # A list with only empty items renders nothing.
4
+ class OrderedList < Prosemirror::Nodes::OrderedList
5
+ def view_template(&)
6
+ super unless ListItem.empty_list?(node)
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ module Trek
2
+ module Content
3
+ # Empty paragraphs, often left by the editor, render nothing.
4
+ class Paragraph < Prosemirror::Nodes::Paragraph
5
+ def view_template(&)
6
+ p(&) unless node.content.empty?
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,22 @@
1
+ module Trek
2
+ module Content
3
+ # A call to action added with the content editor's prompt panel, rendered as a link.
4
+ # Subclass it to render the app's own button component.
5
+ class PromptsBlock < Prosemirror::NodeType
6
+ group :block
7
+
8
+ prop :text, _String?
9
+ prop :href, _String?
10
+ prop :target, _String?
11
+ prop :title, _String?
12
+ prop :color, _String?(/\A[\w-]+\z/)
13
+
14
+ def view_template
15
+ href = @href.present? && safe_url(@href)
16
+ return if !href || @text.blank?
17
+
18
+ a(href:, target: @target, title: @title, data_color: @color) { @text }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,32 @@
1
+ module Trek
2
+ # Renders ProseMirror content (see Trek::Contentable) with the `prosemirror` gem.
3
+ #
4
+ # The schema is Tiptap's, with Trek's blocks. To add or replace node types:
5
+ #
6
+ # # config/initializers/trek.rb
7
+ # Rails.application.config.to_prepare do
8
+ # Trek::Content.schema = Trek::Content.default_schema.with(Content::ImageBlock)
9
+ # end
10
+ module Content
11
+ class << self
12
+ attr_writer :schema
13
+
14
+ def schema
15
+ @schema || (@default_schema ||= default_schema)
16
+ end
17
+
18
+ # Called after code reloading, as the default schema holds node type classes.
19
+ def clear_default_schema
20
+ @default_schema = nil
21
+ end
22
+
23
+ def default_schema
24
+ Prosemirror::Schema.tiptap(
25
+ case: :camel,
26
+ resolve_urls: LinkResolver.new,
27
+ on_invalid: ->(error) { Rails.error.report(error, handled: true) }
28
+ ).with(Paragraph, ListItem, BulletList, OrderedList, ImageBlock, PromptsBlock)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -7,13 +7,20 @@ module Trek
7
7
  before_action :set_mode, only: [:index]
8
8
  # rubocop:enable Rails/LexicallyScopedActionFilter
9
9
 
10
+ # The index's reorder form posts there
11
+ helper_method :reorder_path
12
+
10
13
  def reorder
11
14
  authorize!
12
15
  objects = reorderable_objects.index_by(&:id)
13
16
 
14
- reorder_params.each do |id, position|
15
- object = objects[id.to_i]
16
- object.update(position:) unless object.position == position
17
+ # Saving the positions one record at a time repeats acts_as_list's queries: Prosopite, in
18
+ # development and test, would take them for an N+1
19
+ without_n_plus_one_detection do
20
+ reorder_params.each do |id, position|
21
+ object = objects[id.to_i]
22
+ object.update(position:) unless object.position == position
23
+ end
17
24
  end
18
25
 
19
26
  redirect_to reorder_success_redirect, notice: reorder_notice
@@ -42,6 +49,10 @@ module Trek
42
49
  [:admin, *model_collection_route]
43
50
  end
44
51
 
52
+ def without_n_plus_one_detection(&)
53
+ defined?(Prosopite) ? Prosopite.pause(&) : yield
54
+ end
55
+
45
56
  def reorder_notice
46
57
  t("admin.#{model_collection}.reorder.success")
47
58
  end
@@ -20,12 +20,9 @@ module Trek
20
20
 
21
21
  # Browsers send no CSRF token; the endpoint only logs and reports, with no session nor user
22
22
  skip_forgery_protection
23
- # Rails 7.2+
24
- if respond_to?(:rate_limit)
25
- rate_limit to: 60, within: 1.minute, with: -> { head :too_many_requests }
26
- # Against a flood from many addresses
27
- rate_limit to: 600, within: 1.minute, by: -> { "all" }, with: -> { head :too_many_requests }
28
- end
23
+ rate_limit to: 60, within: 1.minute, with: -> { head :too_many_requests }
24
+ # Against a flood from many addresses
25
+ rate_limit to: 600, within: 1.minute, by: -> { "all" }, with: -> { head :too_many_requests }
29
26
 
30
27
  def create
31
28
  body = request.body.read(MAX_BODY + 1).to_s
@@ -1,6 +1,9 @@
1
1
  module Trek
2
2
  module Panels
3
3
  class BaseController < Trek::BaseController
4
+ # Stands in for a page in the link and prompt panels' choices when the current
5
+ # href isn't a page's global id (another site, a path, a mailto:…), so the select keeps it
6
+ HrefPlaceholder = Data.define(:to_global_id, :title)
4
7
  end
5
8
  end
6
9
  end
@@ -29,7 +29,7 @@ module Trek
29
29
 
30
30
  def set_pages
31
31
  @pages = []
32
- @pages << OpenStruct.new(to_global_id: object_params[:href], title: object_params[:href]) if object_params[:href] && !object_params[:href].start_with?("gid")
32
+ @pages << HrefPlaceholder.new(to_global_id: object_params[:href], title: object_params[:href]) if object_params[:href] && !object_params[:href].start_with?("gid")
33
33
  @pages += Page.alpha_ordered if defined?(Page)
34
34
  end
35
35
 
@@ -29,7 +29,7 @@ module Trek
29
29
 
30
30
  def set_pages
31
31
  @pages = []
32
- @pages << OpenStruct.new(to_global_id: object_params[:href], title: object_params[:href]) if object_params[:href] && !object_params[:href].start_with?("gid")
32
+ @pages << HrefPlaceholder.new(to_global_id: object_params[:href], title: object_params[:href]) if object_params[:href] && !object_params[:href].start_with?("gid")
33
33
  @pages += Page.alpha_ordered if defined?(Page)
34
34
  end
35
35
 
@@ -0,0 +1,11 @@
1
+ module Trek
2
+ # The URL of an uploaded image's thumbnail: through Shrine's derivation endpoint when the uploader loads
3
+ # it (the generated ImageUploader comments it out), or the image itself otherwise
4
+ module ThumbnailHelper
5
+ module_function
6
+
7
+ def thumbnail_url(file, width, height)
8
+ file.respond_to?(:derivation_url) ? file.derivation_url(:thumbnail, width, height) : file.url
9
+ end
10
+ end
11
+ end
@@ -8,16 +8,20 @@ module Trek
8
8
  content.is_a?(Hash) ? content : JSON.parse(content)
9
9
  end
10
10
 
11
- def formatted_content
11
+ # The content as a Prosemirror::Document, built with Trek::Content.schema. Problems found while parsing
12
+ # or rendering it are reported with the record in their context (see Trek::Content::Document).
13
+ def content_document
12
14
  return if content.blank?
13
15
 
14
- Prosemirror.new.format_content(parsed_content)
16
+ Trek::Content::Document.parse(self, parsed_content)
15
17
  end
16
18
 
17
- def content_text
18
- return if content.blank?
19
+ def formatted_content
20
+ content_document&.to_html
21
+ end
19
22
 
20
- extract_text(parsed_content)
23
+ def content_text
24
+ content_document&.text_content
21
25
  end
22
26
 
23
27
  def prosemirror_content?
@@ -27,14 +31,5 @@ module Trek
27
31
  else false
28
32
  end
29
33
  end
30
-
31
- private
32
-
33
- def extract_text(node)
34
- return node["text"].to_s if node["type"] == "text"
35
- return "" unless node["content"]
36
-
37
- node["content"].map { |child| extract_text(child) }.join
38
- end
39
34
  end
40
35
  end
@@ -21,9 +21,10 @@ module Trek
21
21
  super || build_page(parent: default_parent_page)
22
22
  end
23
23
 
24
+ # The admin links to records by id, the site by slug.
24
25
  def to_param
25
26
  # TODO: find a better way?
26
- if caller.to_s.include?("admin")
27
+ if called_from_admin?
27
28
  id || super
28
29
  else
29
30
  page&.slug || super
@@ -96,5 +97,13 @@ module Trek
96
97
  def apply_default_parent_page
97
98
  page.parent = default_parent_page
98
99
  end
100
+
101
+ # Whether an admin file (controller, view, layout, mailer…) is in the call stack. Trek::AdminIpAllowlist
102
+ # doesn't count: a middleware, it sits in the stack of every request, the site's included.
103
+ def called_from_admin?
104
+ caller_locations.any? do |location|
105
+ location.path.include?("admin") && !location.path.end_with?("/lib/trek/admin_ip_allowlist.rb")
106
+ end
107
+ end
99
108
  end
100
109
  end
@@ -1,4 +1,4 @@
1
- h1.c-trek--layout-panel-title = t(".title")
1
+ h1.c-trek--layout-panel-title = t("admin.panels.images.form.title")
2
2
 
3
3
  = form_with model: @object, scope: :image, url: %i[admin panels images] do |f|
4
4
  = render Trek::Form::ErrorsComponent.new(object: @object)
@@ -11,7 +11,7 @@
11
11
  credit=@object.credit
12
12
  size=@object.size
13
13
  file_data=@object.file_data
14
- file_url=@object.file.derivation_url(:thumbnail, 300, 150)
14
+ file_url=Trek::ThumbnailHelper.thumbnail_url(@object.file, 300, 150)
15
15
  text=@object.text
16
16
  )
17
17
  - else
@@ -1,4 +1,4 @@
1
- h1.c-trek--layout-panel-title = t(".title")
1
+ h1.c-trek--layout-panel-title = t("admin.panels.links.form.title")
2
2
 
3
3
  = form_with model: @object, scope: :link, url: %i[admin panels links] do |f|
4
4
  = render Trek::Form::ErrorsComponent.new(object: @object)
@@ -1,4 +1,4 @@
1
- h1.c-trek--layout-panel-title = t(".title")
1
+ h1.c-trek--layout-panel-title = t("admin.panels.prompts.form.title")
2
2
 
3
3
  = form_with model: @object, scope: :prompt, url: %i[admin panels prompts] do |f|
4
4
  = render Trek::Form::ErrorsComponent.new(object: @object)
@@ -1,5 +1,28 @@
1
1
  ---
2
2
  en:
3
+ activemodel:
4
+ attributes:
5
+ trek/content_editor/image:
6
+ alt: Alternative text
7
+ credit: Credit
8
+ file: Image
9
+ size: Size
10
+ text: Caption
11
+ trek/content_editor/link:
12
+ href: Address
13
+ target: Open in
14
+ text: Text
15
+ title: Title
16
+ trek/content_editor/prompt:
17
+ href: Address
18
+ target: Open in
19
+ text: Text
20
+ title: Title
21
+ options:
22
+ trek/content_editor/image:
23
+ size:
24
+ default: As wide as the text
25
+ larger: Wider
3
26
  activerecord:
4
27
  attributes:
5
28
  audit_log:
@@ -1,5 +1,28 @@
1
1
  ---
2
2
  fr:
3
+ activemodel:
4
+ attributes:
5
+ trek/content_editor/image:
6
+ alt: Texte alternatif
7
+ credit: Crédit
8
+ file: Image
9
+ size: Taille
10
+ text: Légende
11
+ trek/content_editor/link:
12
+ href: Adresse
13
+ target: Ouvrir dans
14
+ text: Texte
15
+ title: Titre
16
+ trek/content_editor/prompt:
17
+ href: Adresse
18
+ target: Ouvrir dans
19
+ text: Texte
20
+ title: Titre
21
+ options:
22
+ trek/content_editor/image:
23
+ size:
24
+ default: Comme la colonne de texte
25
+ larger: Plus large
3
26
  activerecord:
4
27
  attributes:
5
28
  audit_log:
@@ -6,8 +6,8 @@ This guide takes you from an empty directory to a working Rails application with
6
6
 
7
7
  Make sure the following are installed:
8
8
 
9
- - Ruby 3.1+
10
- - Rails 7.0+
9
+ - Ruby 3.3+
10
+ - Rails 8.0+
11
11
  - PostgreSQL 12+
12
12
  - Node 22+
13
13
  - Yarn 4.x
@@ -19,7 +19,7 @@ Check your Rails version:
19
19
  rails -v
20
20
  ```
21
21
 
22
- If it's older than 7.0, run `gem install rails` to upgrade.
22
+ If it's older than 8.0, run `gem install rails` to upgrade.
23
23
 
24
24
  Check your Yarn version:
25
25
 
@@ -7,7 +7,8 @@ Utilities for rich text stored as ProseMirror JSON in a `content` column — the
7
7
  | Method | Returns |
8
8
  | --- | --- |
9
9
  | `parsed_content` | the content as a hash (parsing JSON strings if needed) |
10
- | `formatted_content` | safe HTML, rendered through the [ProseMirror pipeline](/reference/formatters) |
10
+ | `content_document` | the content as a `Prosemirror::Document`, to query or render it |
11
+ | `formatted_content` | safe HTML, rendered as described in [Rich text rendering](/reference/formatters#rich-text-rendering) |
11
12
  | `content_text` | plain text extracted from all text nodes |
12
13
  | `prosemirror_content?` | whether `content` is a valid ProseMirror document |
13
14
 
@@ -15,7 +15,7 @@ module Admin
15
15
  end
16
16
  ```
17
17
 
18
- - **Panel controllers** (`Trek::Panels::*`) — support endpoints used by the admin UI: image uploads (Uppy), link insertion and content editor prompts.
18
+ - **Panel controllers** (`Trek::Panels::*`) — support endpoints used by the admin UI: image uploads (Uppy), link insertion and content editor prompts. The installer generates their `Admin::Panels::*` subclasses in the app, which the admin routes point to: Trek's engine is isolated, so its own controllers only see the engine's routes, not the app's.
19
19
 
20
20
  ## Mixins
21
21