routes.rb 14.1 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 13 14 15
  # Autocomplete
  get '/autocomplete/users' => 'autocomplete#users'
  get '/autocomplete/users/:id' => 'autocomplete#user'


16
  # Search
17 18
  get 'search' => 'search#show'
  get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
V
Valery Sizov 已提交
19

20
  # API
21 22
  API::API.logger Rails.logger
  mount API::API => '/api'
23

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

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

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

40
  # Help
J
Job van der Voort 已提交
41
  get 'help'                  => 'help#index'
M
Marin Jankovski 已提交
42
  get 'help/shortcuts'
43
  get 'help/ui'               => 'help#ui'
44
  get 'help/:filepath'        => 'help#show', as: :help_page, constraints: { filepath: /[^\.]+/ }
45

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

D
Douwe Maan 已提交
56 57 58 59 60 61 62
  #
  # Invites
  #

  resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do
    member do
      post :accept
D
Douwe Maan 已提交
63
      match :decline, via: [:get, :post]
D
Douwe Maan 已提交
64 65
    end
  end
M
Marin Jankovski 已提交
66

V
Valery Sizov 已提交
67
  #
68
  # Import
V
Valery Sizov 已提交
69
  #
70 71
  namespace :import do
    resource :github, only: [:create, :new], controller: :github do
V
Valery Sizov 已提交
72 73 74 75 76
      get :status
      get :callback
      get :jobs
    end

77
    resource :gitlab, only: [:create, :new], controller: :gitlab do
V
Valery Sizov 已提交
78 79 80 81
      get :status
      get :callback
      get :jobs
    end
M
Marcin Kulik 已提交
82

D
Douwe Maan 已提交
83 84 85 86 87
    resource :bitbucket, only: [:create, :new], controller: :bitbucket do
      get :status
      get :callback
      get :jobs
    end
88

M
Marcin Kulik 已提交
89 90 91 92 93
    resource :gitorious, only: [:create, :new], controller: :gitorious do
      get :status
      get :callback
      get :jobs
    end
94 95 96 97 98

    resource :google_code, only: [:create, :new], controller: :google_code do
      get :status
      post :callback
      get :jobs
D
Douwe Maan 已提交
99 100 101

      get   :new_user_map,    path: :user_map
      post  :create_user_map, path: :user_map
102
    end
V
Valery Sizov 已提交
103
  end
M
Marin Jankovski 已提交
104

105 106 107
  #
  # Uploads
  #
M
Marin Jankovski 已提交
108

109 110
  scope path: :uploads do
    # Note attachments and User/Group/Project avatars
111 112
    get ":model/:mounted_as/:id/:filename",
        to:           "uploads#show",
113
        constraints:  { model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: /[^\/]+/ }
114 115

    # Project markdown uploads
116
    get ":namespace_id/:project_id/:secret/:filename",
117
      to:           "projects/uploads#show",
118
      constraints:  { namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: /[^\/]+/ }
119
  end
V
Valery Sizov 已提交
120

121
  # Redirect old note attachments path to new uploads path.
122 123
  get "files/note/:id/:filename",
    to:           redirect("uploads/note/attachment/%{id}/%{filename}"),
124
    constraints:  { filename: /[^\/]+/ }
125

126
  #
Y
Yatish Mehta 已提交
127
  # Explore area
128
  #
D
Dmitriy Zaporozhets 已提交
129 130 131 132
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
133
        get :starred
D
Dmitriy Zaporozhets 已提交
134 135 136
      end
    end

137
    resources :groups, only: [:index]
138
    root to: 'projects#trending'
139 140
  end

D
Dmitriy Zaporozhets 已提交
141
  # Compatibility with old routing
142 143
  get 'public' => 'explore/projects#index'
  get 'public/projects' => 'explore/projects#index'
D
Dmitriy Zaporozhets 已提交
144

145 146 147
  #
  # Admin Area
  #
N
Nihad Abbasov 已提交
148
  namespace :admin do
149
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
150
      resources :keys, only: [:show, :destroy]
151
      member do
D
Dmitriy Zaporozhets 已提交
152
        put :team_update
153 154
        put :block
        put :unblock
155
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
D
Dmitriy Zaporozhets 已提交
156 157
      end
    end
A
Andrey Kumanyaev 已提交
158

V
Valery Sizov 已提交
159 160
    resources :applications

161 162
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
163
        put :members_update
164
      end
A
Andrey Kumanyaev 已提交
165
    end
A
Andrey Kumanyaev 已提交
166

167 168
    resources :deploy_keys, only: [:index, :show, :new, :create, :destroy]

R
Robert Speicher 已提交
169
    resources :hooks, only: [:index, :create, :destroy] do
V
Valeriy Sizov 已提交
170 171
      get :test
    end
A
Andrey Kumanyaev 已提交
172

173
    resources :broadcast_messages, only: [:index, :create, :destroy]
174
    resource :logs, only: [:show]
