Project

General

Profile

« Previous | Next » 

Revision 9528

Merged rails-3.2 branch.

View differences:

routes.rb
1
ActionController::Routing::Routes.draw do |map|
2
  # Add your own custom routes here.
3
  # The priority is based upon order of creation: first created -> highest priority.
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
4 17

  
5
  # Here's a sample route:
6
  # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
7
  # Keep in mind you can assign values other than :controller and :action
18
RedmineApp::Application.routes.draw do
19
  root :to => 'welcome#index', :as => 'home'
8 20

  
9
  map.home '', :controller => 'welcome', :conditions => {:method => :get}
21
  match 'login', :to => 'account#login', :as => 'signin'
22
  match 'logout', :to => 'account#logout', :as => 'signout'
23
  match 'account/register', :to => 'account#register', :via => [:get, :post]
24
  match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post]
25
  match 'account/activate', :to => 'account#activate', :via => :get
26
  
27
  match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news'
28
  match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue'
29
  match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue'
30
  match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue'
31
  
32
  match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post
33
  match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post]
10 34

  
11
  map.signin 'login', :controller => 'account', :action => 'login',
12
             :conditions => {:method => [:get, :post]}
13
  map.signout 'logout', :controller => 'account', :action => 'logout',
14
              :conditions => {:method => :get}
15
  map.connect 'account/register', :controller => 'account', :action => 'register',
16
              :conditions => {:method => [:get, :post]}
17
  map.connect 'account/lost_password', :controller => 'account', :action => 'lost_password',
18
              :conditions => {:method => [:get, :post]}
19
  map.connect 'account/activate', :controller => 'account', :action => 'activate',
20
              :conditions => {:method => :get}
35
  match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post]
36
  get 'boards/:board_id/topics/:id', :to => 'messages#show'
37
  match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
38
  get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
39
  
40
  post 'boards/:board_id/topics/preview', :to => 'messages#preview'
41
  post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
42
  post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
43
  post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
21 44

  
22
  map.connect 'projects/:id/wiki', :controller => 'wikis',
23
              :action => 'edit', :conditions => {:method => :post}
24
  map.connect 'projects/:id/wiki/destroy', :controller => 'wikis',
25
              :action => 'destroy', :conditions => {:method => [:get, :post]}
45
  # Misc issue routes. TODO: move into resources
46
  match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'
47
  match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu'
48
  match '/issues/changes', :to => 'journals#index', :as => 'issue_changes'
49
  match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
26 50

  
27
  map.with_options :controller => 'messages' do |messages_routes|
28
    messages_routes.with_options :conditions => {:method => :get} do |messages_views|
29
      messages_views.connect 'boards/:board_id/topics/new', :action => 'new'
30
      messages_views.connect 'boards/:board_id/topics/:id', :action => 'show'
31
      messages_views.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
32
    end
33
    messages_routes.with_options :conditions => {:method => :post} do |messages_actions|
34
      messages_actions.connect 'boards/:board_id/topics/new', :action => 'new'
35
      messages_actions.connect 'boards/:board_id/topics/preview', :action => 'preview'
36
      messages_actions.connect 'boards/:board_id/topics/quote/:id', :action => 'quote'
37
      messages_actions.connect 'boards/:board_id/topics/:id/replies', :action => 'reply'
38
      messages_actions.connect 'boards/:board_id/topics/:id/edit', :action => 'edit'
39
      messages_actions.connect 'boards/:board_id/topics/:id/destroy', :action => 'destroy'
40
    end
41
  end
51
  match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get
52
  match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post]
42 53

  
43
  # Misc issue routes. TODO: move into resources
44
  map.auto_complete_issues '/issues/auto_complete', :controller => 'auto_completes',
45
                           :action => 'issues', :conditions => { :method => :get }
46
  # TODO: would look nicer as /issues/:id/preview
47
  map.preview_new_issue '/issues/preview/new/:project_id', :controller => 'previews',
