subdirectory.patch

Jost Baron, 2013-05-13 20:24

Download (32.2 KB)

View differences:

config/routes.rb (working copy)
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18
Redmine::Utils::relative_url_root = ''
19

  
18 20
RedmineApp::Application.routes.draw do
19
  root :to => 'welcome#index', :as => 'home'
21
  scope ActionController::Base.relative_url_root do
22
    root :to => 'welcome#index', :as => 'home'
20 23

  
21
  match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post]
22
  match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post]
23
  match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register'
24
  match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post], :as => 'lost_password'
25
  match 'account/activate', :to => 'account#activate', :via => :get
24
    match 'login', :to => 'account#login', :as => 'signin', :via => [:get, :post]
25
    match 'logout', :to => 'account#logout', :as => 'signout', :via => [:get, :post]
26
    match 'account/register', :to => 'account#register', :via => [:get, :post], :as => 'register'
27
    match 'account/lost_password', :to => 'account#lost_password', :via => [:get, :post], :as => 'lost_password'
28
    match 'account/activate', :to => 'account#activate', :via => :get
26 29

  
27
  match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post, :put]
28
  match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put]
29
  match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put]
30
  match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put]
30
    match '/news/preview', :controller => 'previews', :action => 'news', :as => 'preview_news', :via => [:get, :post, :put]
31
    match '/issues/preview/new/:project_id', :to => 'previews#issue', :as => 'preview_new_issue', :via => [:get, :post, :put]
32
    match '/issues/preview/edit/:id', :to => 'previews#issue', :as => 'preview_edit_issue', :via => [:get, :post, :put]
33
    match '/issues/preview', :to => 'previews#issue', :as => 'preview_issue', :via => [:get, :post, :put]
31 34

  
32
  match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post
33
  match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post]
35
    match 'projects/:id/wiki', :to => 'wikis#edit', :via => :post
36
    match 'projects/:id/wiki/destroy', :to => 'wikis#destroy', :via => [:get, :post]
34 37

  
35
  match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message'
36
  get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message'
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'
38
    match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message'
39
    get 'boards/:board_id/topics/:id', :to => 'messages#show', :as => 'board_message'
40
    match 'boards/:board_id/topics/quote/:id', :to => 'messages#quote', :via => [:get, :post]
41
    get 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
39 42

  
40
  post 'boards/:board_id/topics/preview', :to => 'messages#preview', :as => 'preview_board_message'
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'
43
    post 'boards/:board_id/topics/preview', :to => 'messages#preview', :as => 'preview_board_message'
44
    post 'boards/:board_id/topics/:id/replies', :to => 'messages#reply'
45
    post 'boards/:board_id/topics/:id/edit', :to => 'messages#edit'
46
    post 'boards/:board_id/topics/:id/destroy', :to => 'messages#destroy'
44 47

  
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', :via => [:get, :post]
48
  match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get
49
  match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
48
    # Misc issue routes. TODO: move into resources
49
    match '/issues/auto_complete', :to => 'auto_completes#issues', :via => :get, :as => 'auto_complete_issues'
50
    match '/issues/context_menu', :to => 'context_menus#issues', :as => 'issues_context_menu', :via => [:get, :post]
51
    match '/issues/changes', :to => 'journals#index', :as => 'issue_changes', :via => :get
52
    match '/issues/:id/quoted', :to => 'journals#new', :id => /\d+/, :via => :post, :as => 'quoted_issue'
50 53

  
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]
54
    match '/journals/diff/:id', :to => 'journals#diff', :id => /\d+/, :via => :get
55
    match '/journals/edit/:id', :to => 'journals#edit', :id => /\d+/, :via => [:get, :post]
53 56

  
54
  get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt'
55
  get '/issues/gantt', :to => 'gantts#show'
57
    get '/projects/:project_id/issues/gantt', :to => 'gantts#show', :as => 'project_gantt'
58
    get '/issues/gantt', :to => 'gantts#show'
56 59

  
57
  get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar'
58
  get '/issues/calendar', :to => 'calendars#show'
60
    get '/projects/:project_id/issues/calendar', :to => 'calendars#show', :as => 'project_calendar'
61
    get '/issues/calendar', :to => 'calendars#show'
59 62

  
60
  get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
61
  get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
63
    get 'projects/:id/issues/report', :to => 'reports#issue_report', :as => 'project_issues_report'
64
    get 'projects/:id/issues/report/:detail', :to => 'reports#issue_report_details', :as => 'project_issues_report_details'
