From 5f8cc4fa269dadc895d99eec9ef3a82b17c5890a Mon Sep 17 00:00:00 2001 From: erdgeist Date: Thu, 25 Jun 2026 04:35:21 +0200 Subject: 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 --- app/helpers/link_helper.rb | 26 ++++++++++++-------------- app/views/admin/_drafts.html.erb | 4 ++-- app/views/admin/_menu.html.erb | 6 +++--- app/views/assets/index.html.erb | 4 ++-- app/views/events/index.html.erb | 4 ++-- app/views/layouts/admin.html.erb | 3 ++- app/views/menu_items/index.html.erb | 4 ++-- app/views/nodes/edit.html.erb | 2 +- app/views/occurrences/index.html.erb | 4 ++-- app/views/pages/index.html.erb | 2 +- app/views/revisions/index.html.erb | 2 +- app/views/users/_user.html.erb | 4 ++-- 12 files changed, 32 insertions(+), 33 deletions(-) (limited to 'app') 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 end def link_to_path title, path, html_options = {} + return "" if path.nil? + if params[:page_path] page_path = params[:page_path].is_a?(Array) ? params[:page_path].join("/") : params[:page_path] active = (page_path == path.sub(/^\//, "")) end - + active_class = active ? {:class => 'active'} : {:class => 'inactive'} - + html_options = html_options.merge(active_class) - - params[:locale] ||= I18n.locale - - link_to( - title, { - :controller => :content, - :action => :render_page, - :locale => params[:locale], - :page_path => (path.sub(/^\//, "") rescue "") - }, + + locale = params[:locale] || I18n.locale + + link_to( + title, + content_path(path.sub(/^\//, ""), :locale => locale), html_options ) end - + def selected? controller_name if params[:controller] == controller_name return :class => "selected" @@ -48,7 +46,7 @@ module LinkHelper "Last modified #{@page.updated_at.to_s(:db)}" link_to( - 'Unlock', unlock_node_path(@node), :method => :put, :confirm => message + 'Unlock', unlock_node_path(@node), :method => :put, :data => { :confirm => message } ) end diff --git a/app/views/admin/_drafts.html.erb b/app/views/admin/_drafts.html.erb index 58b946b..2036d12 100644 --- a/app/views/admin/_drafts.html.erb +++ b/app/views/admin/_drafts.html.erb @@ -17,9 +17,9 @@ <%= link_to 'Show', node_path(draft.node) %> <%= link_to "Revisions", revision_path(draft.node.id) %> - <%= link_to "Publish", publish_node_path(draft.node), :method => :put, :confirm => "Do you really want to publish?" %> + <%= link_to "Publish", publish_node_path(draft.node), :method => :put, :data => { :confirm => "Do you really want to publish?" } %> <% end %> - \ No newline at end of file + diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index e8b39ce..3188d94 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -1,7 +1,7 @@ <%= language_selector %> -<%= link_to 'Logout', :controller => :sessions, :action => :destroy %> -<%= link_to 'Overview', :controller => :admin, :action => 'index' %> +<%= link_to 'Logout', logout_path, :method => :delete %> +<%= link_to 'Overview', admin_path %> <%= link_to 'Nodes', nodes_path, selected?('nodes') %> <%= link_to 'Assets', assets_path, selected?('assets') %> <%= link_to 'User', users_path, selected?('users') %> -<%= link_to 'Navigation', menu_items_path, selected?('menu_items') %> >  \ No newline at end of file +<%= link_to 'Navigation', menu_items_path, selected?('menu_items') %> >  diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb index fc7c029..e7ef313 100644 --- a/app/views/assets/index.html.erb +++ b/app/views/assets/index.html.erb @@ -15,7 +15,7 @@ <%= asset.upload.content_type %> <%= link_to 'Show', asset %> <%= link_to 'Edit', edit_asset_path(asset) %> - <%= link_to 'Destroy', asset, :confirm => 'Are you sure?', :method => :delete %> + <%= link_to 'Destroy', asset, :data => { :confirm => 'Are you sure?' }, :method => :delete %> <% end %> - \ No newline at end of file + diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index c1b5b48..93c95fa 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -26,11 +26,11 @@ <%=h event.node_id %> <%= link_to 'Show', event %> <%= link_to 'Edit', edit_event_path(event) %> - <%= link_to 'Destroy', event, :confirm => 'Are you sure?', :method => :delete %> + <%= link_to 'Destroy', event, :data => { :confirm => 'Are you sure?' }, :method => :delete %> <% end %>
-<%= link_to 'New event', new_event_path %> \ No newline at end of file +<%= link_to 'New event', new_event_path %> diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index 9f36021..e64850b 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -4,9 +4,10 @@ + <%= csrf_meta_tags %> <%= "#{params[:controller]} | #{params[:action]}" %> - <%= javascript_include_tag 'jquery-1.3.2.min' %> + <%= javascript_include_tag 'jquery', 'jquery_ujs' %> <%= javascript_include_tag 'jquery-ui-1.7.2.custom.min' %> <%= javascript_include_tag 'jquery.hotkeys' %> <%= javascript_include_tag 'tiny_mce/jquery.tinymce.js' %> diff --git a/app/views/menu_items/index.html.erb b/app/views/menu_items/index.html.erb index 123a07a..7d0ce62 100644 --- a/app/views/menu_items/index.html.erb +++ b/app/views/menu_items/index.html.erb @@ -18,9 +18,9 @@ "Delete", menu_item_path(menu_item), :method => :delete, - :confirm => "Are you sure?" + :data => { :confirm => "Are you sure?" } ) %> <% end %> - \ No newline at end of file + diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index d40d4e7..64884cf 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb @@ -2,7 +2,7 @@ <%= link_to 'metadata', '#', :id => 'button', :class => "unselected" %> <%= link_to 'Show', @node %> <%= link_to 'Preview', preview_page_path(@draft) %> - <%= link_to 'Publish', publish_node_path, :method => :put, :confirm => "Publish this draft?" %> + <%= link_to 'Publish', publish_node_path, :method => :put, :data => { :confirm => "Publish this draft?" } %> <%= link_to 'Revisions', node_revisions_path(@node) %> <% end %> diff --git a/app/views/occurrences/index.html.erb b/app/views/occurrences/index.html.erb index 06dbf07..7b8ffb8 100644 --- a/app/views/occurrences/index.html.erb +++ b/app/views/occurrences/index.html.erb @@ -18,11 +18,11 @@ <%=h occurrence.event_id %> <%= link_to 'Show', occurrence %> <%= link_to 'Edit', edit_occurrence_path(occurrence) %> - <%= link_to 'Destroy', occurrence, :confirm => 'Are you sure?', :method => :delete %> + <%= link_to 'Destroy', occurrence, :data => { :confirm => 'Are you sure?' }, :method => :delete %> <% end %>
-<%= link_to 'New occurrence', new_occurrence_path %> \ No newline at end of file +<%= link_to 'New occurrence', new_occurrence_path %> diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb index 06cb16c..4b28c9b 100644 --- a/app/views/pages/index.html.erb +++ b/app/views/pages/index.html.erb @@ -12,7 +12,7 @@ <%=h page.title %> <%= link_to 'Show', content_path(:page_path => page.node.unique_path) %> <%= link_to 'Edit', edit_page_path(page) %> - <%= link_to 'Destroy', page, :confirm => 'Are you sure?', :method => :delete %> + <%= link_to 'Destroy', page, :data => { :confirm => 'Are you sure?' }, :method => :delete %> <% end %> diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb index 306f9ea..e038ed2 100644 --- a/app/views/revisions/index.html.erb +++ b/app/views/revisions/index.html.erb @@ -31,7 +31,7 @@ 'restore', restore_node_revision_path(@node, page), :method => :put, - :confirm => "Restore this revision?" + :data => { :confirm => "Restore this revision?" } ) %> diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index 8117bcd..9987e31 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -11,9 +11,9 @@ "destroy", user_path(user), :method => :delete, - :confirm => "Do you really want to delete user #{user.login}?" + :data => { :confirm => "Do you really want to delete user #{user.login}?" } ) %> <% end %> -<% end %> \ No newline at end of file +<% end %> -- cgit v1.3