48
                        :action => 'issue'
49
  map.preview_edit_issue '/issues/preview/edit/:id', :controller => 'previews',
50
                         :action => 'issue'
51
  map.issues_context_menu '/issues/context_menu',
52
                          :controller => 'context_menus', :action => 'issues'
54
  match '/projects/:project_id/issues/gantt', :to => 'gantts#show'
55
  match '/issues/gantt', :to => 'gantts#show'
53 56

  
54
  map.issue_changes '/issues/changes', :controller => 'journals', :action => 'index'
55
  map.quoted_issue '/issues/:id/quoted', :controller => 'journals', :action => 'new',
56
                   :id => /\d+/, :conditions => { :method => :post }
57
  match '/projects/:project_id/issues/calendar', :to => 'calendars#show'
58
  match '/issues/calendar', :to => 'calendars#show'
57 59

  
58
  map.connect '/journals/diff/:id', :controller => 'journals', :action => 'diff',
59
              :id => /\d+/, :conditions => { :method => :get }
60
  map.connect '/journals/edit/:id', :controller => 'journals', :action => 'edit',
61
              :id => /\d+/, :conditions => { :method => [:get, :post] }
60
  match 'projects/:id/issues/report', :to => 'reports#issue_report', :via => :get
61
  match 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :via => :get
62 62

  
63
  map.with_options :controller => 'gantts', :action => 'show' do |gantts_routes|
64
    gantts_routes.connect '/projects/:project_id/issues/gantt'
65
    gantts_routes.connect '/projects/:project_id/issues/gantt.:format'
66
    gantts_routes.connect '/issues/gantt.:format'
67
  end
63
  match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
64
  match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
65
  match 'my/page', :controller => 'my', :action => 'page', :via => :get
66
  match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page
67
  match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post
68
  match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post
69
  match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
70
  match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get
71
  match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post
72
  match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post
73
  match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post
68 74

  
69
  map.with_options :controller => 'calendars', :action => 'show' do |calendars_routes|
70
    calendars_routes.connect '/projects/:project_id/issues/calendar'
71
    calendars_routes.connect '/issues/calendar'
72
  end
75
  resources :users
76
  match 'users/:id/memberships/:membership_id', :to => 'users#edit_membership', :via => :put, :as => 'user_membership'
77
  match 'users/:id/memberships/:membership_id', :to => 'users#destroy_membership', :via => :delete
78
  match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships'
73 79

  
74
  map.with_options :controller => 'reports', :conditions => {:method => :get} do |reports|
75
    reports.connect 'projects/:id/issues/report', :action => 'issue_report'
76
    reports.connect 'projects/:id/issues/report/:detail', :action => 'issue_report_details'
77
  end
80
  match 'watchers/new', :controller=> 'watchers', :action => 'new', :via => :get
81
  match 'watchers', :controller=> 'watchers', :action => 'create', :via => :post
82
  match 'watchers/append', :controller=> 'watchers', :action => 'append', :via => :post
83
  match 'watchers/destroy', :controller=> 'watchers', :action => 'destroy', :via => :post
84
  match 'watchers/watch', :controller=> 'watchers', :action => 'watch', :via => :post
85
  match 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch', :via => :post
86
  match 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user', :via => :get
78 87

  
79
  map.connect 'my/account', :controller => 'my', :action => 'account',
80
              :conditions => {:method => [:get, :post]}
81
  map.connect 'my/account/destroy', :controller => 'my', :action => 'destroy',
82
              :conditions => {:method => [:get, :post]}
83
  map.connect 'my/page', :controller => 'my', :action => 'page',
84
              :conditions => {:method => :get}
85
  # Redirects to my/page
86
  map.connect 'my', :controller => 'my', :action => 'index',
87
              :conditions => {:method => :get}
88
  map.connect 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key',
89
              :conditions => {:method => :post}
90
  map.connect 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key',
91
              :conditions => {:method => :post}
92
  map.connect 'my/password', :controller => 'my', :action => 'password',