62 65

  
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
66
    match 'my/account', :controller => 'my', :action => 'account', :via => [:get, :post]
67
    match 'my/account/destroy', :controller => 'my', :action => 'destroy', :via => [:get, :post]
68
    match 'my/page', :controller => 'my', :action => 'page', :via => :get
69
    match 'my', :controller => 'my', :action => 'index', :via => :get # Redirects to my/page
70
    match 'my/reset_rss_key', :controller => 'my', :action => 'reset_rss_key', :via => :post
71
    match 'my/reset_api_key', :controller => 'my', :action => 'reset_api_key', :via => :post
72
    match 'my/password', :controller => 'my', :action => 'password', :via => [:get, :post]
73
    match 'my/page_layout', :controller => 'my', :action => 'page_layout', :via => :get
74
    match 'my/add_block', :controller => 'my', :action => 'add_block', :via => :post
75
    match 'my/remove_block', :controller => 'my', :action => 'remove_block', :via => :post
76
    match 'my/order_blocks', :controller => 'my', :action => 'order_blocks', :via => :post
74 77

  
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'
78
    resources :users
79
    match 'users/:id/memberships/:membership_id', :to => 'users#edit_membership', :via => :put, :as => 'user_membership'
80
    match 'users/:id/memberships/:membership_id', :to => 'users#destroy_membership', :via => :delete
81
    match 'users/:id/memberships', :to => 'users#edit_membership', :via => :post, :as => 'user_memberships'
79 82

  
80
  post 'watchers/watch', :to => 'watchers#watch', :as => 'watch'
81
  delete 'watchers/watch', :to => 'watchers#unwatch'
82
  get 'watchers/new', :to => 'watchers#new'
83
  post 'watchers', :to => 'watchers#create'
84
  post 'watchers/append', :to => 'watchers#append'
85
  delete 'watchers', :to => 'watchers#destroy'
86
  get 'watchers/autocomplete_for_user', :to => 'watchers#autocomplete_for_user'
87
  # Specific routes for issue watchers API
88
  post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue'
89
  delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
83
    post 'watchers/watch', :to => 'watchers#watch', :as => 'watch'
84
    delete 'watchers/watch', :to => 'watchers#unwatch'
85
    get 'watchers/new', :to => 'watchers#new'
86
    post 'watchers', :to => 'watchers#create'
87
    post 'watchers/append', :to => 'watchers#append'
88
    delete 'watchers', :to => 'watchers#destroy'
89
    get 'watchers/autocomplete_for_user', :to => 'watchers#autocomplete_for_user'
90
    # Specific routes for issue watchers API
91
    post 'issues/:object_id/watchers', :to => 'watchers#create', :object_type => 'issue'
92
    delete 'issues/:object_id/watchers/:user_id' => 'watchers#destroy', :object_type => 'issue'
90 93

  
91
  resources :projects do
92
    member do
93
      get 'settings(/:tab)', :action => 'settings', :as => 'settings'
94
      post 'modules'
95
      post 'archive'
96
      post 'unarchive'
97
      post 'close'
98
      post 'reopen'
99
      match 'copy', :via => [:get, :post]
100
    end
94
    resources :projects do
95
      member do
96
        get 'settings(/:tab)', :action => 'settings', :as => 'settings'
97
        post 'modules'
98
        post 'archive'
99
        post 'unarchive'
100
        post 'close'
101
        post 'reopen'
102
        match 'copy', :via => [:get, :post]
103
      end
101 104

  
102
    resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
103
      collection do
104
        get 'autocomplete'
105
      resources :memberships, :shallow => true, :shallow_path => ActionController::Base.relative_url_root, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
106
        collection do
107
          get 'autocomplete'
108
        end
105 109
      end
106
    end
107 110

  
108
    resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy]
111
      resource :enumerations, :controller => 'project_enumerations', :only => [:update, :destroy]
109 112

  
110
    get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue'
111
    resources :issues, :only => [:index, :new, :create] do
112
      resources :time_entries, :controller => 'timelog' do
113
        collection do
114
          get 'report'
113
      get 'issues/:copy_from/copy', :to => 'issues#new', :as => 'copy_issue'
114
      resources :issues, :only => [:index, :new, :create] do
115
        resources :time_entries, :controller => 'timelog' do
116
          collection do
117
            get 'report'
118
          end
115 119
        end
116 120
      end
117
    end
118
    # issue form update
119
    match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form'
121
      # issue form update
