From 811bb04649365b0faaa00b1e0810bb101a4d19b1 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Fri, 26 Jun 2026 13:40:55 +0200 Subject: Stage 5 click-testing fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix link_to :method → button_to for all PUT/DELETE actions - Add button_to CSS reset to admin.css for visual consistency - Fix admin layout: replace broken jquery/jquery_ujs pipeline refs with admin_bundle via sprockets; add sprockets-rails, jquery-ui-rails gems - Add app/assets/javascripts/admin_bundle.js pipeline manifest - Fix event_information helper: use safe_join to avoid double-escaping - Fix nodes_helper: to_s(:db) → to_fs(:db) for event times - Fix revisions view: eliminate nested forms; diff button uses vanilla JS to collect radio button values before POST - Fix config/environments/development.rb and test.rb: cache_classes → enable_reloading - Add routing_filter_rails71_patch.rb version guard - Move LockedByAnotherUser to own file for Zeitwerk autoloading - Fix Globalize fallbacks via config.i18n.fallbacks in application.rb --- app/assets/config/manifest.js | 1 + app/assets/javascripts/admin_bundle.js | 5 + app/assets/javascripts/jquery.hotkeys.js | 244 +++++++++++++++++++++++++++++++ app/helpers/link_helper.rb | 12 +- app/helpers/nodes_helper.rb | 16 +- app/views/admin/_drafts.html.erb | 2 +- app/views/admin/_menu.html.erb | 2 +- app/views/assets/index.html.erb | 2 +- app/views/events/index.html.erb | 2 +- app/views/layouts/admin.html.erb | 5 +- app/views/menu_items/index.html.erb | 9 +- app/views/nodes/edit.html.erb | 2 +- app/views/occurrences/index.html.erb | 2 +- app/views/pages/index.html.erb | 2 +- app/views/revisions/index.html.erb | 38 +++-- app/views/users/_user.html.erb | 9 +- 16 files changed, 308 insertions(+), 45 deletions(-) create mode 100644 app/assets/javascripts/admin_bundle.js create mode 100755 app/assets/javascripts/jquery.hotkeys.js (limited to 'app') diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index e69de29..56d7f6d 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -0,0 +1 @@ +//= link admin_bundle.js diff --git a/app/assets/javascripts/admin_bundle.js b/app/assets/javascripts/admin_bundle.js new file mode 100644 index 0000000..687266c --- /dev/null +++ b/app/assets/javascripts/admin_bundle.js @@ -0,0 +1,5 @@ +//= require jquery +//= require jquery_ujs +//= require jquery-ui +//= require jquery.hotkeys +//= require_self diff --git a/app/assets/javascripts/jquery.hotkeys.js b/app/assets/javascripts/jquery.hotkeys.js new file mode 100755 index 0000000..9a8f2de --- /dev/null +++ b/app/assets/javascripts/jquery.hotkeys.js @@ -0,0 +1,244 @@ +/* +(c) Copyrights 2007 - 2008 + +Original idea by by Binny V A, http://www.openjs.com/scripts/events/keyboard_shortcuts/ + +jQuery Plugin by Tzury Bar Yochay +tzury.by@gmail.com +http://evalinux.wordpress.com +http://facebook.com/profile.php?id=513676303 + +Project's sites: +http://code.google.com/p/js-hotkeys/ +http://github.com/tzuryby/hotkeys/tree/master + +License: same as jQuery license. + +USAGE: + // simple usage + $(document).bind('keydown', 'Ctrl+c', function(){ alert('copy anyone?');}); + + // special options such as disableInIput + $(document).bind('keydown', {combi:'Ctrl+x', disableInInput: true} , function() {}); + +Note: + This plugin wraps the following jQuery methods: $.fn.find, $.fn.bind and $.fn.unbind +*/ + +(function (jQuery){ + // keep reference to the original $.fn.bind, $.fn.unbind and $.fn.find + jQuery.fn.__bind__ = jQuery.fn.bind; + jQuery.fn.__unbind__ = jQuery.fn.unbind; + jQuery.fn.__find__ = jQuery.fn.find; + + var hotkeys = { + version: '0.7.9', + override: /keypress|keydown|keyup/g, + triggersMap: {}, + + specialKeys: { 27: 'esc', 9: 'tab', 32:'space', 13: 'return', 8:'backspace', 145: 'scroll', + 20: 'capslock', 144: 'numlock', 19:'pause', 45:'insert', 36:'home', 46:'del', + 35:'end', 33: 'pageup', 34:'pagedown', 37:'left', 38:'up', 39:'right',40:'down', + 109: '-', + 112:'f1',113:'f2', 114:'f3', 115:'f4', 116:'f5', 117:'f6', 118:'f7', 119:'f8', + 120:'f9', 121:'f10', 122:'f11', 123:'f12', 191: '/'}, + + shiftNums: { "`":"~", "1":"!", "2":"@", "3":"#", "4":"$", "5":"%", "6":"^", "7":"&", + "8":"*", "9":"(", "0":")", "-":"_", "=":"+", ";":":", "'":"\"", ",":"<", + ".":">", "/":"?", "\\":"|" }, + + newTrigger: function (type, combi, callback) { + // i.e. {'keyup': {'ctrl': {cb: callback, disableInInput: false}}} + var result = {}; + result[type] = {}; + result[type][combi] = {cb: callback, disableInInput: false}; + return result; + } + }; + // add firefox num pad char codes + //if (jQuery.browser.mozilla){ + // add num pad char codes + hotkeys.specialKeys = jQuery.extend(hotkeys.specialKeys, { 96: '0', 97:'1', 98: '2', 99: + '3', 100: '4', 101: '5', 102: '6', 103: '7', 104: '8', 105: '9', 106: '*', + 107: '+', 109: '-', 110: '.', 111 : '/' + }); + //} + + // a wrapper around of $.fn.find + // see more at: http://groups.google.com/group/jquery-en/browse_thread/thread/18f9825e8d22f18d + jQuery.fn.find = function( selector ) { + this.query = selector; + return jQuery.fn.__find__.apply(this, arguments); + }; + + jQuery.fn.unbind = function (type, combi, fn){ + if (jQuery.isFunction(combi)){ + fn = combi; + combi = null; + } + if (combi && typeof combi === 'string'){ + var selectorId = ((this.prevObject && this.prevObject.query) || (this[0].id && this[0].id) || this[0]).toString(); + var hkTypes = type.split(' '); + for (var x=0; x :put, :data => { :confirm => message } + message = "Are you sure you want to unlock?\n" \ + "Locked by #{@node.lock_owner.login}\n" \ + "Last modified #{@page.updated_at.to_fs(:db)}" + button_to 'Unlock', unlock_node_path(@node), + method: :put, + form: { data: { confirm: message } } end - end diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb index c739ccd..a054a2e 100644 --- a/app/helpers/nodes_helper.rb +++ b/app/helpers/nodes_helper.rb @@ -28,14 +28,20 @@ module NodesHelper def user_list User.all.map {|u| [u.login, u.id]} end - + def event_information if @node.event - "#{@node.event.start_time.to_fs(:db)} - #{@node.event.end_time.to_fs(:db)} > " \ - "#{link_to 'show', event_path(@node.event)} " \ - "#{link_to 'edit', edit_event_path(@node.event)}" + safe_join([ + "#{@node.event.start_time.to_fs(:db)} - #{@node.event.end_time.to_fs(:db)} > ", + link_to('show', event_path(@node.event)), + ' ', + link_to('edit', edit_event_path(@node.event)) + ]) else - "no event attached > #{link_to 'add', new_event_path(:node_id => @node.id)}" + safe_join([ + 'no event attached > ', + link_to('add', new_event_path(:node_id => @node.id)) + ]) end end end diff --git a/app/views/admin/_drafts.html.erb b/app/views/admin/_drafts.html.erb index 2036d12..a35b0ab 100644 --- a/app/views/admin/_drafts.html.erb +++ b/app/views/admin/_drafts.html.erb @@ -17,7 +17,7 @@ <%= 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, :data => { :confirm => "Do you really want to publish?" } %> + <%= button_to "Publish", publish_node_path(draft.node), method: :put, form: { data: { confirm: "Do you really want to publish?" } } %> <% end %> diff --git a/app/views/admin/_menu.html.erb b/app/views/admin/_menu.html.erb index 3188d94..6f217eb 100644 --- a/app/views/admin/_menu.html.erb +++ b/app/views/admin/_menu.html.erb @@ -1,5 +1,5 @@ <%= language_selector %> -<%= link_to 'Logout', logout_path, :method => :delete %> +<%= button_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') %> diff --git a/app/views/assets/index.html.erb b/app/views/assets/index.html.erb index e7ef313..83d55c2 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, :data => { :confirm => 'Are you sure?' }, :method => :delete %> + <%= button_to 'Destroy', asset, method: :delete, form: { data: { confirm: 'Are you sure?' } } %> <% end %> diff --git a/app/views/events/index.html.erb b/app/views/events/index.html.erb index 93c95fa..19b21ce 100644 --- a/app/views/events/index.html.erb +++ b/app/views/events/index.html.erb @@ -26,7 +26,7 @@ <%=h event.node_id %> <%= link_to 'Show', event %> <%= link_to 'Edit', edit_event_path(event) %> - <%= link_to 'Destroy', event, :data => { :confirm => 'Are you sure?' }, :method => :delete %> + <%= button_to 'Destroy', event, method: :delete, form: { data: { confirm: 'Are you sure?' } } %> <% end %> diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index e64850b..2a90786 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -7,14 +7,13 @@ <%= csrf_meta_tags %> <%= "#{params[:controller]} | #{params[:action]}" %> - <%= javascript_include_tag 'jquery', 'jquery_ujs' %> - <%= javascript_include_tag 'jquery-ui-1.7.2.custom.min' %> - <%= javascript_include_tag 'jquery.hotkeys' %> + <%= javascript_include_tag 'admin_bundle' %> <%= javascript_include_tag 'tiny_mce/jquery.tinymce.js' %> <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %> <%= stylesheet_link_tag 'admin' %> <%= javascript_include_tag 'admin_search.js' %> <%= javascript_include_tag 'admin_interface.js' %> + <%= stylesheet_link_tag 'admin' %> diff --git a/app/views/menu_items/index.html.erb b/app/views/menu_items/index.html.erb index 7d0ce62..c52c150 100644 --- a/app/views/menu_items/index.html.erb +++ b/app/views/menu_items/index.html.erb @@ -14,12 +14,9 @@ <%= menu_item.title %> <%= link_to "Edit", edit_menu_item_path(menu_item) %> - <%= link_to( - "Delete", - menu_item_path(menu_item), - :method => :delete, - :data => { :confirm => "Are you sure?" } - ) %> + <%= button_to "Delete", menu_item_path(menu_item), + method: :delete, + form: { data: { confirm: "Are you sure?" } } %> <% end %> diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index 64884cf..596f992 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, :data => { :confirm => "Publish this draft?" } %> + <%= button_to 'Publish', publish_node_path(@node), method: :put, form: { 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 7b8ffb8..0e99857 100644 --- a/app/views/occurrences/index.html.erb +++ b/app/views/occurrences/index.html.erb @@ -18,7 +18,7 @@ <%=h occurrence.event_id %> <%= link_to 'Show', occurrence %> <%= link_to 'Edit', edit_occurrence_path(occurrence) %> - <%= link_to 'Destroy', occurrence, :data => { :confirm => 'Are you sure?' }, :method => :delete %> + <%= button_to 'Destroy', occurrence, method: :delete, form: { data: { confirm: 'Are you sure?' } } %> <% end %> diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb index 4b28c9b..91e5359 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, :data => { :confirm => 'Are you sure?' }, :method => :delete %> + <%= button_to 'Destroy', page, method: :delete, form: { data: { confirm: 'Are you sure?' } } %> <% end %> diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb index e038ed2..b875a4f 100644 --- a/app/views/revisions/index.html.erb +++ b/app/views/revisions/index.html.erb @@ -4,7 +4,6 @@