175
    resource :background_jobs, controller: 'background_jobs', only: [:show]
176

V
Vinnie Okada 已提交
177 178 179
    resources :namespaces, path: '/projects', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
      root to: 'projects#index', as: :projects

180 181
      resources(:projects,
                path: '/',
V
Vinnie Okada 已提交
182 183 184 185 186 187 188
                constraints: { id: /[a-zA-Z.0-9_\-]+/ },
                only: [:index, :show]) do
        root to: 'projects#show'

        member do
          put :transfer
        end
189 190 191
      end
    end

M
Marin Jankovski 已提交
192 193 194
    resource :application_settings, only: [:show, :update] do
      resources :services
    end
195

196
    root to: 'dashboard#index'
G
gitlabhq 已提交
197 198
  end

R
randx 已提交
199 200 201
  #
  # Profile Area
  #
202 203 204 205
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design
D
Dmitriy Zaporozhets 已提交
206
      get :applications
207 208 209 210

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

212
    scope module: :profiles do
213 214 215 216 217
      resource :account, only: [:show, :update] do
        member do
          delete :unlink
        end
      end
218
      resource :notifications, only: [:show, :update]
219 220 221 222 223
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
224
      resources :keys
225
      resources :emails, only: [:index, :create, :destroy]
226
      resource :avatar, only: [:destroy]
227
    end
228
  end
R
Robert Speicher 已提交
229

230
  get 'u/:username/calendar' => 'users#calendar', as: :user_calendar,
231 232 233 234
      constraints: { username: /.*/ }

  get 'u/:username/calendar_activities' => 'users#calendar_activities', as: :user_calendar_activities,
      constraints: { username: /.*/ }
235

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

R
randx 已提交
239 240 241
  #
  # Dashboard Area
  #
242
  resource :dashboard, controller: 'dashboard', only: [:show] do
D
Dmitriy Zaporozhets 已提交
243 244 245 246
    member do
      get :issues
      get :merge_requests
    end
D
Douwe Maan 已提交
247 248 249

    scope module: :dashboard do
      resources :milestones, only: [:index, :show]
250

251
      resources :groups, only: [:index]
252 253 254 255 256 257

      resources :projects, only: [] do
        collection do
          get :starred
        end
      end
D
Douwe Maan 已提交
258
    end
D
Dmitriy Zaporozhets 已提交
259
  end
G
gitlabhq 已提交
260

R
randx 已提交
261 262 263
  #
  # Groups Area
  #
264
  resources :groups, constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }  do
R
randx 已提交
265 266 267
    member do
      get :issues
      get :merge_requests
D
Dmitriy Zaporozhets 已提交
268
      get :projects
R
randx 已提交
269
    end
270

S
Steven Thonus 已提交
271
    scope module: :groups do
272
      resources :group_members, only: [:index, :create, :update, :destroy] do
273
        post :resend_invite, on: :member
274
        delete :leave, on: :collection
275
      end
276

S
Steven Thonus 已提交
277
      resource :avatar, only: [:destroy]
D
Douwe Maan 已提交
278
      resources :milestones, only: [:index, :show, :update]
S
Steven Thonus 已提交
279
    end
R
randx 已提交
280 281
  end

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

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

286
  devise_scope :user do
287
    get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
288
  end
V
Vinnie Okada 已提交
289 290 291

  root to: "dashboard#show"

292 293 294
  #
  # Project Area
  #
V
Vinnie Okada 已提交
295 296 297 298 299 300 301 302 303 304
  resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
    resources(:projects, constraints: { id: /[a-zA-Z.0-9_\-]+/ }, except:
              [:new, :create, :index], path: "/") do
      member do
        put :transfer
        post :archive
        post :unarchive
        post :toggle_star
        post :markdown_preview
        get :autocomplete_sources
S
skv 已提交
305
      end
306

V
Vinnie Okada 已提交
307 308 309 310 311 312 313 314 315
      scope module: :projects do
        # Blob routes:
        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'

        scope do
316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
          get(
            '/blob/*id/diff',
            to: 'blob#diff',
            constraints: { id: /.+/, format: false },
            as: :blob_diff
          )
          get(
            '/blob/*id',
            to: 'blob#show',
            constraints: { id: /.+/, format: false },
            as: :blob
          )
          delete(
            '/blob/*id',
            to: 'blob#destroy',
            constraints: { id: /.+/, format: false }
          )
V
Vinnie Okada 已提交
333
        end
334

V
Vinnie Okada 已提交
335 336 337 338 339 340 341
        scope do
          get(
            '/raw/*id',
            to: 'raw#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :raw
          )
342
        end
343

V
Vinnie Okada 已提交
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
        scope do
          get(
            '/tree/*id',
            to: 'tree#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :tree
          )
        end

        scope do
          get(
            '/blame/*id',
            to: 'blame#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :blame
          )
360
        end
D
Dmitriy Zaporozhets 已提交
361

