routes.rb 10.9 KB
Newer Older
D
sidekiq  
Dmitriy Zaporozhets 已提交
1
require 'sidekiq/web'
2
require 'api/api'
D
sidekiq  
Dmitriy Zaporozhets 已提交
3

G
gitlabhq 已提交
4
Gitlab::Application.routes.draw do
V
Valery Sizov 已提交
5
  use_doorkeeper do
6 7 8
    controllers applications: 'oauth/applications',
                authorized_applications: 'oauth/authorized_applications',
                authorizations: 'oauth/authorizations'
V
Valery Sizov 已提交
9
  end
10 11 12
  #
  # Search
  #
13 14
  get 'search' => 'search#show'
  get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
V
Valery Sizov 已提交
15

16
  # API
17 18
  API::API.logger Rails.logger
  mount API::API => '/api'
19

G
GitLab 已提交
20
  # Get all keys of user
21 22
  get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ }

23
  constraint = lambda { |request| request.env['warden'].authenticate? and request.env['warden'].user.admin? }
D
sidekiq  
Dmitriy Zaporozhets 已提交
24
  constraints constraint do
25
    mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
D
sidekiq  
Dmitriy Zaporozhets 已提交
26
  end
A
Ariejan de Vroom 已提交
27

28 29
  # Enable Grack support
  mount Grack::Bundle.new({
30
    git_path:     Gitlab.config.git.bin_path,
31 32 33
    project_root: Gitlab.config.gitlab_shell.repos_path,
    upload_pack:  Gitlab.config.gitlab_shell.upload_pack,
    receive_pack: Gitlab.config.gitlab_shell.receive_pack
34
  }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post]
35

36 37 38
  #
  # Help
  #
J
Job van der Voort 已提交
39 40

  get 'help'                  => 'help#index'
41
  get 'help/:category/:file'  => 'help#show', as: :help_page
M
Marin Jankovski 已提交
42
  get 'help/shortcuts'
43

A
Andrew8xx8 已提交
44 45 46 47 48
  #
  # Global snippets
  #
  resources :snippets do
    member do
49
      get 'raw'
A
Andrew8xx8 已提交
50 51
    end
  end
52
  get '/s/:username' => 'snippets#user_index', as: :user_snippets, constraints: { username: /.*/ }
A
Andrew8xx8 已提交
53

M
Marin Jankovski 已提交
54

V
Valery Sizov 已提交
55
  #
56
  # Import
V
Valery Sizov 已提交
57
  #
58 59
  namespace :import do
    resource :github, only: [:create, :new], controller: :github do
V
Valery Sizov 已提交
60 61 62 63 64
      get :status
      get :callback
      get :jobs
    end

65
    resource :gitlab, only: [:create, :new], controller: :gitlab do
V
Valery Sizov 已提交
66 67 68 69
      get :status
      get :callback
      get :jobs
    end
V
Valery Sizov 已提交
70
  end
M
Marin Jankovski 已提交
71

72 73 74
  #
  # Uploads
  #
M
Marin Jankovski 已提交
75

76 77 78 79 80 81 82 83 84
  scope path: :uploads do
    # Note attachments and User/Group/Project avatars
    get ":model/:mounted_as/:id/:filename", to: "uploads#show", 
      constraints: { model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: /.+/ }

    # Project markdown uploads
    get ":id/:secret/:filename", to: "projects/uploads#show", 
      constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/, filename: /.+/ }
  end
V
Valery Sizov 已提交
85

86
  #
Y
Yatish Mehta 已提交
87
  # Explore area
88
  #
D
Dmitriy Zaporozhets 已提交
89 90 91 92
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
93
        get :starred
D
Dmitriy Zaporozhets 已提交
94 95 96
      end
    end

97
    resources :groups, only: [:index]
98
    root to: 'projects#trending'
99 100
  end

D
Dmitriy Zaporozhets 已提交
101
  # Compatibility with old routing
102 103
  get 'public' => 'explore/projects#index'
  get 'public/projects' => 'explore/projects#index'
D
Dmitriy Zaporozhets 已提交
104

105 106 107
  #
  # Attachments serving
  #
108
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
109

110 111 112
  #
  # Admin Area
  #
N
Nihad Abbasov 已提交
113
  namespace :admin do
114
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
115
      resources :keys, only: [:show, :destroy]
116
      member do