122
      match 'issues/update_form', :controller => 'issues', :action => 'update_form', :via => [:put, :post], :as => 'issue_form'
120 123

  
121
    resources :files, :only => [:index, :new, :create]
124
      resources :files, :only => [:index, :new, :create]
122 125

  
123
    resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
124
      collection do
125
        put 'close_completed'
126
      resources :versions, :except => [:index, :show, :edit, :update, :destroy] do
127
        collection do
128
          put 'close_completed'
129
        end
126 130
      end
127
    end
128
    get 'versions.:format', :to => 'versions#index'
129
    get 'roadmap', :to => 'versions#index', :format => false
130
    get 'versions', :to => 'versions#index'
131
      get 'versions.:format', :to => 'versions#index'
132
      get 'roadmap', :to => 'versions#index', :format => false
133
      get 'versions', :to => 'versions#index'
131 134

  
132
    resources :news, :except => [:show, :edit, :update, :destroy]
133
    resources :time_entries, :controller => 'timelog' do
134
      get 'report', :on => :collection
135
    end
136
    resources :queries, :only => [:new, :create]
137
    resources :issue_categories, :shallow => true
138
    resources :documents, :except => [:show, :edit, :update, :destroy]
139
    resources :boards
140
    resources :repositories, :shallow => true, :except => [:index, :show] do
141
      member do
142
        match 'committers', :via => [:get, :post]
135
      resources :news, :except => [:show, :edit, :update, :destroy]
136
      resources :time_entries, :controller => 'timelog' do
137
        get 'report', :on => :collection
143 138
      end
144
    end
139
      resources :queries, :only => [:new, :create]
140
      resources :issue_categories, :shallow => true, :shallow_path => ActionController::Base.relative_url_root
141
      resources :documents, :except => [:show, :edit, :update, :destroy]
142
      resources :boards
143
      resources :repositories, :shallow => true, :shallow_path => ActionController::Base.relative_url_root, :except => [:index, :show] do
144
        member do
145
          match 'committers', :via => [:get, :post]
146
        end
147
      end
145 148

  
146
    match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
147
    resources :wiki, :except => [:index, :new, :create], :as => 'wiki_page' do
148
      member do
149
        get 'rename'
150
        post 'rename'
151
        get 'history'
152
        get 'diff'
153
        match 'preview', :via => [:post, :put]
154
        post 'protect'
155
        post 'add_attachment'
149
      match 'wiki/index', :controller => 'wiki', :action => 'index', :via => :get
150
      resources :wiki, :except => [:index, :new, :create], :as => 'wiki_page' do
151
        member do
152
          get 'rename'
153
          post 'rename'
154
          get 'history'
155
          get 'diff'
156
          match 'preview', :via => [:post, :put]
157
          post 'protect'
158
          post 'add_attachment'
159
        end
160
        collection do
161
          get 'export'
162
          get 'date_index'
163
        end
156 164
      end
157
      collection do
158
        get 'export'
159
        get 'date_index'
160
      end
165
      match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
166
      get 'wiki/:id/:version', :to => 'wiki#show', :constraints => {:version => /\d+/}
167
      delete 'wiki/:id/:version', :to => 'wiki#destroy_version'
168
      get 'wiki/:id/:version/annotate', :to => 'wiki#annotate'
169
      get 'wiki/:id/:version/diff', :to => 'wiki#diff'
161 170
    end
162
    match 'wiki', :controller => 'wiki', :action => 'show', :via => :get
163
    get 'wiki/:id/:version', :to => 'wiki#show', :constraints => {:version => /\d+/}
164
    delete 'wiki/:id/:version', :to => 'wiki#destroy_version'
165
    get 'wiki/:id/:version/annotate', :to => 'wiki#annotate'
166
    get 'wiki/:id/:version/diff', :to => 'wiki#diff'
167
  end
168 171

  
169
  resources :issues do
170
    collection do
171
      match 'bulk_edit', :via => [:get, :post]
172
      post 'bulk_update'
173
    end
174
    resources :time_entries, :controller => 'timelog' do
172
    resources :issues do
175 173
      collection do
176
        get 'report'
174
        match 'bulk_edit', :via => [:get, :post]
175
        post 'bulk_update'
177 176
      end
177
      resources :time_entries, :controller => 'timelog' do
178
        collection do
179
          get 'report'
180
        end
181
      end
182
      resources :relations, :shallow => true, :shallow_path => ActionController::Base.relative_url_root, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
178 183
    end