362 363 364 365
        scope do
          get(
            '/commits/*id',
            to: 'commits#show',
D
Dmitriy Zaporozhets 已提交
366
            constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ },
367 368 369 370 371 372 373 374 375 376 377 378 379
            as: :commits
          )
        end

        resource  :avatar, only: [:show, :destroy]
        resources :commit, only: [:show], constraints: { id: /[[:alnum:]]{6,40}/ } do
          get :branches, on: :member
        end

        resources :compare, only: [:index, :create]
        resources :network, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ }

        resources :graphs, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } do
V
Vinnie Okada 已提交
380 381 382
          member do
            get :commits
          end
383
        end
V
Valery Sizov 已提交
384

V
Vinnie Okada 已提交
385 386
        get '/compare/:from...:to' => 'compare#show', :as => 'compare',
            :constraints => { from: /.+/, to: /.+/ }
387

V
Vinnie Okada 已提交
388 389 390 391
        resources :snippets, constraints: { id: /\d+/ } do
          member do
            get 'raw'
          end
392
        end
393

V
Vinnie Okada 已提交
394 395 396 397 398 399
        resources :wikis, only: [:show, :edit, :destroy, :create], constraints: { id: /[a-zA-Z.0-9_\-\/]+/ } do
          collection do
            get :pages
            put ':id' => 'wikis#update'
            get :git_access
          end
D
Dmitriy Zaporozhets 已提交
400

V
Vinnie Okada 已提交
401 402 403
          member do
            get 'history'
          end
404
        end
405

V
Vinnie Okada 已提交
406 407 408 409 410
        resource :repository, only: [:show, :create] do
          member do
            get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
          end
        end
M
miks 已提交
411

V
Vinnie Okada 已提交
412 413 414 415
        resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
          member do
            get :test
          end
416
        end
G
gitlabhq 已提交
417

418
        resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :show, :new, :create] do
V
Vinnie Okada 已提交
419 420 421 422
          member do
            put :enable
            put :disable
          end
423
        end
G
gitlabhq 已提交
424

V
Vinnie Okada 已提交
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440
        resource :fork, only: [:new, :create]
        resource :import, only: [:new, :create, :show]

        resources :refs, only: [] do
          collection do
            get 'switch'
          end

          member do
            # tree viewer logs
            get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex }
            get 'logs_tree/:path' => 'refs#logs_tree', as: :logs_file, constraints: {
              id: Gitlab::Regex.git_reference_regex,
              path: /.*/
            }
          end
441
        end
442

V
Vinnie Okada 已提交
443 444 445 446 447 448
        resources :merge_requests, constraints: { id: /\d+/ }, except: [:destroy] do
          member do
            get :diffs
            post :automerge
            get :automerge_check
            get :ci_status
V
tests  
Valery Sizov 已提交
449
            post :toggle_subscription
V
Vinnie Okada 已提交
450 451 452 453 454 455 456
          end

          collection do
            get :branch_from
            get :branch_to
            get :update_branches
          end
457
        end
458

V
Vinnie Okada 已提交
459 460 461 462 463 464 465 466
        resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
        resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
        resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }

        resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do
          member do
            get :test
          end
467
        end
468

V
Vinnie Okada 已提交
469 470 471 472 473
        resources :milestones, except: [:destroy], constraints: { id: /\d+/ } do
          member do
            put :sort_issues
            put :sort_merge_requests
          end
D
Dmitriy Zaporozhets 已提交
474
        end
475

V
Vinnie Okada 已提交
476 477 478 479
        resources :labels, constraints: { id: /\d+/ } do
          collection do
            post :generate
          end
480
        end
481

V
Vinnie Okada 已提交
482
        resources :issues, constraints: { id: /\d+/ }, except: [:destroy] do
V
Valery Sizov 已提交
483
          member do
V
tests  
Valery Sizov 已提交
484
            post :toggle_subscription
V
Valery Sizov 已提交
485
          end
V
Vinnie Okada 已提交
486 487 488
          collection do
            post  :bulk_update
          end
489
        end
R
Robert Speicher 已提交
490

491
        resources :project_members, except: [:new, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
V
Vinnie Okada 已提交
492 493
          collection do
            delete :leave
D
Dmitriy Zaporozhets 已提交
494

V
Vinnie Okada 已提交
495 496 497 498 499
            # Used for import team
            # from another project
            get :import
            post :apply_import
          end
500 501 502 503

          member do
            post :resend_invite
          end
504
        end
D
Dmitriy Zaporozhets 已提交
505

V
Vinnie Okada 已提交
506 507 508 509
        resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do
          member do
            delete :delete_attachment
          end
510
        end
511 512 513

        resources :uploads, only: [:create] do
          collection do
514
            get ":secret/:filename", action: :show, as: :show, constraints: { filename: /[^\/]+/ }
515
          end
516
        end
517
      end
518

519
    end
G
gitlabhq 已提交
520
  end
R
Robert Speicher 已提交
521

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