D
Dmitriy Zaporozhets 已提交
117
        put :team_update
118 119
        put :block
        put :unblock
120
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
D
Dmitriy Zaporozhets 已提交
121 122
      end
    end
A
Andrey Kumanyaev 已提交
123

V
Valery Sizov 已提交
124 125
    resources :applications

126 127
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
A
Andrey Kumanyaev 已提交
128
        put :project_teams_update
129
      end
A
Andrey Kumanyaev 已提交
130
    end
A
Andrey Kumanyaev 已提交
131

R
Robert Speicher 已提交
132
    resources :hooks, only: [:index, :create, :destroy] do
V
Valeriy Sizov 已提交
133 134
      get :test
    end
A
Andrey Kumanyaev 已提交
135

136
    resources :broadcast_messages, only: [:index, :create, :destroy]
137
    resource :logs, only: [:show]
138
    resource :background_jobs, controller: 'background_jobs', only: [:show]
139 140 141 142 143 144 145

    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show] do
      member do
        put :transfer
      end
    end

M
Marin Jankovski 已提交
146 147 148
    resource :application_settings, only: [:show, :update] do
      resources :services
    end
149

150
    root to: 'dashboard#index'
G
gitlabhq 已提交
151 152
  end

R
randx 已提交
153 154 155
  #
  # Profile Area
  #
156 157 158 159
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design
D
Dmitriy Zaporozhets 已提交
160
      get :applications
161 162 163 164

      put :reset_private_token
      put :update_username
    end
D
Dmitriy Zaporozhets 已提交
165

166
    scope module: :profiles do
167
      resource :account, only: [:show, :update]
168
      resource :notifications, only: [:show, :update]
169 170 171 172 173
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
174
      resources :keys
175
      resources :emails, only: [:index, :create, :destroy]
176 177 178 179 180
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
181
      resource :avatar, only: [:destroy]
182
    end
183
  end
R
Robert Speicher 已提交
184

185 186 187
  get 'u/:username/calendar' => 'users#calendar', as: :user_calendar,
      constraints: { username: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }

188 189
  get '/u/:username' => 'users#show', as: :user,
      constraints: { username: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }
D
Dmitriy Zaporozhets 已提交
190

R
randx 已提交
191 192 193
  #
  # Dashboard Area
  #
194
  resource :dashboard, controller: 'dashboard', only: [:show] do
D
Dmitriy Zaporozhets 已提交
195 196 197 198 199 200
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
G
gitlabhq 已提交
201

R
randx 已提交
202 203 204
  #
  # Groups Area
  #
205
  resources :groups, constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }  do
R
randx 已提交
206 207 208
    member do
      get :issues
      get :merge_requests
209
      get :members
D
Dmitriy Zaporozhets 已提交
210
      get :projects
R
randx 已提交
211
    end
212

S
Steven Thonus 已提交
213
    scope module: :groups do
214
      resources :group_members, only: [:create, :update, :destroy]
S
Steven Thonus 已提交
215
      resource :avatar, only: [:destroy]
216
      resources :milestones
S
Steven Thonus 已提交
217
    end
R
randx 已提交
218 219
  end

R
Robert Speicher 已提交
220
  resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
221

222
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :sessions, confirmations: :confirmations }
G
gitlabhq 已提交
223

224
  devise_scope :user do
225
    get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
226
  end
227 228 229
  #
  # Project Area
  #
230
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: '/' do
231 232
    member do
      put :transfer
233 234
      post :archive
      post :unarchive
235
      post :upload_image
C
Ciro Santilli 已提交
236
      post :toggle_star
237
      post :markdown_preview
238
      get :autocomplete_sources
239 240
    end

241
    scope module: :projects do
242
      # Blob routes:
243 244 245 246 247
      get '/new/:id', to: 'blob#new', constraints: { id: /.+/ }, as: 'new_blob'
      post '/create/:id', to: 'blob#create', constraints: { id: /.+/ }, as: 'create_blob'
      get '/edit/:id', to: 'blob#edit', constraints: { id: /.+/ }, as: 'edit_blob'
      put '/update/:id', to: 'blob#update', constraints: { id: /.+/ }, as: 'update_blob'
      post '/preview/:id', to: 'blob#preview', constraints: { id: /.+/ }, as: 'preview_blob'
248

249
      resources :blob, only: [:show, :destroy], constraints: { id: /.+/, format: false } do