93
              :conditions => {:method => [:get, :post]}
94
  map.connect 'my/page_layout', :controller => 'my', :action => 'page_layout',
95
              :conditions => {:method => :get}
96
  map.connect 'my/add_block', :controller => 'my', :action => 'add_block',
97
              :conditions => {:method => :post}
98
  map.connect 'my/remove_block', :controller => 'my', :action => 'remove_block',
99
              :conditions => {:method => :post}
100
  map.connect 'my/order_blocks', :controller => 'my', :action => 'order_blocks',
101
              :conditions => {:method => :post}
88
  match 'projects/:id/settings/:tab', :to => "projects#settings"
102 89

  
103
  map.with_options :controller => 'users' do |users|
104
    users.user_membership 'users/:id/memberships/:membership_id',
105
                          :action => 'edit_membership',
106
                          :conditions => {:method => :put}
107
    users.connect 'users/:id/memberships/:membership_id',
108
                  :action => 'destroy_membership',
109
                  :conditions => {:method => :delete}
110
    users.user_memberships 'users/:id/memberships',
111
                           :action => 'edit_membership',
112
                           :conditions => {:method => :post}
113
  end
114
  map.resources :users
90
  resources :projects do
91
    member do
92
      get 'settings'
93
      post 'modules'
94
      post 'archive'
95
      post 'unarchive'
96
      match 'copy', :via => [:get, :post]
97
    end
115 98

  
116
  # For nice "roadmap" in the url for the index action
117
  map.connect 'projects/:project_id/roadmap', :controller => 'versions', :action => 'index'
99
    resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :create, :update, :destroy] do
100
      collection do
101
        get 'autocomplete'
102
      end
103
    end
118 104

  
119
  map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
120
  map.connect 'news/:id/comments', :controller => 'comments',
121
              :action => 'create', :conditions => {:method => :post}
122
  map.connect 'news/:id/comments/:comment_id', :controller => 'comments',
123
              :action => 'destroy', :conditions => {:method => :delete}
105
    resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy]
124 106

  
125
  map.connect 'watchers/new', :controller=> 'watchers', :action => 'new',
126
              :conditions => {:method => :get}
127
  map.connect 'watchers', :controller=> 'watchers', :action => 'create',
128
              :conditions => {:method => :post}
129
  map.connect 'watchers/append', :controller=> 'watchers', :action => 'append',
130
              :conditions => {:method => :post}
131
  map.connect 'watchers/destroy', :controller=> 'watchers', :action => 'destroy',
132
              :conditions => {:method => :post}
133
  map.connect 'watchers/watch', :controller=> 'watchers', :action => 'watch',
134
              :conditions => {:method => :post}
135
  map.connect 'watchers/unwatch', :controller=> 'watchers', :action => 'unwatch',
136
              :conditions => {:method => :post}
137
  map.connect 'watchers/autocomplete_for_user', :controller=> 'watchers', :action => 'autocomplete_for_user',
138
              :conditions => {:method => :get}
107
    match 'issues/:copy_from/copy', :to => 'issues#new'
108
    resources :issues, :only => [:index, :new, :create] do
109
      resources :time_entries, :controller => 'timelog' do
110
        collection do
111
          get 'report'
112
        end
113
      end
114
    end
115
    # issue form update
116
    match 'issues/new', :controller => 'issues', :action => 'new', :via => [:put, :post], :as => 'issue_form'
139 117

  
140
  # TODO: port to be part of the resources route(s)
141
  map.with_options :conditions => {:method => :get} do |project_views|
142
    project_views.connect 'projects/:id/settings/:tab',
143
                          :controller => 'projects', :action => 'settings'
144
    project_views.connect 'projects/:project_id/issues/:copy_from/copy',
145
                          :controller => 'issues', :action => 'new'
146
  end
118
    resources :files, :only => [:index, :new, :create]