179
    resources :relations, :shallow => true, :controller => 'issue_relations', :only => [:index, :show, :create, :destroy]
180
  end
181
  match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete
184
    match '/issues', :controller => 'issues', :action => 'destroy', :via => :delete
182 185

  
183
  resources :queries, :except => [:show]
186
    resources :queries, :except => [:show]
184 187

  
185
  resources :news, :only => [:index, :show, :edit, :update, :destroy]
186
  match '/news/:id/comments', :to => 'comments#create', :via => :post
187
  match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete
188
    resources :news, :only => [:index, :show, :edit, :update, :destroy]
189
    match '/news/:id/comments', :to => 'comments#create', :via => :post
190
    match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete
188 191

  
189
  resources :versions, :only => [:show, :edit, :update, :destroy] do
190
    post 'status_by', :on => :member
191
  end
192
    resources :versions, :only => [:show, :edit, :update, :destroy] do
193
      post 'status_by', :on => :member
194
    end
192 195

  
193
  resources :documents, :only => [:show, :edit, :update, :destroy] do
194
    post 'add_attachment', :on => :member
195
  end
196
    resources :documents, :only => [:show, :edit, :update, :destroy] do
197
      post 'add_attachment', :on => :member
198
    end
196 199

  
197
  match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post]
200
    match '/time_entries/context_menu', :to => 'context_menus#time_entries', :as => :time_entries_context_menu, :via => [:get, :post]
198 201

  
199
  resources :time_entries, :controller => 'timelog', :except => :destroy do
200
    collection do
201
      get 'report'
202
      get 'bulk_edit'
203
      post 'bulk_update'
202
    resources :time_entries, :controller => 'timelog', :except => :destroy do
203
      collection do
204
        get 'report'
205
        get 'bulk_edit'
206
        post 'bulk_update'
207
      end
204 208
    end
205
  end
206
  match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
207
  # TODO: delete /time_entries for bulk deletion
208
  match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete
209
    match '/time_entries/:id', :to => 'timelog#destroy', :via => :delete, :id => /\d+/
210
    # TODO: delete /time_entries for bulk deletion
211
    match '/time_entries/destroy', :to => 'timelog#destroy', :via => :delete
209 212

  
210
  get 'projects/:id/activity', :to => 'activities#index'
211
  get 'projects/:id/activity.:format', :to => 'activities#index'
212
  get 'activity', :to => 'activities#index'
213
    get 'projects/:id/activity', :to => 'activities#index'
214
    get 'projects/:id/activity.:format', :to => 'activities#index'
215
    get 'activity', :to => 'activities#index'
213 216

  
214
  # repositories routes
215
  get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
216
  get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
217
    # repositories routes
218
    get 'projects/:id/repository/:repository_id/statistics', :to => 'repositories#stats'
219
    get 'projects/:id/repository/:repository_id/graph', :to => 'repositories#graph'
217 220

  
218
  get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))',
219
      :to => 'repositories#changes'
221
    get 'projects/:id/repository/:repository_id/changes(/*path(.:ext))',
222
        :to => 'repositories#changes'
220 223

  
221
  get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
222
  get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
223
  post   'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
224
  delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
225
  get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
226
  get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))',
227
      :controller => 'repositories',
228
      :format => false,
229
      :constraints => {
230
            :action => /(browse|show|entry|raw|annotate|diff)/,
231
            :rev    => /[a-z0-9\.\-_]+/
232
          }
224
    get 'projects/:id/repository/:repository_id/revisions/:rev', :to => 'repositories#revision'
225
    get 'projects/:id/repository/:repository_id/revision', :to => 'repositories#revision'
226
    post   'projects/:id/repository/:repository_id/revisions/:rev/issues', :to => 'repositories#add_related_issue'
227
    delete 'projects/:id/repository/:repository_id/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
228
    get 'projects/:id/repository/:repository_id/revisions', :to => 'repositories#revisions'
229
    get 'projects/:id/repository/:repository_id/revisions/:rev/:action(/*path(.:ext))',
230
        :controller => 'repositories',
231
        :format => false,
232
        :constraints => {
233
              :action => /(browse|show|entry|raw|annotate|diff)/,
234
              :rev    => /[a-z0-9\.\-_]+/
235
        }
233 236

  
234
  get 'projects/:id/repository/statistics', :to => 'repositories#stats'
235
  get 'projects/:id/repository/graph', :to => 'repositories#graph'
237
    get 'projects/:id/repository/statistics', :to => 'repositories#stats'
