diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-26 05:19:28 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-26 05:19:28 +0200 |
| commit | a1ddc25da0d2aa79a4d9216ef7792f26233bd38e (patch) | |
| tree | 4d53e6ccb631e588c9e1d25c7a2dc5ef2ef44135 /app/helpers/link_helper.rb | |
| parent | fa0ccc43010297c0c10e3075095c0a9171989498 (diff) | |
Stage 5 fixes: RouteWithParams removal, Globalize fallbacks, search stub, to_s(:db) → to_fs(:db), LockedByAnotherUser autoload, test environment config
- Remove safe_path helper and content_path shim from link_helper.rb
- Update all safe_path call sites in views to use named route helpers directly
- Fix Globalize fallbacks via config.i18n.fallbacks in application.rb, remove i18n initializer
- Stub Node.search returning none (search disabled pending PostgreSQL upgrade)
- Replace to_s(:db) with to_fs(:db) in node.rb, nodes_helper.rb, link_helper.rb, admin view
- Move LockedByAnotherUser to app/models/locked_by_another_user.rb for Zeitwerk autoloading
- Fix config/environments/test.rb: config.assets removed, cache_classes → enable_reloading,
test_order removed, minitest pinned to ~> 5.25
- Fix config/environments/development.rb: cache_classes → enable_reloading
- Park search vector migration in doc/ pending PostgreSQL and plpgsql availability
Diffstat (limited to 'app/helpers/link_helper.rb')
| -rw-r--r-- | app/helpers/link_helper.rb | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb index 39ec495..cb13c8d 100644 --- a/app/helpers/link_helper.rb +++ b/app/helpers/link_helper.rb | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | module LinkHelper | 1 | module LinkHelper |
| 2 | 2 | ||
| 3 | def content_path_helper path_array | 3 | def content_path_helper path_array |
| 4 | url_for( | 4 | url_for( |
| 5 | :controller => :content, | 5 | :controller => :content, |
| @@ -8,11 +8,11 @@ module LinkHelper | |||
| 8 | :page_path => path_array | 8 | :page_path => path_array |
| 9 | ) | 9 | ) |
| 10 | end | 10 | end |
| 11 | 11 | ||
| 12 | def content_url_helper path_array | 12 | def content_url_helper path_array |
| 13 | request.protocol + request.host_with_port + content_path_helper(path_array) | 13 | request.protocol + request.host_with_port + content_path_helper(path_array) |
| 14 | end | 14 | end |
| 15 | 15 | ||
| 16 | def link_to_path title, path, html_options = {} | 16 | def link_to_path title, path, html_options = {} |
| 17 | return "" if path.nil? | 17 | return "" if path.nil? |
| 18 | 18 | ||
| @@ -22,9 +22,7 @@ module LinkHelper | |||
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | active_class = active ? {:class => 'active'} : {:class => 'inactive'} | 24 | active_class = active ? {:class => 'active'} : {:class => 'inactive'} |
| 25 | |||
| 26 | html_options = html_options.merge(active_class) | 25 | html_options = html_options.merge(active_class) |
| 27 | |||
| 28 | locale = params[:locale] || I18n.locale | 26 | locale = params[:locale] || I18n.locale |
| 29 | 27 | ||
| 30 | link_to( | 28 | link_to( |
| @@ -39,34 +37,13 @@ module LinkHelper | |||
| 39 | return :class => "selected" | 37 | return :class => "selected" |
| 40 | end | 38 | end |
| 41 | end | 39 | end |
| 42 | 40 | ||
| 43 | def unlock_link | 41 | def unlock_link |
| 44 | message = "Are you sure you want to unlock?\n" + | 42 | message = "Are you sure you want to unlock?\n" + |
| 45 | "Locked by #{@node.lock_owner.login}\n" + | 43 | "Locked by #{@node.lock_owner.login}\n" + |
| 46 | "Last modified #{@page.updated_at.to_s(:db)}" | 44 | "Last modified #{@page.updated_at.to_fs(:db)}" |
| 47 | |||
| 48 | link_to 'Unlock', safe_path(:unlock_node_path, @node), :method => :put, :data => { :confirm => message } | ||
| 49 | end | ||
| 50 | |||
| 51 | # Rails 6.1 workaround: content_path named helper returns RouteWithParams | ||
| 52 | # when called from within a catch-all glob route request context. | ||
| 53 | # Rails 6.1 workaround: named route helpers return RouteWithParams when called | ||
| 54 | # from within a catch-all glob route request context. | ||
| 55 | # Remove this method when upgrading to Rails 7.0+, where this is fixed. | ||
| 56 | def safe_path(name, *args) | ||
| 57 | Rails.application.routes.url_helpers.send(name, *args) | ||
| 58 | end | ||
| 59 | 45 | ||
| 60 | def content_path(page_path = nil, options = {}) | 46 | link_to 'Unlock', unlock_node_path(@node), :method => :put, :data => { :confirm => message } |
| 61 | if page_path.is_a?(Hash) | ||
| 62 | options = page_path | ||
| 63 | page_path = options.delete(:page_path) | ||
| 64 | end | ||
| 65 | options[:locale] ||= params[:locale] || I18n.locale | ||
| 66 | Rails.application.routes.url_helpers.content_path( | ||
| 67 | Array(page_path).join("/").sub(/^\//, ""), | ||
| 68 | options | ||
| 69 | ) | ||
| 70 | end | 47 | end |
| 71 | 48 | ||
| 72 | end | 49 | end |