147 119

  
148
  map.resources :projects, :member => {
149
    :copy => [:get, :post],
150
    :settings => :get,
151
    :modules => :post,
152
    :archive => :post,
153
    :unarchive => :post
154
  } do |project|
155
    project.resource :enumerations, :controller => 'project_enumerations',
156
                     :only => [:update, :destroy]
157
    # issue form update
158
    project.issue_form 'issues/new', :controller => 'issues',
159
                       :action => 'new', :conditions => {:method => [:post, :put]}
160
    project.resources :issues, :only => [:index, :new, :create] do |issues|
161
      issues.resources :time_entries, :controller => 'timelog',
162
                       :collection => {:report => :get}
120
    resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
121
      collection do
122
        put 'close_completed'
123
      end
163 124
    end
125
    match 'versions.:format', :to => 'versions#index'
126
    match 'roadmap', :to => 'versions#index', :format => false
127
    match 'versions', :to => 'versions#index'
164 128

  
165
    project.resources :files, :only => [:index, :new, :create]
166
    project.resources :versions, :shallow => true,
167
                      :collection => {:close_completed => :put},
168
                      :member => {:status_by => :post}
169
    project.resources :news, :shallow => true
170
    project.resources :time_entries, :controller => 'timelog',
171
                      :collection => {:report => :get}
172
    project.resources :queries, :only => [:new, :create]
173
    project.resources :issue_categories, :shallow => true
174
    project.resources :documents, :shallow => true, :member => {:add_attachment => :post}
175
    project.resources :boards
176
    project.resources :repositories, :shallow => true, :except => [:index, :show],
177
                      :member => {:committers => [:get, :post]}
178
    project.resources :memberships, :shallow => true, :controller => 'members',
179
                      :only => [:index, :show, :create, :update, :destroy],
180
                      :collection => {:autocomplete => :get}
129
    resources :news, :except => [:show, :edit, :update, :destroy]
130
    resources :time_entries, :controller => 'timelog' do
131
      get 'report', :on => :collection
132
    end
133
    resources :queries, :only => [:new, :create]
134
    resources :issue_categories, :shallow => true
135
    resources :documents, :except => [:show, :edit, :update, :destroy]
136
    resources :boards
137
    resources :repositories, :shallow => true, :except => [:index, :show] do
138
      member do
139
        match 'committers', :via => [:get, :post]
140
      end
141
    end
181 142

  
182
    project.wiki_start_page 'wiki', :controller => 'wiki', :action => 'show', :conditions => {:method => :get}
183
    project.wiki_index 'wiki/index', :controller => 'wiki', :action => 'index', :conditions => {:method => :get}
184
    project.wiki_diff 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff', :version => nil
185
    project.wiki_diff 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
186
    project.wiki_annotate 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
187
    project.resources :wiki, :except => [:new, :create], :member => {
188
      :rename => [:get, :post],
189
      :history => :get,
190
      :preview => :any,
191
      :protect => :post,
192
      :add_attachment => :post
193
    }, :collection => {
194
      :export => :get,
195
      :date_index => :get
196
    }
143
    match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
144
    match 'wiki/:id/diff/:version/vs/:version_from', :controller => 'wiki', :action => 'diff'
145
    match 'wiki/:id/diff/:version', :controller => 'wiki', :action => 'diff'
146
    resources :wiki, :except => [:index, :new, :create] do
147
      member do
148
        get 'rename'
149
        post 'rename'
150
        get 'history'
151
        get 'diff'
152
        match 'preview', :via => [:post, :put]
153
        post 'protect'
154
        post 'add_attachment'
155
      end
156
      collection do
157
        get 'export'
158
        get 'date_index'
159
      end
160
    end
161
    match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
162
    match 'wiki/:id/annotate/:version', :controller => 'wiki', :action => 'annotate'
197 163
  end
198 164

  
199
  map.connect 'news', :controller => 'news', :action => 'index'
200
  map.connect 'news.:format', :controller => 'news', :action => 'index'
165
  resources :issues do
166
    collection do