238
    get 'projects/:id/repository/graph', :to => 'repositories#graph'
236 239

  
237
  get 'projects/:id/repository/changes(/*path(.:ext))',
238
      :to => 'repositories#changes'
240
    get 'projects/:id/repository/changes(/*path(.:ext))',
241
        :to => 'repositories#changes'
239 242

  
240
  get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
241
  get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
242
  get 'projects/:id/repository/revision', :to => 'repositories#revision'
243
  post   'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
244
  delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
245
  get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))',
246
      :controller => 'repositories',
247
      :format => false,
248
      :constraints => {
249
            :action => /(browse|show|entry|raw|annotate|diff)/,
250
            :rev    => /[a-z0-9\.\-_]+/
251
          }
252
  get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))',
253
      :controller => 'repositories',
254
      :action => /(browse|show|entry|raw|changes|annotate|diff)/
255
  get 'projects/:id/repository/:action(/*path(.:ext))',
256
      :controller => 'repositories',
257
      :action => /(browse|show|entry|raw|changes|annotate|diff)/
243
    get 'projects/:id/repository/revisions', :to => 'repositories#revisions'
244
    get 'projects/:id/repository/revisions/:rev', :to => 'repositories#revision'
245
    get 'projects/:id/repository/revision', :to => 'repositories#revision'
246
    post   'projects/:id/repository/revisions/:rev/issues', :to => 'repositories#add_related_issue'
247
    delete 'projects/:id/repository/revisions/:rev/issues/:issue_id', :to => 'repositories#remove_related_issue'
248
    get 'projects/:id/repository/revisions/:rev/:action(/*path(.:ext))',
249
        :controller => 'repositories',
250
        :format => false,
251
        :constraints => {
252
              :action => /(browse|show|entry|raw|annotate|diff)/,
253
              :rev    => /[a-z0-9\.\-_]+/
254
        }
255
    get 'projects/:id/repository/:repository_id/:action(/*path(.:ext))',
256
        :controller => 'repositories',
257
        :action => /(browse|show|entry|raw|changes|annotate|diff)/
258
    get 'projects/:id/repository/:action(/*path(.:ext))',
259
        :controller => 'repositories',
260
        :action => /(browse|show|entry|raw|changes|annotate|diff)/
258 261

  
259
  get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
260
  get 'projects/:id/repository', :to => 'repositories#show', :path => nil
262
    get 'projects/:id/repository/:repository_id', :to => 'repositories#show', :path => nil
263
    get 'projects/:id/repository', :to => 'repositories#show', :path => nil
261 264

  
262
  # additional routes for having the file name at the end of url
263
  get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
264
  get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
265
  get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
266
  get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
267
  resources :attachments, :only => [:show, :destroy]
265
    # additional routes for having the file name at the end of url
266
    get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
267
    get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'
268
    get 'attachments/download/:id', :to => 'attachments#download', :id => /\d+/
269
    get 'attachments/thumbnail/:id(/:size)', :to => 'attachments#thumbnail', :id => /\d+/, :size => /\d+/, :as => 'thumbnail'
270
    resources :attachments, :only => [:show, :destroy]
268 271

  
269
  resources :groups do
270
    member do
271
      get 'autocomplete_for_user'
272
    resources :groups do
273
      member do
274
        get 'autocomplete_for_user'
275
      end
272 276
    end
273
  end
274 277

  
275
  match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users'
276
  match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user'
277
  match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post
278
  match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post
278
    match 'groups/:id/users', :controller => 'groups', :action => 'add_users', :id => /\d+/, :via => :post, :as => 'group_users'
279
    match 'groups/:id/users/:user_id', :controller => 'groups', :action => 'remove_user', :id => /\d+/, :via => :delete, :as => 'group_user'
280
    match 'groups/destroy_membership/:id', :controller => 'groups', :action => 'destroy_membership', :id => /\d+/, :via => :post
281
    match 'groups/edit_membership/:id', :controller => 'groups', :action => 'edit_membership', :id => /\d+/, :via => :post
279 282

  
280
  resources :trackers, :except => :show do
281
    collection do
282
      match 'fields', :via => [:get, :post]
283
    resources :trackers, :except => :show do
284
      collection do
285
        match 'fields', :via => [:get, :post]
286
      end
283 287
    end
284
  end
285
  resources :issue_statuses, :except => :show do
286
    collection do
287
      post 'update_issue_done_ratio'
288
    resources :issue_statuses, :except => :show do
289
      collection do
290
        post 'update_issue_done_ratio'
