summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-06-26 05:19:28 +0200
committererdgeist <erdgeist@erdgeist.org>2026-06-26 05:19:28 +0200
commita1ddc25da0d2aa79a4d9216ef7792f26233bd38e (patch)
tree4d53e6ccb631e588c9e1d25c7a2dc5ef2ef44135 /app
parentfa0ccc43010297c0c10e3075095c0a9171989498 (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')
-rw-r--r--app/helpers/link_helper.rb35
-rw-r--r--app/helpers/nodes_helper.rb2
-rw-r--r--app/models/locked_by_another_user.rb1
-rw-r--r--app/models/node.rb13
-rw-r--r--app/views/admin/_recent_changes.html.erb2
-rw-r--r--app/views/content/_search.html.erb2
-rw-r--r--app/views/content/_tags.html.erb2
-rw-r--r--app/views/layouts/application.html.erb4
8 files changed, 21 insertions, 40 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 @@
1module LinkHelper 1module 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
72end 49end
diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb
index 204ad8a..c739ccd 100644
--- a/app/helpers/nodes_helper.rb
+++ b/app/helpers/nodes_helper.rb
@@ -31,7 +31,7 @@ module NodesHelper
31 31
32 def event_information 32 def event_information
33 if @node.event 33 if @node.event
34 "#{@node.event.start_time.to_s(:db)} - #{@node.event.end_time.to_s(:db)} > " \ 34 "#{@node.event.start_time.to_fs(:db)} - #{@node.event.end_time.to_fs(:db)} > " \
35 "#{link_to 'show', event_path(@node.event)} " \ 35 "#{link_to 'show', event_path(@node.event)} " \
36 "#{link_to 'edit', edit_event_path(@node.event)}" 36 "#{link_to 'edit', edit_event_path(@node.event)}"
37 else 37 else
diff --git a/app/models/locked_by_another_user.rb b/app/models/locked_by_another_user.rb
new file mode 100644
index 0000000..6f9e272
--- /dev/null
+++ b/app/models/locked_by_another_user.rb
@@ -0,0 +1 @@
class LockedByAnotherUser < StandardError; end
diff --git a/app/models/node.rb b/app/models/node.rb
index f7a70d0..41c3867 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -73,7 +73,7 @@ class Node < ApplicationRecord
73 raise( 73 raise(
74 LockedByAnotherUser, 74 LockedByAnotherUser,
75 "Page is locked by another user who is working on it! " \ 75 "Page is locked by another user who is working on it! " \
76 "Last modification: #{draft.updated_at.to_s(:db)}" 76 "Last modification: #{draft.updated_at.to_fs(:db)}"
77 ) 77 )
78 else 78 else
79 lock_for! current_user 79 lock_for! current_user
@@ -211,6 +211,13 @@ class Node < ApplicationRecord
211 self.created_at < new_id_format_date ? unique_path : id 211 self.created_at < new_id_format_date ? unique_path : id
212 end 212 end
213 213
214 # TODO: restore full-text search once PostgreSQL is upgraded.
215 # The tsvector/plpgsql approach requires PostgreSQL 10+ with plpgsql available.
216 # For now, search is disabled to unblock the Rails 7.2 upgrade.
217 def self.search(term, _ = {})
218 none
219 end
220
214 protected 221 protected
215 def lock_for! current_user 222 def lock_for! current_user
216 self.lock_owner = current_user 223 self.lock_owner = current_user
@@ -255,7 +262,3 @@ class Node < ApplicationRecord
255 end 262 end
256 end 263 end
257end 264end
258
259class LockedByAnotherUser < StandardError; end
260
261
diff --git a/app/views/admin/_recent_changes.html.erb b/app/views/admin/_recent_changes.html.erb
index 300d088..88b5e93 100644
--- a/app/views/admin/_recent_changes.html.erb
+++ b/app/views/admin/_recent_changes.html.erb
@@ -13,7 +13,7 @@
13 <td><%= truncated_title_for_node node %></td> 13 <td><%= truncated_title_for_node node %></td>
14 <td><%= node.unique_name %></td> 14 <td><%= node.unique_name %></td>
15 <td><%= node.draft.user.login rescue "" %></td> 15 <td><%= node.draft.user.login rescue "" %></td>
16 <td><%= node.updated_at.to_s(:db) %></td> 16 <td><%= node.updated_at.to_fs(:db) %></td>
17 <td class="actions"> 17 <td class="actions">
18 <%= link_to 'Show', node_path(node) %> 18 <%= link_to 'Show', node_path(node) %>
19 <%= link_to "Revisions", revision_path(:id => node.id) %> 19 <%= link_to "Revisions", revision_path(:id => node.id) %>
diff --git a/app/views/content/_search.html.erb b/app/views/content/_search.html.erb
index f732fca..aa91424 100644
--- a/app/views/content/_search.html.erb
+++ b/app/views/content/_search.html.erb
@@ -1,3 +1,3 @@
1<%= form_tag safe_path(:search_path), :method => 'get' do %> 1<%= form_tag search_path, :method => 'get' do %>
2 <div><%= text_field_tag :search_term, params[:search_term], :placeholder => 'suchen', :type => 'search' %></div> 2 <div><%= text_field_tag :search_term, params[:search_term], :placeholder => 'suchen', :type => 'search' %></div>
3<% end %> 3<% end %>
diff --git a/app/views/content/_tags.html.erb b/app/views/content/_tags.html.erb
index 387f51c..f0e7210 100644
--- a/app/views/content/_tags.html.erb
+++ b/app/views/content/_tags.html.erb
@@ -3,7 +3,7 @@
3 <h2>Tags</h2> 3 <h2>Tags</h2>
4 <ul class="teasertext"> 4 <ul class="teasertext">
5 <% @page.tags.each do |tag| %> 5 <% @page.tags.each do |tag| %>
6 <li><%= link_to tag.name, safe_path(:tag_path, tag.name) %></li> 6 <li><%= link_to tag.name, tag_path(tag.name) %></li>
7 <% end %> 7 <% end %>
8 </ul> 8 </ul>
9</div> 9</div>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 84dcdc6..c5cbf14 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -52,8 +52,8 @@
52 <div class="main_navigation"> 52 <div class="main_navigation">
53 <h2>Admin</h2> 53 <h2>Admin</h2>
54 <ul> 54 <ul>
55 <li><%= link_to raw('<span class="inactive admin_edit_link">⚙️ Overview</span>'), safe_path(:admin_path) %></li> 55 <li><%= link_to raw('<span class="inactive admin_edit_link">⚙️ Overview</span>'), admin_path %></li>
56 <li><%= link_to raw('<span class="inactive admin_edit_link">✎ Edit</span>'), safe_path(:node_path, @page.node) %></li> 56 <li><%= link_to raw('<span class="inactive admin_edit_link">✎ Edit</span>'), node_path(@page.node) %></li>
57 </ul> 57 </ul>
58 </div> 58 </div>
59 <% end %> 59 <% end %>