167
      match 'bulk_edit', :via => [:get, :post]
168
      post 'bulk_update'
169
    end
170
    resources :time_entries, :controller => 'timelog' do
171
      collection do
172
        get 'report'
173
      end
174
    end
175
    resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
176
  end
177
  match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete
201 178

  
202
  map.resources :queries, :except => [:show]
203
  map.resources :issues,
204
                :collection => {:bulk_edit => [:get, :post], :bulk_update => :post} do |issues|
205
    issues.resources :time_entries, :controller => 'timelog',
206
                     :collection => {:report => :get}
207
    issues.resources :relations, :shallow => true,
208
                     :controller => 'issue_relations',
209
                     :only => [:index, :show, :create, :destroy]
179
  resources :queries, :except => [:show]
180

  
181
  resources :news, :only => [:index, :show, :edit, :update, :destroy]
182
  match '/news/:id/comments', :to => 'comments#create', :via => :post
183
  match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete
184
  
185
  resources :versions, :only => [:show, :edit, :update, :destroy] do
186
    post 'status_by', :on => :member
210 187
  end
211
  # Bulk deletion
212
  map.connect '/issues', :controller => 'issues', :action => 'destroy',
213
              :conditions => {:method => :delete}
214 188

  
215
  map.connect '/time_entries/destroy',
216
              :controller => 'timelog', :action => 'destroy',
217
              :conditions => { :method => :delete }
218
  map.time_entries_context_menu '/time_entries/context_menu',
219
                   :controller => 'context_menus', :action => 'time_entries'
189
  resources :documents, :only => [:show, :edit, :update, :destroy] do
190
    post 'add_attachment', :on => :member
191
  end
220 192

  
221
  map.resources :time_entries, :controller => 'timelog',
222
                :collection => {:report => :get, :bulk_edit => :get, :bulk_update => :post}
193
  match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu
223 194

  
224
  map.with_options :controller => 'activities', :action => 'index',
225
                   :conditions => {:method => :get} do |activity|
226
    activity.connect 'projects/:id/activity'
227
    activity.connect 'projects/:id/activity.:format'
228
    activity.connect 'activity', :id => nil
229
    activity.connect 'activity.:format', :id => nil
195
  resources :time_entries, :controller => 'timelog', :except => :destroy do
196
    collection do
197
      get 'report'
198
      get 'bulk_edit'
199
      post 'bulk_update'
200
    end
230 201
  end
202
  match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
203
  # TODO: delete /time_entries for bulk deletion
204
  match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete
205
  
206
  # TODO: port to be part of the resources route(s)
207
  match 'projects/:id/settings/:tab', :to => 'projects#settings', :via => :get
231 208

  
232
  map.with_options :controller => 'repositories' do |repositories|
233
    repositories.with_options :conditions => {:method => :get} do |repository_views|
234
      repository_views.connect 'projects/:id/repository',
235
                               :action => 'show'
209
  get 'projects/:id/activity', :to => 'activities#index'
210
  get 'projects/:id/activity.:format', :to => 'activities#index'
211
  get 'activity', :to => 'activities#index'
236 212

  
237
      repository_views.connect 'projects/:id/repository/:repository_id/statistics',
238
                               :action => 'stats'
239
      repository_views.connect 'projects/:id/repository/:repository_id/graph',
240
                               :action => 'graph'
213
  # repositories routes
214
  get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
215
  get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
216
  match 'projects/:id/repository/:repository_id/committers', :to => 'repositories#committers', :via => [:get, :post]
241 217

  
242
      repository_views.connect 'projects/:id/repository/statistics',
243
                               :action => 'stats'
244
      repository_views.connect 'projects/:id/repository/graph',
245
                               :action => 'graph'
218
  get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
219
  get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
220
  post   'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
221
  delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
222
  get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
223
  get 'projects/:id/repository/:repository_id/revisions/:rev/:format(/*path(.:ext))', :to => 'repositories#entry', :format => /raw/
