routes.rb 13.4 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

M
Marin Jankovski 已提交
56

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

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

D
Douwe Maan 已提交
73 74 75 76 77
    resource :bitbucket, only: [:create, :new], controller: :bitbucket do
      get :status
      get :callback
      get :jobs
    end
78

M
Marcin Kulik 已提交
79 80 81 82 83
    resource :gitorious, only: [:create, :new], controller: :gitorious do
      get :status
      get :callback
      get :jobs
    end
V
Valery Sizov 已提交
84
  end
M
Marin Jankovski 已提交
85

86 87 88
  #
  # Uploads
  #
M
Marin Jankovski 已提交
89

90 91
  scope path: :uploads do
    # Note attachments and User/Group/Project avatars
92 93
    get ":model/:mounted_as/:id/:filename",
        to:           "uploads#show",
D
Douwe Maan 已提交
94
        constraints:  { model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: /.+/ }
95 96

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

102
  # Redirect old note attachments path to new uploads path.
103 104 105 106
  get "files/note/:id/:filename",
    to:           redirect("uploads/note/attachment/%{id}/%{filename}"),
    constraints:  { filename: /.+/ }

107
  #
Y
Yatish Mehta 已提交
108
  # Explore area
109
  #
D
Dmitriy Zaporozhets 已提交
110 111 112 113
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
114
        get :starred
D
Dmitriy Zaporozhets 已提交
115 116 117
      end
    end

118
    resources :groups, only: [:index]
119
    root to: 'projects#trending'
120 121
  end

D
Dmitriy Zaporozhets 已提交
122
  # Compatibility with old routing
123 124
  get 'public' => 'explore/projects#index'
  get 'public/projects' => 'explore/projects#index'
D
Dmitriy Zaporozhets 已提交
125

126 127 128
  #
  # Admin Area
  #
N
Nihad Abbasov 已提交
129
  namespace :admin do
130
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
131
      resources :keys, only: [:show, :destroy]
132
      member do
D
Dmitriy Zaporozhets 已提交
133
        put :team_update
134 135
        put :block
        put :unblock
136
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
D
Dmitriy Zaporozhets 已提交
137 138
      end
    end
A
Andrey Kumanyaev 已提交
139

V
Valery Sizov 已提交
140 141
    resources :applications

142 143
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
144
        put :members_update
145
      end
A
Andrey Kumanyaev 已提交
146
    end
A
Andrey Kumanyaev 已提交
147

R
Robert Speicher 已提交
148
    resources :hooks, only: [:index, :create, :destroy] do
V
Valeriy Sizov 已提交
149 150
      get :test
    end
A
Andrey Kumanyaev 已提交
151

152
    resources :broadcast_messages, only: [:index, :create, :destroy]
153
    resource :logs, only: [:show]
154
    resource :background_jobs, controller: 'background_jobs', only: [:show]
155

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

159 160
      resources(:projects,
                path: '/',
V
Vinnie Okada 已提交
161 162 163 164 165 166 167
                constraints: { id: /[a-zA-Z.0-9_\-]+/ },
                only: [:index, :show]) do
        root to: 'projects#show'

        member do
          put :transfer
        end
168 169 170
      end
    end

M
Marin Jankovski 已提交
171 172 173
    resource :application_settings, only: [:show, :update] do
      resources :services
    end
174

175
    root to: 'dashboard#index'
G
gitlabhq 已提交
176 177
  end

R
randx 已提交
178 179 180
  #
  # Profile Area
  #
181 182 183 184
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design
D
Dmitriy Zaporozhets 已提交
185
      get :applications
186 187 188 189

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

191
    scope module: :profiles do
192 193 194 195 196
      resource :account, only: [:show, :update] do
        member do
          delete :unlink
        end
      end
197
      resource :notifications, only: [:show, :update]
198 199 200 201 202
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
203
      resources :keys
204
      resources :emails, only: [:index, :create, :destroy]
205
      resource :avatar, only: [:destroy]
206
    end
207
  end
R
Robert Speicher 已提交
208

209
  get 'u/:username/calendar' => 'users#calendar', as: :user_calendar,
210 211 212 213
      constraints: { username: /.*/ }

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

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

R
randx 已提交
218 219 220
  #
  # Dashboard Area
  #
221
  resource :dashboard, controller: 'dashboard', only: [:show] do
D
Dmitriy Zaporozhets 已提交
222 223 224 225
    member do
      get :issues
      get :merge_requests
    end
D
Douwe Maan 已提交
226 227 228

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

230
      resources :groups, only: [:index]
231 232 233 234 235 236

      resources :projects, only: [] do
        collection do
          get :starred
        end
      end
D
Douwe Maan 已提交
237
    end
D
Dmitriy Zaporozhets 已提交
238
  end
G
gitlabhq 已提交
239