Revisions for Node: <%= @node.unique_name %>

-<%= form_tag diff_node_revisions_path(@node) do %> @@ -14,6 +13,7 @@ + <% (@pages || @node.pages.all).reverse.each do |page| %> @@ -23,22 +23,36 @@ + - <% end %> - +
FirstEditor Date
<%= page.title %> <%= page.editor.try(:login) %> <%= page.updated_at %><%= link_to 'show', node_revision_path(@node, page) %> - <%= link_to 'show', node_revision_path(@node, page) %> - - <%= link_to( - 'restore', - restore_node_revision_path(@node, page), - :method => :put, - :data => { :confirm => "Restore this revision?" } - ) %> + <%= button_to 'restore', restore_node_revision_path(@node, page), + method: :put, + form: { data: { confirm: "Restore this revision?" } } %>
<%= submit_tag 'Diff revisions' %> + <%= button_to 'Diff revisions', diff_node_revisions_path(@node), + method: :post, + form: { id: 'diff_form' } %> +
-<% end %> + diff --git a/app/views/users/_user.html.erb b/app/views/users/_user.html.erb index 9987e31..ddb7afd 100644 --- a/app/views/users/_user.html.erb +++ b/app/views/users/_user.html.erb @@ -7,12 +7,9 @@ <%= link_to "edit", edit_user_path(user) %> - <%= link_to( - "destroy", - user_path(user), - :method => :delete, - :data => { :confirm => "Do you really want to delete user #{user.login}?" } - ) %> + <%= button_to "destroy", user_path(user), + method: :delete, + form: { data: { confirm: "Do you really want to delete user #{user.login}?" } } %> <% end %> -- cgit v1.3