224
  get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))', :controller => 'repositories', :action => /(browse|show|entry|changes|annotate|diff)/
246 225

  
247
      repository_views.connect 'projects/:id/repository/:repository_id/revisions',
248
                               :action => 'revisions'
249
      repository_views.connect 'projects/:id/repository/:repository_id/revisions.:format',
250
                               :action => 'revisions'
251
      repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev',
252
                               :action => 'revision'
253
      repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues',
254
                                :action => 'add_related_issue', :conditions => {:method => :post}
255
      repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id',
256
                                :action => 'remove_related_issue', :conditions => {:method => :delete}
257
      repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff',
258
                               :action => 'diff'
259
      repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/diff.:format',
260
                               :action => 'diff'
261
      repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/raw/*path',
262
                               :action => 'entry', :format => 'raw'
263
      repository_views.connect 'projects/:id/repository/:repository_id/revisions/:rev/:action/*path',
264
                               :requirements => { 
265
                                   :action => /(browse|show|entry|changes|annotate|diff)/,
266
                                   :rev    => /[a-z0-9\.\-_]+/
267
                                 }
268
      repository_views.connect 'projects/:id/repository/:repository_id/raw/*path',
269
                               :action => 'entry', :format => 'raw'
270
      repository_views.connect 'projects/:id/repository/:repository_id/:action/*path',
271
                               :requirements => { :action => /(browse|entry|changes|annotate|diff)/ }
272
      repository_views.connect 'projects/:id/repository/:repository_id/show/*path',
273
                               :requirements => { :path => /.+/ }
226
  get 'projects/:id/repository/statistics', :to => 'repositories#stats'
227
  get 'projects/:id/repository/graph', :to => 'repositories#graph'
228
  match 'projects/:id/repository/committers', :to => 'repositories#committers', :via => [:get, :post]
274 229

  
275
      repository_views.connect 'projects/:id/repository/:repository_id/revision',
276
                               :action => 'revision'
230
  get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
231
  get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
232
  get 'projects/:id/repository/revision', :to => 'repositories#revision'
233
  post   'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
234
  delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
235
  get 'projects/:id/repository/revisions/:rev/:format(/*path(.:ext))', :to => 'repositories#entry', :format => /raw/
236
  get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))', :controller => 'repositories', :action => /(browse|show|entry|changes|annotate|diff)/
237
  get 'projects/:id/repository/:repository_id/:format(/*path(.:ext))', :to => 'repositories#entry', :format => /raw/
238
  get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))', :controller => 'repositories', :action => /(browse|show|entry|changes|annotate|diff)/
239
  get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
277 240

  
278
      repository_views.connect 'projects/:id/repository/revisions',
279
                               :action => 'revisions'
280
      repository_views.connect 'projects/:id/repository/revisions.:format',
281
                               :action => 'revisions'
282
      repository_views.connect 'projects/:id/repository/revisions/:rev',
283
                               :action => 'revision'
284
      repository_views.connect 'projects/:id/repository/revisions/:rev/issues',
285
                                :action => 'add_related_issue', :conditions => {:method => :post}
286
      repository_views.connect 'projects/:id/repository/revisions/:rev/issues/:issue_id',
287
                                :action => 'remove_related_issue', :conditions => {:method => :delete}
288
      repository_views.connect 'projects/:id/repository/revisions/:rev/diff',
289
                               :action => 'diff'
290
      repository_views.connect 'projects/:id/repository/revisions/:rev/diff.:format',
291
                               :action => 'diff'
292
      repository_views.connect 'projects/:id/repository/revisions/:rev/raw/*path',
293
                               :action => 'entry', :format => 'raw'
294
      repository_views.connect 'projects/:id/repository/revisions/:rev/:action/*path',
295
                               :requirements => { 
296
                                   :action => /(browse|show|entry|changes|annotate|diff)/,
297
                                   :rev    => /[a-z0-9\.\-_]+/
298
                                 }
299
      repository_views.connect 'projects/:id/repository/raw/*path',
300
                               :action => 'entry', :format => 'raw'
301
      repository_views.connect 'projects/:id/repository/:action/*path',
302
                               :requirements => { :action => /(browse|show|entry|changes|annotate|diff)/ }
241
  get 'projects/:id/repository/:format(/*path(.:ext))', :to => 'repositories#entry', :format => /raw/
242
  get 'projects/:id/repository/:action(/*path(.:ext))', :controller => 'repositories', :action => /(browse|show|entry|changes|annotate|diff)/
243
  get 'projects/:id/repository', :to => 'repositories#show', :path => nil
303 244

  
304
      repository_views.connect 'projects/:id/repository/revision',
305
                               :action => 'revision'
245
  # additional routes for having the file name at the end of url
246
  match 'attachments/:id/:filename', :controller => 'attachments', :action => 'show', :id => /\d+/, :filename => /.*/, :via => :get