S
skv 已提交
250 251
        get :diff, on: :member
      end
252

253 254
      resources :raw,       only: [:show], constraints: { id: /.+/ }
      resources :tree,      only: [:show], constraints: { id: /.+/, format: /(html|js)/ }
255
      resource  :avatar,    only: [:show, :destroy]
256

V
Valery Sizov 已提交
257
      resources :commit,    only: [:show], constraints: { id: /[[:alnum:]]{6,40}/ } do
258 259 260
        get :branches, on: :member
      end

V
Valery Sizov 已提交
261
      resources :commits,   only: [:show], constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }
262
      resources :compare,   only: [:index, :create]
263 264 265
      resources :blame,     only: [:show], constraints: { id: /.+/ }
      resources :network,   only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ }
      resources :graphs,    only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } do
266 267 268 269
        member do
          get :commits
        end
      end
270

271
      get '/compare/:from...:to' => 'compare#show', :as => 'compare',
272
          :constraints => { from: /.+/, to: /.+/ }
273

274
      resources :snippets, constraints: { id: /\d+/ } do
275
        member do
276
          get 'raw'
277
        end
278
      end
279

280
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: { id: /[a-zA-Z.0-9_\-\/]+/ } do
281 282 283 284 285
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
D
Dmitriy Zaporozhets 已提交
286

287
        member do
288
          get 'history'
289
        end
V
Valery Sizov 已提交
290
      end
V
Valery Sizov 已提交
291

292
      resource :fork, only: [:new, :create]
293
      resource :import, only: [:new, :create, :show]
294

295
      resource :repository, only: [:show, :create] do
296
        member do
297
          get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
298
        end
D
Dmitriy Zaporozhets 已提交
299
      end
300

301 302 303 304
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
D
Dmitriy Zaporozhets 已提交
305 306
      end

307
      resources :deploy_keys, constraints: { id: /\d+/ } do
308 309 310 311
        member do
          put :enable
          put :disable
        end
312 313
      end

314
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
315
      resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
316
      resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
M
miks 已提交
317

318 319
      resources :refs, only: [] do
        collection do
320
          get 'switch'
321
        end
G
gitlabhq 已提交
322

323 324
        member do
          # tree viewer logs
325
          get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex }
326 327 328 329
          get 'logs_tree/:path' => 'refs#logs_tree', as: :logs_file, constraints: {
            id: Gitlab::Regex.git_reference_regex,
            path: /.*/
          }
330
        end
G
gitlabhq 已提交
331
      end
G
gitlabhq 已提交
332

333
      resources :merge_requests, constraints: { id: /\d+/ }, except: [:destroy] do
334 335
        member do
          get :diffs
336
          post :automerge
337 338 339
          get :automerge_check
          get :ci_status
        end
340

341 342 343
        collection do
          get :branch_from
          get :branch_to
I
Izaak Alpert 已提交
344
          get :update_branches
345
        end
346
      end
347

348
      resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do
349 350 351
        member do
          get :test
        end
352
      end
353

354
      resources :team, controller: 'team_members', only: [:index]
355
      resources :milestones, except: [:destroy], constraints: { id: /\d+/ } do
D
Dmitriy Zaporozhets 已提交
356 357
        member do
          put :sort_issues
358
          put :sort_merge_requests
D
Dmitriy Zaporozhets 已提交
359 360
        end
      end
361

362
      resources :labels, constraints: { id: /\d+/ } do
363 364 365
        collection do
          post :generate
        end
366 367
      end

368
      resources :issues, constraints: { id: /\d+/ }, except: [:destroy] do
369 370 371
        collection do
          post  :bulk_update
        end
A
Adam Leonard 已提交
372
      end
R
Robert Speicher 已提交
373

374
      resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
375
        collection do
376
          delete :leave
D
Dmitriy Zaporozhets 已提交
377

378 379 380 381 382
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
D
Dmitriy Zaporozhets 已提交
383 384
      end

385
      resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do
386
        member do
387
          delete :delete_attachment
388
        end
389
      end
390

391
    end
G
gitlabhq 已提交
392
  end
R
Robert Speicher 已提交
393

394
  get ':id' => 'namespaces#show', constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }
G
GitLab 已提交
395

396
  root to: 'dashboard#show'
G
gitlabhq 已提交
397
end