From 765f7abc60334b278c97678c41f1ba458db283d0 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Mon, 26 Jan 2009 01:47:51 +0000 Subject: [PATCH] Converted routing and urls to follow the Rails REST convention. Patch supplied by commits from Gerrit Kaiser on Github. Existing routes will still work (backwards compatible) but any new urls will be generated using the new routing rules. Changes listed below: * made the URLs for some project tabs and project settings follow the new rails RESTful conventions of /collection/:id/subcollection/:sub_id * prettier URL for project roadmap * more nice project URLs * use GET for filtering form * prettified URLs used on issues tab * custom route for activity atom feeds * prettier repository urls * fixed broken route definition * fixed failing tests for issuecontroller that were hardcoding the url string * more RESTful routes for boards and messages * RESTful routes for wiki pages * RESTful routes for documents * moved old routes that are retained for compatibility to the bottom and grouped them together * added RESTful URIs for issues * RESTfulness for the news section * fixed route order * changed hardcoded URLs in tests * fixed badly written tests * fixed forgotten parameter in routes * changed hardcoded URLS to new scheme * changed project add url to the standard POST to collection * create new issue by POSTing to collection * changed hardcoded URLs in integrations tests * made project add form work again * restful routes for project deletion * prettier routes for project (un)archival * made routes table more readable * fixed note quoting * user routing * fixed bug * always sort by GET * Fixed: cross-project issue list should not show issues of projects for which the issue tracking module was disabled. * prettified URLs used on issues tab * urls for time log * fixed reply routing * eliminate revision query paremeter for diff and entry actions * fixed test failures with hard-coded urls * ensure ajax links always use get * refactored ajax link generation into separate method #1901 git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2317 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 43 ++-- app/helpers/sort_helper.rb | 2 +- app/views/projects/changelog.rhtml | 2 +- app/views/timelog/details.rhtml | 4 +- app/views/timelog/report.rhtml | 4 +- app/views/users/_general.rhtml | 2 +- config/routes.rb | 236 ++++++++++++++++-- test/functional/admin_controller_test.rb | 7 + test/functional/boards_controller_test.rb | 43 ++++ test/functional/documents_controller_test.rb | 45 +++- .../issue_relations_controller_test.rb | 22 ++ test/functional/issues_controller_test.rb | 168 +++++++++++-- test/functional/members_controller_test.rb | 15 ++ test/functional/messages_controller_test.rb | 43 ++++ test/functional/news_controller_test.rb | 64 +++++ test/functional/projects_controller_test.rb | 199 +++++++++++++-- test/functional/reports_controller_test.rb | 20 ++ .../repositories_controller_test.rb | 113 ++++++++- ...repositories_subversion_controller_test.rb | 8 +- test/functional/timelog_controller_test.rb | 119 ++++++++- test/functional/users_controller_test.rb | 74 +++++- test/functional/versions_controller_test.rb | 4 +- test/functional/wiki_controller_test.rb | 124 ++++++++- test/functional/wikis_controller_test.rb | 23 +- test/integration/admin_test.rb | 4 +- test/integration/issues_test.rb | 8 +- test/integration/projects_test.rb | 10 +- test/unit/helpers/application_helper_test.rb | 32 +-- .../redmine/wiki_formatting/macros_test.rb | 10 +- test/unit/mailer_test.rb | 22 +- 30 files changed, 1311 insertions(+), 159 deletions(-) create mode 100644 test/functional/issue_relations_controller_test.rb create mode 100644 test/functional/members_controller_test.rb create mode 100644 test/functional/reports_controller_test.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e6b480b9f..6779fdef8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -243,39 +243,36 @@ module ApplicationHelper url_param.clear if url_param.has_key?(:set_filter) html = '' - html << link_to_remote(('« ' + l(:label_previous)), - {:update => 'content', - :url => url_param.merge(page_param => paginator.current.previous), - :complete => 'window.scrollTo(0,0)'}, - {:href => url_for(:params => url_param.merge(page_param => paginator.current.previous))}) + ' ' if paginator.current.previous + if paginator.current.previous + html << link_to_remote_content_update('« ' + l(:label_previous), url_param.merge(page_param => paginator.current.previous)) + ' ' + end html << (pagination_links_each(paginator, options) do |n| - link_to_remote(n.to_s, - {:url => {:params => url_param.merge(page_param => n)}, - :update => 'content', - :complete => 'window.scrollTo(0,0)'}, - {:href => url_for(:params => url_param.merge(page_param => n))}) + link_to_remote_content_update(n.to_s, url_param.merge(page_param => n)) end || '') - - html << ' ' + link_to_remote((l(:label_next) + ' »'), - {:update => 'content', - :url => url_param.merge(page_param => paginator.current.next), - :complete => 'window.scrollTo(0,0)'}, - {:href => url_for(:params => url_param.merge(page_param => paginator.current.next))}) if paginator.current.next + + if paginator.current.next + html << ' ' + link_to_remote_content_update((l(:label_next) + ' »'), url_param.merge(page_param => paginator.current.next)) + end unless count.nil? - html << [" (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", per_page_links(paginator.items_per_page)].compact.join(' | ') + html << [ + " (#{paginator.current.first_item}-#{paginator.current.last_item}/#{count})", + per_page_links(paginator.items_per_page) + ].compact.join(' | ') end html end - + def per_page_links(selected=nil) url_param = params.dup url_param.clear if url_param.has_key?(:set_filter) links = Setting.per_page_options_array.collect do |n| - n == selected ? n : link_to_remote(n, {:update => "content", :url => params.dup.merge(:per_page => n)}, + n == selected ? n : link_to_remote(n, {:update => "content", + :url => params.dup.merge(:per_page => n), + :method => :get}, {:href => url_for(url_param.merge(:per_page => n))}) end links.size > 1 ? l(:label_display_per_page, links.join(', ')) : nil @@ -664,4 +661,12 @@ module ApplicationHelper extend helper return self end + + def link_to_remote_content_update(text, url_params) + link_to_remote(text, + {:url => url_params, :method => :get, :update => 'content', :complete => 'window.scrollTo(0,0)'}, + {:href => url_for(:params => url_params)} + ) + end + end diff --git a/app/helpers/sort_helper.rb b/app/helpers/sort_helper.rb index ed520e748..85ae8151c 100644 --- a/app/helpers/sort_helper.rb +++ b/app/helpers/sort_helper.rb @@ -121,7 +121,7 @@ module SortHelper url_options = params.has_key?(:set_filter) ? sort_options : params.merge(sort_options) link_to_remote(caption, - {:update => "content", :url => url_options}, + {:update => "content", :url => url_options, :method => :get}, {:href => url_for(url_options)}) + (icon ? nbsp(2) + image_tag(icon) : '') end diff --git a/app/views/projects/changelog.rhtml b/app/views/projects/changelog.rhtml index e4d32a393..e44d1d1ee 100644 --- a/app/views/projects/changelog.rhtml +++ b/app/views/projects/changelog.rhtml @@ -26,7 +26,7 @@ <% end %> <% content_for :sidebar do %> -<% form_tag do %> +<% form_tag({},:method => :get) do %>

<%= l(:label_change_log) %>

<% @trackers.each do |tracker| %>