247
  match 'attachments/download/:id/:filename', :controller => 'attachments', :action => 'download', :id => /\d+/, :filename => /.*/, :via => :get
248
  match 'attachments/download/:id', :controller => 'attachments', :action => 'download', :id => /\d+/, :via => :get
249
  resources :attachments, :only => [:show, :destroy]
306 250

  
307
      repository_views.connect 'projects/:id/repository/:repository_id',
308
                               :action => 'show'
251
  resources :groups do
252
    member do
253
      get 'autocomplete_for_user'
309 254
    end
310 255
  end
311 256

  
312
  # additional routes for having the file name at the end of url
313
  map.connect 'attachments/:id/:filename', :controller => 'attachments',
314
              :action => 'show', :id => /\d+/, :filename => /.*/,
315
              :conditions => {:method => :get}
316
  map.connect 'attachments/download/:id/:filename', :controller => 'attachments',
317
              :action => 'download', :id => /\d+/, :filename => /.*/,
318
              :conditions => {:method => :get}
319
  map.connect 'attachments/download/:id', :controller => 'attachments',
320
              :action => 'download', :id => /\d+/,
321
              :conditions => {:method => :get}
322
  map.resources :attachments, :only => [:show, :destroy]
257
  match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users'
258
  match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user'
259
  match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post
260
  match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post
323 261

  
324
  map.resources :groups, :member => {:autocomplete_for_user => :get}
325
  map.group_users 'groups/:id/users', :controller => 'groups',
326
                  :action => 'add_users', :id => /\d+/,
327
                  :conditions => {:method => :post}
328
  map.group_user  'groups/:id/users/:user_id', :controller => 'groups',
329
                  :action => 'remove_user', :id => /\d+/,
330
                  :conditions => {:method => :delete}
331
  map.connect 'groups/destroy_membership/:id', :controller => 'groups',
332
              :action => 'destroy_membership', :id => /\d+/,
333
              :conditions => {:method => :post}
334
  map.connect 'groups/edit_membership/:id', :controller => 'groups',
335
              :action => 'edit_membership', :id => /\d+/,
336
              :conditions => {:method => :post}
262
  resources :trackers, :except => :show
263
  resources :issue_statuses, :except => :show do
264
    collection do
265
      post 'update_issue_done_ratio'
266
    end
267
  end
268
  resources :custom_fields, :except => :show
269
  resources :roles, :except => :show do
270
    collection do
271
      match 'permissions', :via => [:get, :post]
272
    end
273
  end
274
  resources :enumerations, :except => :show
337 275

  
338
  map.resources :trackers, :except => :show
339
  map.resources :issue_statuses, :except => :show, :collection => {:update_issue_done_ratio => :post}
340
  map.resources :custom_fields, :except => :show
341
  map.resources :roles, :except => :show, :collection => {:permissions => [:get, :post]}
342
  map.resources :enumerations, :except => :show
276
  get 'projects/:id/search', :controller => 'search', :action => 'index'