291
      end
288 292
    end
289
  end
290
  resources :custom_fields, :except => :show
291
  resources :roles do
292
    collection do
293
      match 'permissions', :via => [:get, :post]
293
    resources :custom_fields, :except => :show
294
    resources :roles do
295
      collection do
296
        match 'permissions', :via => [:get, :post]
297
      end
294 298
    end
295
  end
296
  resources :enumerations, :except => :show
297
  match 'enumerations/:type', :to => 'enumerations#index', :via => :get
299
    resources :enumerations, :except => :show
300
    match 'enumerations/:type', :to => 'enumerations#index', :via => :get
298 301

  
299
  get 'projects/:id/search', :controller => 'search', :action => 'index'
300
  get 'search', :controller => 'search', :action => 'index'
302
    get 'projects/:id/search', :controller => 'search', :action => 'index'
303
    get 'search', :controller => 'search', :action => 'index'
301 304

  
302
  match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post
305
    match 'mail_handler', :controller => 'mail_handler', :action => 'index', :via => :post
303 306

  
304
  match 'admin', :controller => 'admin', :action => 'index', :via => :get
305
  match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
306
  match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
307
  match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
308
  match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get
309
  match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post
307
    match 'admin', :controller => 'admin', :action => 'index', :via => :get
308
    match 'admin/projects', :controller => 'admin', :action => 'projects', :via => :get
309
    match 'admin/plugins', :controller => 'admin', :action => 'plugins', :via => :get
310
    match 'admin/info', :controller => 'admin', :action => 'info', :via => :get
311
    match 'admin/test_email', :controller => 'admin', :action => 'test_email', :via => :get
312
    match 'admin/default_configuration', :controller => 'admin', :action => 'default_configuration', :via => :post
310 313

  
311
  resources :auth_sources do
312
    member do
313
      get 'test_connection', :as => 'try_connection'
314
    resources :auth_sources do
315
      member do
316
        get 'test_connection', :as => 'try_connection'
317
      end
318
      collection do
319
        get 'autocomplete_for_new_user'
320
      end
314 321
    end
315
    collection do
316
      get 'autocomplete_for_new_user'
317
    end
318
  end
319 322

  
320
  match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
321
  match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
322
  match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post]
323
  match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post]
324
  match 'settings', :controller => 'settings', :action => 'index', :via => :get
325
  match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post]
326
  match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post], :as => 'plugin_settings'
323
    match 'workflows', :controller => 'workflows', :action => 'index', :via => :get
324
    match 'workflows/edit', :controller => 'workflows', :action => 'edit', :via => [:get, :post]
325
    match 'workflows/permissions', :controller => 'workflows', :action => 'permissions', :via => [:get, :post]
326
    match 'workflows/copy', :controller => 'workflows', :action => 'copy', :via => [:get, :post]
327
    match 'settings', :controller => 'settings', :action => 'index', :via => :get
328
    match 'settings/edit', :controller => 'settings', :action => 'edit', :via => [:get, :post]
329
    match 'settings/plugin/:id', :controller => 'settings', :action => 'plugin', :via => [:get, :post], :as => 'plugin_settings'
327 330

  
328
  match 'sys/projects', :to => 'sys#projects', :via => :get
329
  match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post
330
  match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => :get
331
    match 'sys/projects', :to => 'sys#projects', :via => :get
332
    match 'sys/projects/:id/repository', :to => 'sys#create_project_repository', :via => :post
333
    match 'sys/fetch_changesets', :to => 'sys#fetch_changesets', :via => :get
331 334

  
332
  match 'uploads', :to => 'attachments#upload', :via => :post
335
    match 'uploads', :to => 'attachments#upload', :via => :post
333 336

  
334
  get 'robots.txt', :to => 'welcome#robots'
337
    get 'robots.txt', :to => 'welcome#robots'
335 338

  
336
  Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
337
    file = File.join(plugin_dir, "config/routes.rb")
338
    if File.exists?(file)
339
      begin
340
        instance_eval File.read(file)
341
      rescue Exception => e
342
        puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
343
        exit 1
339
    Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir|
340
      file = File.join(plugin_dir, "config/routes.rb")
341
      if File.exists?(file)
342
        begin
343
          instance_eval File.read(file)
344
        rescue Exception => e
345
          puts "An error occurred while loading the routes definition of #{File.basename(plugin_dir)} plugin (#{file}): #{e.message}."
346
          exit 1
347
        end
344 348
      end
345 349
    end
346 350
  end