diff options
Diffstat (limited to 'app/helpers')
| -rw-r--r-- | app/helpers/admin_helper.rb | 6 | ||||
| -rw-r--r-- | app/helpers/link_helper.rb | 25 |
2 files changed, 25 insertions, 6 deletions
diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 389f6dcb..e5c3d5c8 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | module AdminHelper | 1 | module AdminHelper |
| 2 | 2 | ||
| 3 | def language_selector | 3 | def language_selector |
| 4 | case I18n.locale | 4 | case I18n.locale |
| 5 | when :de | 5 | when :de |
| 6 | link_to raw('<span class="inactive">English</span>'), url_for(:overwrite_params => {:locale => :en}) | 6 | link_to raw('<span class="inactive">English</span>'), url_for(params.permit!.to_h.merge('locale' => 'en')) |
| 7 | when :en | 7 | when :en |
| 8 | link_to raw('<span class="inactive">Deutsch</span>'), url_for(:overwrite_params => {:locale => :de}) | 8 | link_to raw('<span class="inactive">Deutsch</span>'), url_for(params.permit!.to_h.merge('locale' => 'de')) |
| 9 | end | 9 | end |
| 10 | end | 10 | end |
| 11 | end | 11 | end |
diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb index 85d8fbe4..39ec4958 100644 --- a/app/helpers/link_helper.rb +++ b/app/helpers/link_helper.rb | |||
| @@ -45,9 +45,28 @@ module LinkHelper | |||
| 45 | "Locked by #{@node.lock_owner.login}\n" + | 45 | "Locked by #{@node.lock_owner.login}\n" + |
| 46 | "Last modified #{@page.updated_at.to_s(:db)}" | 46 | "Last modified #{@page.updated_at.to_s(:db)}" |
| 47 | 47 | ||
| 48 | link_to( | 48 | link_to 'Unlock', safe_path(:unlock_node_path, @node), :method => :put, :data => { :confirm => message } |
| 49 | 'Unlock', 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 | |||
| 60 | def content_path(page_path = nil, options = {}) | ||
| 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 | ||
| 50 | ) | 69 | ) |
| 51 | end | 70 | end |
| 52 | 71 | ||
| 53 | end | 72 | end |
