diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-25 04:35:21 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-25 04:35:21 +0200 |
| commit | 5f8cc4fa269dadc895d99eec9ef3a82b17c5890a (patch) | |
| tree | 048ffe4ef9e6b147eddbe6472312b72267d268d9 /app/helpers/link_helper.rb | |
| parent | f7a5944a1f44ede9881d368a36eb9f7d82d6ab69 (diff) | |
Rails 4.2 view fixes
- Replace :confirm => with :data => { :confirm => } in all link_to calls
- Fix link_to_path helper: use content_path named route instead of hash-style routing
- Fix admin/_menu.html.erb: use named routes for logout and admin index
- Fix admin layout: load jquery/jquery_ujs before jquery-ui, remove duplicate jQuery 1.3.2
- Add csrf_meta_tags to admin layout
Diffstat (limited to 'app/helpers/link_helper.rb')
| -rw-r--r-- | app/helpers/link_helper.rb | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb index 29c58f0..85d8fbe 100644 --- a/app/helpers/link_helper.rb +++ b/app/helpers/link_helper.rb | |||
| @@ -14,28 +14,26 @@ module LinkHelper | |||
| 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? | ||
| 18 | |||
| 17 | if params[:page_path] | 19 | if params[:page_path] |
| 18 | page_path = params[:page_path].is_a?(Array) ? params[:page_path].join("/") : params[:page_path] | 20 | page_path = params[:page_path].is_a?(Array) ? params[:page_path].join("/") : params[:page_path] |
| 19 | active = (page_path == path.sub(/^\//, "")) | 21 | active = (page_path == path.sub(/^\//, "")) |
| 20 | end | 22 | end |
| 21 | 23 | ||
| 22 | active_class = active ? {:class => 'active'} : {:class => 'inactive'} | 24 | active_class = active ? {:class => 'active'} : {:class => 'inactive'} |
| 23 | 25 | ||
| 24 | html_options = html_options.merge(active_class) | 26 | html_options = html_options.merge(active_class) |
| 25 | 27 | ||
| 26 | params[:locale] ||= I18n.locale | 28 | locale = params[:locale] || I18n.locale |
| 27 | 29 | ||
| 28 | link_to( | 30 | link_to( |
| 29 | title, { | 31 | title, |
| 30 | :controller => :content, | 32 | content_path(path.sub(/^\//, ""), :locale => locale), |
| 31 | :action => :render_page, | ||
| 32 | :locale => params[:locale], | ||
| 33 | :page_path => (path.sub(/^\//, "") rescue "") | ||
| 34 | }, | ||
| 35 | html_options | 33 | html_options |
| 36 | ) | 34 | ) |
| 37 | end | 35 | end |
| 38 | 36 | ||
| 39 | def selected? controller_name | 37 | def selected? controller_name |
| 40 | if params[:controller] == controller_name | 38 | if params[:controller] == controller_name |
| 41 | return :class => "selected" | 39 | return :class => "selected" |
| @@ -48,7 +46,7 @@ module LinkHelper | |||
| 48 | "Last modified #{@page.updated_at.to_s(:db)}" | 46 | "Last modified #{@page.updated_at.to_s(:db)}" |
| 49 | 47 | ||
| 50 | link_to( | 48 | link_to( |
| 51 | 'Unlock', unlock_node_path(@node), :method => :put, :confirm => message | 49 | 'Unlock', unlock_node_path(@node), :method => :put, :data => { :confirm => message } |
| 52 | ) | 50 | ) |
| 53 | end | 51 | end |
| 54 | 52 | ||