R
randx 已提交
240 241 242
  #
  # Groups Area
  #
243
  resources :groups, constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }  do
R
randx 已提交
244 245 246
    member do
      get :issues
      get :merge_requests
D
Dmitriy Zaporozhets 已提交
247
      get :projects
R
randx 已提交
248
    end
249

S
Steven Thonus 已提交
250
    scope module: :groups do
251
      resources :group_members, only: [:index, :create, :update, :destroy] do
252
        delete :leave, on: :collection
253
      end
254

S
Steven Thonus 已提交
255
      resource :avatar, only: [:destroy]
D
Douwe Maan 已提交
256
      resources :milestones, only: [:index, :show, :update]
S
Steven Thonus 已提交
257
    end
R
randx 已提交
258 259
  end

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

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

264
  devise_scope :user do
265
    get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
266
  end
V
Vinnie Okada 已提交
267 268 269

  root to: "dashboard#show"

270 271 272
  #
  # Project Area
  #
V
Vinnie Okada 已提交
273 274 275 276 277 278 279 280 281 282
  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 已提交
283
      end
284

V
Vinnie Okada 已提交
285 286 287 288 289 290 291 292 293
      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
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
          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 已提交
311
        end
312

V
Vinnie Okada 已提交
313 314 315 316 317 318 319
        scope do
          get(
            '/raw/*id',
            to: 'raw#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :raw
          )
320
        end
321

V
Vinnie Okada 已提交
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337
        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
          )
338
        end
D
Dmitriy Zaporozhets 已提交
339

340 341 342 343
        scope do
          get(
            '/commits/*id',
            to: 'commits#show',
D
Dmitriy Zaporozhets 已提交
344
            constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ },
345 346 347 348 349 350 351 352 353 354 355 356 357
            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 已提交
358 359 360
          member do
            get :commits
          end
361
        end
V
Valery Sizov 已提交
362

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

V
Vinnie Okada 已提交
366 367 368 369
        resources :snippets, constraints: { id: /\d+/ } do
          member do
            get 'raw'
          end
370
        end
371

V
Vinnie Okada 已提交
372 373 374 375 376 377
        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 已提交
378

V
Vinnie Okada 已提交
379 380 381
          member do
            get 'history'
          end
382
        end
383

V
Vinnie Okada 已提交
384 385 386 387 388
        resource :repository, only: [:show, :create] do
          member do
            get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
          end
        end
M
miks 已提交
389

V
Vinnie Okada 已提交
390 391 392 393
        resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
          member do
            get :test
          end
394
        end
G
gitlabhq 已提交
395

V
Vinnie Okada 已提交
396 397 398 399 400
        resources :deploy_keys, constraints: { id: /\d+/ } do
          member do
            put :enable
            put :disable
          end
401
        end
G
gitlabhq 已提交
402

V
Vinnie Okada 已提交
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
        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
419
        end
420

V
Vinnie Okada 已提交
421 422 423 424 425 426
        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 已提交
427
            post :toggle_subscription
V
Vinnie Okada 已提交
428 429 430 431 432 433 434
          end

          collection do
            get :branch_from
            get :branch_to
            get :update_branches
          end
435
        end
436

V
Vinnie Okada 已提交
437 438 439 440 441 442 443 444
        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
445
        end
446

V
Vinnie Okada 已提交
447 448 449 450 451
        resources :milestones, except: [:destroy], constraints: { id: /\d+/ } do
          member do
            put :sort_issues
            put :sort_merge_requests
          end
D
Dmitriy Zaporozhets 已提交
452
        end
453

V
Vinnie Okada 已提交
454 455 456 457
        resources :labels, constraints: { id: /\d+/ } do
          collection do
            post :generate
          end
458
        end
459

V
Vinnie Okada 已提交
460
        resources :issues, constraints: { id: /\d+/ }, except: [:destroy] do
V
Valery Sizov 已提交
461
          member do
V
tests  
Valery Sizov 已提交
462
            post :toggle_subscription
V
Valery Sizov 已提交
463
          end
V
Vinnie Okada 已提交
464 465 466
          collection do
            post  :bulk_update
          end
467
        end
R
Robert Speicher 已提交
468

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

V
Vinnie Okada 已提交
473 474 475 476 477
            # Used for import team
            # from another project
            get :import
            post :apply_import
          end
478
        end
D
Dmitriy Zaporozhets 已提交
479

V
Vinnie Okada 已提交
480 481 482 483
        resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do
          member do
            delete :delete_attachment
          end
484
        end
485 486 487 488 489

        resources :uploads, only: [:create] do
          collection do
            get ":secret/:filename", action: :show, as: :show, constraints: { filename: /.+/ }
          end
490
        end
491
      end
492

493
    end
G
gitlabhq 已提交
494
  end
R
Robert Speicher 已提交
495

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