Chris@1115: # Redmine - project management software Chris@1115: # Copyright (C) 2006-2012 Jean-Philippe Lang Chris@1115: # Chris@1115: # This program is free software; you can redistribute it and/or Chris@1115: # modify it under the terms of the GNU General Public License Chris@1115: # as published by the Free Software Foundation; either version 2 Chris@1115: # of the License, or (at your option) any later version. Chris@1115: # Chris@1115: # This program is distributed in the hope that it will be useful, Chris@1115: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@1115: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@1115: # GNU General Public License for more details. Chris@1115: # Chris@1115: # You should have received a copy of the GNU General Public License Chris@1115: # along with this program; if not, write to the Free Software Chris@1115: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@909: Chris@1115: RedmineApp::Application.routes.draw do Chris@1115: root :to => 'welcome#index', :as => 'home' Chris@0: Chris@1115: match 'login', :to => 'account#login', :as => 'signin' Chris@1115: match 'logout', :to => 'account#logout', :as => 'signout' Chris@1115: match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register' Chris@1115: match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post], :as => 'lost_password' Chris@1115: match 'account/activate', :to => 'account#activate', :via => :get Chris@909: Chris@1115: match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news' Chris@1115: match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue' Chris@1115: match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue' Chris@1115: match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue' Chris@909: Chris@1115: match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post Chris@1115: match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post] Chris@0: Chris@1115: match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post] Chris@1115: get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message' Chris@1115: match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post] Chris@1115: get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' Chris@1115: Chris@1115: post 'boards/:board_id/topics/preview', :to => 'messages#preview' Chris@1115: post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply' Chris@1115: post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit' Chris@1115: post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy' Chris@1115: Chris@1115: # Misc issue routes. TODO: move into resources Chris@1115: match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues' Chris@1115: match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu' Chris@1115: match '/issues/changes', :to => 'journals#index', :as => 'issue_changes' Chris@1115: match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue' Chris@1115: Chris@1115: match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get Chris@1115: match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post] Chris@1115: Chris@1115: match '/projects/:project_id/issues/gantt', :to => 'gantts#show' Chris@1115: match '/issues/gantt', :to => 'gantts#show' Chris@1115: Chris@1115: match '/projects/:project_id/issues/calendar', :to => 'calendars#show' Chris@1115: match '/issues/calendar', :to => 'calendars#show' Chris@1115: Chris@1115: match 'projects/:id/issues/report', :to => 'reports#issue_report', :via => :get Chris@1115: match 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :via => :get Chris@1115: Chris@1115: match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post] Chris@1115: match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post] Chris@1115: match 'my/page', :controller => 'my', :action => 'page', :via => :get Chris@1115: match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page Chris@1115: match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post Chris@1115: match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post Chris@1115: match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post] Chris@1115: match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get Chris@1115: match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post Chris@1115: match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post Chris@1115: match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post Chris@1115: Chris@1115: resources :users Chris@1115: match 'users/:id/memberships/:membership_id', :to => 'users#edit_membership', :via => :put, :as => 'user_membership' Chris@1115: match 'users/:id/memberships/:membership_id', :to => 'users#destroy_membership', :via => :delete Chris@1115: match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships' Chris@1115: Chris@1115: match 'watchers/new', :controller=> 'watchers', :action => 'new', :via => :get Chris@1115: match 'watchers', :controller=> 'watchers', :action => 'create', :via => :post Chris@1115: match 'watchers/append', :controller=> 'watchers', :action => 'append', :via => :post Chris@1115: match 'watchers/destroy', :controller=> 'watchers', :action => 'destroy', :via => :post Chris@1115: match 'watchers/watch', :controller=> 'watchers', :action => 'watch', :via => :post Chris@1115: match 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch', :via => :post Chris@1115: match 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user', :via => :get Chris@1115: Chris@1115: match 'projects/:id/settings/:tab', :to => "projects#settings" luis@1245: match 'projects/:id/overview', :to => "projects#overview" Chris@1115: Chris@1115: resources :projects do Chris@1115: member do Chris@1115: get 'settings' Chris@1115: post 'modules' Chris@1115: post 'archive' Chris@1115: post 'unarchive' Chris@1115: post 'close' Chris@1115: post 'reopen' Chris@1115: match 'copy', :via => [:get, :post] Chris@1115: end Chris@1115: chris@1141: resources :members, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do chris@1141: collection do chris@1141: get 'autocomplete' chris@1141: end chris@1141: end Chris@1115: resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do Chris@1115: collection do Chris@1115: get 'autocomplete' Chris@1115: end Chris@1115: end Chris@1115: Chris@1115: resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy] Chris@1115: Chris@1115: match 'issues/:copy_from/copy', :to => 'issues#new' Chris@1115: resources :issues, :only => [:index, :new, :create] do Chris@1115: resources :time_entries, :controller => 'timelog' do Chris@1115: collection do Chris@1115: get 'report' Chris@1115: end Chris@1115: end Chris@1115: end Chris@1115: # issue form update Chris@1115: match 'issues/new', :controller => 'issues', :action => 'new', :via => [:put, :post], :as => 'issue_form' Chris@1115: Chris@1115: resources :files, :only => [:index, :new, :create] Chris@1115: Chris@1115: resources :versions, :except => [:index, :show, :edit, :update, :destroy] do Chris@1115: collection do Chris@1115: put 'close_completed' Chris@1115: end Chris@1115: end Chris@1115: match 'versions.:format', :to => 'versions#index' Chris@1115: match 'roadmap', :to => 'versions#index', :format => false Chris@1115: match 'versions', :to => 'versions#index' Chris@1115: Chris@1115: resources :news, :except => [:show, :edit, :update, :destroy] Chris@1115: resources :time_entries, :controller => 'timelog' do Chris@1115: get 'report', :on => :collection Chris@1115: end Chris@1115: resources :queries, :only => [:new, :create] Chris@1115: resources :issue_categories, :shallow => true Chris@1115: resources :documents, :except => [:show, :edit, :update, :destroy] Chris@1115: resources :boards Chris@1115: resources :repositories, :shallow => true, :except => [:index, :show] do Chris@1115: member do Chris@1115: match 'committers', :via => [:get, :post] Chris@1115: end Chris@1115: end Chris@1115: Chris@1115: match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get Chris@1115: resources :wiki, :except => [:index, :new, :create] do Chris@1115: member do Chris@1115: get 'rename' Chris@1115: post 'rename' Chris@1115: get 'history' Chris@1115: get 'diff' Chris@1115: match 'preview', :via => [:post, :put] Chris@1115: post 'protect' Chris@1115: post 'add_attachment' Chris@1115: end Chris@1115: collection do Chris@1115: get 'export' Chris@1115: get 'date_index' Chris@1115: end Chris@1115: end Chris@1115: match 'wiki', :controller => 'wiki', :action => 'show', :via => :get Chris@1115: get 'wiki/:id/:version', :to => 'wiki#show' Chris@1115: delete 'wiki/:id/:version', :to => 'wiki#destroy_version' Chris@1115: get 'wiki/:id/:version/annotate', :to => 'wiki#annotate' Chris@1115: get 'wiki/:id/:version/diff', :to => 'wiki#diff' Chris@0: end chris@37: Chris@1115: resources :issues do Chris@1115: collection do Chris@1115: match 'bulk_edit', :via => [:get, :post] Chris@1115: post 'bulk_update' Chris@1115: end Chris@1115: resources :time_entries, :controller => 'timelog' do Chris@1115: collection do Chris@1115: get 'report' Chris@1115: end Chris@1115: end Chris@1115: resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy] Chris@1115: end Chris@1115: match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete Chris@909: luis@1129: # changed this route to ensure compatibility with Rails 3 --lf.20130109 luis@1129: match 'explore' => 'projects#explore' chris@1007: Chris@1115: resources :queries, :except => [:show] Chris@909: Chris@1115: resources :news, :only => [:index, :show, :edit, :update, :destroy] Chris@1115: match '/news/:id/comments', :to => 'comments#create', :via => :post Chris@1115: match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete Chris@1115: Chris@1115: resources :versions, :only => [:show, :edit, :update, :destroy] do Chris@1115: post 'status_by', :on => :member Chris@1115: end Chris@1115: Chris@1115: resources :documents, :only => [:show, :edit, :update, :destroy] do Chris@1115: post 'add_attachment', :on => :member Chris@1115: end Chris@1115: Chris@1115: match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu Chris@1115: Chris@1115: resources :time_entries, :controller => 'timelog', :except => :destroy do Chris@1115: collection do Chris@1115: get 'report' Chris@1115: get 'bulk_edit' Chris@1115: post 'bulk_update' Chris@0: end Chris@1115: end Chris@1115: match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/ Chris@1115: # TODO: delete /time_entries for bulk deletion Chris@1115: match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete Chris@1115: Chris@1115: # TODO: port to be part of the resources route(s) Chris@1115: match 'projects/:id/settings/:tab', :to => 'projects#settings', :via => :get Chris@1115: Chris@1115: get 'projects/:id/activity', :to => 'activities#index' Chris@1115: get 'projects/:id/activity.:format', :to => 'activities#index' Chris@1115: get 'activity', :to => 'activities#index' Chris@1115: Chris@1115: # repositories routes Chris@1115: get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats' Chris@1115: get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph' Chris@1115: Chris@1115: get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))', Chris@1115: :to => 'repositories#changes' Chris@1115: Chris@1115: get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision' Chris@1115: get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision' Chris@1115: post 'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue' Chris@1115: delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue' Chris@1115: get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions' Chris@1115: get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))', Chris@1115: :controller => 'repositories', Chris@1115: :format => false, Chris@1115: :constraints => { Chris@1115: :action => /(browse|show|entry|raw|annotate|diff)/, Chris@1115: :rev => /[a-z0-9\.\-_]+/ Chris@1115: } Chris@1115: Chris@1115: get 'projects/:id/repository/statistics', :to => 'repositories#stats' Chris@1115: get 'projects/:id/repository/graph', :to => 'repositories#graph' Chris@1115: Chris@1115: get 'projects/:id/repository/changes(/*path(.:ext))', Chris@1115: :to => 'repositories#changes' Chris@1115: Chris@1115: get 'projects/:id/repository/revisions', :to => 'repositories#revisions' Chris@1115: get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision' Chris@1115: get 'projects/:id/repository/revision', :to => 'repositories#revision' Chris@1115: post 'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue' Chris@1115: delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue' Chris@1115: get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))', Chris@1115: :controller => 'repositories', Chris@1115: :format => false, Chris@1115: :constraints => { Chris@1115: :action => /(browse|show|entry|raw|annotate|diff)/, Chris@1115: :rev => /[a-z0-9\.\-_]+/ Chris@1115: } Chris@1115: get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', Chris@1115: :controller => 'repositories', Chris@1115: :action => /(browse|show|entry|raw|changes|annotate|diff)/ Chris@1115: get 'projects/:id/repository/:action(/*path(.:ext))', Chris@1115: :controller => 'repositories', Chris@1115: :action => /(browse|show|entry|raw|changes|annotate|diff)/ Chris@1115: Chris@1115: get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil Chris@1115: get 'projects/:id/repository', :to => 'repositories#show', :path => nil Chris@1115: Chris@1115: # additional routes for having the file name at the end of url Chris@1115: match 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/, :via => :get Chris@1115: match 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/, :via => :get Chris@1115: match 'attachments/download/:id', :controller => 'attachments', :action => 'download', :id => /\d+/, :via => :get chris@1153: match 'attachments/toggle_active/:id', :controller => 'attachments', :action => 'toggle_active', :id => /\d+/, :via => :get Chris@1115: match 'attachments/thumbnail/:id(/:size)', :controller => 'attachments', :action => 'thumbnail', :id => /\d+/, :via => :get, :size => /\d+/ Chris@1115: resources :attachments, :only => [:show, :destroy] Chris@1115: Chris@1115: resources :groups do Chris@1115: member do Chris@1115: get 'autocomplete_for_user' Chris@0: end Chris@0: end Chris@909: Chris@1115: match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users' Chris@1115: match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user' Chris@1115: match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post Chris@1115: match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post Chris@1115: Chris@1115: resources :trackers, :except => :show do Chris@1115: collection do Chris@1115: match 'fields', :via => [:get, :post] Chris@0: end Chris@1115: end Chris@1115: resources :issue_statuses, :except => :show do Chris@1115: collection do Chris@1115: post 'update_issue_done_ratio' Chris@1115: end Chris@1115: end Chris@1115: resources :custom_fields, :except => :show Chris@1115: resources :roles do Chris@1115: collection do Chris@1115: match 'permissions', :via => [:get, :post] Chris@1115: end Chris@1115: end Chris@1115: resources :enumerations, :except => :show Chris@1115: match 'enumerations/:type', :to => 'enumerations#index', :via => :get Chris@1115: Chris@1115: get 'projects/:id/search', :controller => 'search', :action => 'index' Chris@1115: get 'search', :controller => 'search', :action => 'index' Chris@1115: Chris@1115: match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post Chris@1115: Chris@1115: match 'admin', :controller => 'admin', :action => 'index', :via => :get Chris@1115: match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get Chris@1115: match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get Chris@1115: match 'admin/info', :controller => 'admin', :action => 'info', :via => :get Chris@1115: match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get Chris@1115: match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post Chris@1115: Chris@1115: resources :auth_sources do Chris@1115: member do Chris@1115: get 'test_connection' Chris@0: end Chris@0: end Chris@909: Chris@1115: match 'workflows', :controller => 'workflows', :action => 'index', :via => :get Chris@1115: match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post] Chris@1115: match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post] Chris@1115: match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post] Chris@1115: match 'settings', :controller => 'settings', :action => 'index', :via => :get Chris@1115: match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post] Chris@1115: match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post] Chris@1115: Chris@1115: match 'sys/projects', :to => 'sys#projects', :via => :get Chris@1115: match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post Chris@1115: match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => :get Chris@1115: Chris@1115: match 'uploads', :to => 'attachments#upload', :via => :post Chris@1115: Chris@1115: get 'robots.txt', :to => 'welcome#robots' Chris@1115: Chris@1115: Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir| Chris@1115: file = File.join(plugin_dir, "config/routes.rb") Chris@1115: if File.exists?(file) Chris@1115: begin Chris@1115: instance_eval File.read(file) Chris@1115: rescue Exception => e Chris@1115: puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}." Chris@1115: exit 1 Chris@1115: end Chris@0: end Chris@0: end Chris@0: end