277
  get 'search', :controller => 'search', :action => 'index'
343 278

  
344
  map.connect 'projects/:id/search', :controller => 'search', :action => 'index', :conditions => {:method => :get}
345
  map.connect 'search', :controller => 'search', :action => 'index', :conditions => {:method => :get}
279
  match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post
346 280

  
347
  map.connect 'mail_handler', :controller => 'mail_handler',
348
              :action => 'index', :conditions => {:method => :post}
281
  match 'admin', :controller => 'admin', :action => 'index', :via => :get
282
  match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
283
  match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
284
  match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
285
  match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get
286
  match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post
349 287

  
350
  map.connect 'admin', :controller => 'admin', :action => 'index',
351
              :conditions => {:method => :get}
352
  map.connect 'admin/projects', :controller => 'admin', :action => 'projects',
353
              :conditions => {:method => :get}
354
  map.connect 'admin/plugins', :controller => 'admin', :action => 'plugins',
355
              :conditions => {:method => :get}
356
  map.connect 'admin/info', :controller => 'admin', :action => 'info',
357
              :conditions => {:method => :get}
358
  map.connect 'admin/test_email', :controller => 'admin', :action => 'test_email',
359
              :conditions => {:method => :get}
360
  map.connect 'admin/default_configuration', :controller => 'admin',
361
              :action => 'default_configuration', :conditions => {:method => :post}
288
  resources :auth_sources do
289
    member do
290
      get 'test_connection'
291
    end
292
  end
362 293

  
363
  map.resources :auth_sources, :member => {:test_connection => :get}
294
  match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
295
  match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
296
  match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post]
297
  match 'settings', :controller => 'settings', :action => 'index', :via => :get
298
  match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post]
299
  match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post]
364 300

  
365
  map.connect 'workflows', :controller => 'workflows',
366
              :action => 'index', :conditions => {:method => :get}
367
  map.connect 'workflows/edit', :controller => 'workflows',
368
              :action => 'edit', :conditions => {:method => [:get, :post]}
369
  map.connect 'workflows/copy', :controller => 'workflows',
370
              :action => 'copy', :conditions => {:method => [:get, :post]}
301
  match 'sys/projects', :to => 'sys#projects', :via => :get
302
  match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post
303
  match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => :get
371 304

  
372
  map.connect 'settings', :controller => 'settings',
373
              :action => 'index', :conditions => {:method => :get}
374
  map.connect 'settings/edit', :controller => 'settings',
375
              :action => 'edit', :conditions => {:method => [:get, :post]}
376
  map.connect 'settings/plugin/:id', :controller => 'settings',
377
              :action => 'plugin', :conditions => {:method => [:get, :post]}
305
  match 'uploads', :to => 'attachments#upload', :via => :post
378 306

  
379
  map.with_options :controller => 'sys' do |sys|
380
    sys.connect 'sys/projects.:format',
381
                :action => 'projects',
382
                :conditions => {:method => :get}
383
    sys.connect 'sys/projects/:id/repository.:format',
384
                :action => 'create_project_repository',
385
                :conditions => {:method => :post}
386
    sys.connect 'sys/fetch_changesets',
387
                :action => 'fetch_changesets',
388
                :conditions => {:method => :get}
307
  get 'robots.txt', :to => 'welcome#robots'
308

  
309
  Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
310
    file = File.join(plugin_dir, "config/routes.rb")
311
    if File.exists?(file)
312
      begin
313
        instance_eval File.read(file)
314
      rescue Exception => e
315
        puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
316
        exit 1
317
      end
318
    end
389 319
  end
390

  
391
  map.connect 'uploads.:format', :controller => 'attachments', :action => 'upload', :conditions => {:method => :post}
392

  
393
  map.connect 'robots.txt', :controller => 'welcome',
394
              :action => 'robots', :conditions => {:method => :get}
395

  
396
  # Used for OpenID
397
  map.root :controller => 'account', :action => 'login'
398 320
end

Also available in: Unified diff