routes.rb 12.3 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
M
Marcin Kulik 已提交
70 71 72 73 74 75

    resource :gitorious, only: [:create, :new], controller: :gitorious do
      get :status
      get :callback
      get :jobs
    end
V
Valery Sizov 已提交
76
  end
M
Marin Jankovski 已提交
77

78 79 80
  #
  # Uploads
  #
M
Marin Jankovski 已提交
81

82 83
  scope path: :uploads do
    # Note attachments and User/Group/Project avatars
D
Douwe Maan 已提交
84 85 86
    get ":model/:mounted_as/:id/:filename", 
        to:           "uploads#show", 
        constraints:  { model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: /.+/ }
87 88

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

94
  #
Y
Yatish Mehta 已提交
95
  # Explore area
96
  #
D
Dmitriy Zaporozhets 已提交
97 98 99 100
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
101
        get :starred
D
Dmitriy Zaporozhets 已提交
102 103 104
      end
    end

105
    resources :groups, only: [:index]
106
    root to: 'projects#trending'
107 108
  end

D
Dmitriy Zaporozhets 已提交
109
  # Compatibility with old routing
110 111
  get 'public' => 'explore/projects#index'
  get 'public/projects' => 'explore/projects#index'
D
Dmitriy Zaporozhets 已提交
112

113 114 115
  #
  # Attachments serving
  #
116
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
117

118 119 120
  #
  # Admin Area
  #
N
Nihad Abbasov 已提交
121
  namespace :admin do
122
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
123
      resources :keys, only: [:show, :destroy]
124
      member do
D
Dmitriy Zaporozhets 已提交
125
        put :team_update
126 127
        put :block
        put :unblock
128
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
D
Dmitriy Zaporozhets 已提交
129 130
      end
    end
A
Andrey Kumanyaev 已提交
131

V
Valery Sizov 已提交
132 133
    resources :applications

134 135
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
A
Andrey Kumanyaev 已提交
136
        put :project_teams_update
137
      end
A
Andrey Kumanyaev 已提交
138
    end
A
Andrey Kumanyaev 已提交
139

R
Robert Speicher 已提交
140
    resources :hooks, only: [:index, :create, :destroy] do
V
Valeriy Sizov 已提交
141 142
      get :test
    end
A
Andrey Kumanyaev 已提交
143

144
    resources :broadcast_messages, only: [:index, :create, :destroy]
145
    resource :logs, only: [:show]
146
    resource :background_jobs, controller: 'background_jobs', only: [:show]
147

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

      resources(:projects, path: '/',
                constraints: { id: /[a-zA-Z.0-9_\-]+/ },
                only: [:index, :show]) do
        root to: 'projects#show'

        member do
          put :transfer
        end
159 160 161
      end
    end

M
Marin Jankovski 已提交
162 163 164
    resource :application_settings, only: [:show, :update] do
      resources :services
    end
165

166
    root to: 'dashboard#index'
G
gitlabhq 已提交
167 168
  end

R
randx 已提交
169 170 171
  #
  # Profile Area
  #
172 173 174 175
  resource :profile, only: [:show, :update] do
    member do
      get :history
      get :design
D
Dmitriy Zaporozhets 已提交
176
      get :applications
177 178 179 180

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

182
    scope module: :profiles do
183
      resource :account, only: [:show, :update]
184
      resource :notifications, only: [:show, :update]
185 186 187 188 189
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
190
      resources :keys
191
      resources :emails, only: [:index, :create, :destroy]
192 193 194 195 196
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
197
      resource :avatar, only: [:destroy]
198
    end
199
  end
R
Robert Speicher 已提交
200

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

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

R
randx 已提交
207 208 209
  #
  # Dashboard Area
  #
210
  resource :dashboard, controller: 'dashboard', only: [:show] do
D
Dmitriy Zaporozhets 已提交
211 212 213 214 215 216
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
G
gitlabhq 已提交
217

R
randx 已提交
218 219 220
  #
  # Groups Area
  #
221
  resources :groups, constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }  do
R
randx 已提交
222 223 224
    member do
      get :issues
      get :merge_requests
225
      get :members
D
Dmitriy Zaporozhets 已提交
226
      get :projects
R
randx 已提交
227
    end
228

S
Steven Thonus 已提交
229
    scope module: :groups do
230
      resources :group_members, only: [:create, :update, :destroy]
S
Steven Thonus 已提交
231
      resource :avatar, only: [:destroy]
232
      resources :milestones
S
Steven Thonus 已提交
233
    end
R
randx 已提交
234 235
  end

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

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

240
  devise_scope :user do
241
    get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
242
  end
V
Vinnie Okada 已提交
243 244 245

  root to: "dashboard#show"

246 247 248
  #
  # Project Area
  #
V
Vinnie Okada 已提交
249 250 251 252 253 254 255 256 257 258 259
  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 :upload_image
        post :toggle_star
        post :markdown_preview
        get :autocomplete_sources
S
skv 已提交
260
      end
261

V
Vinnie Okada 已提交
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
      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
          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 })
        end
279

V
Vinnie Okada 已提交
280 281 282 283 284 285 286
        scope do
          get(
            '/raw/*id',
            to: 'raw#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :raw
          )
287
        end
288

V
Vinnie Okada 已提交
289 290 291 292 293 294 295 296 297
        scope do
          get(
            '/tree/*id',
            to: 'tree#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :tree
          )
        end
        resource  :avatar,    only: [:show, :destroy]
298

V
Vinnie Okada 已提交
299 300
        resources :commit,    only: [:show], constraints: { id: /[[:alnum:]]{6,40}/ } do
          get :branches, on: :member
301 302
        end

V
Vinnie Okada 已提交
303 304 305 306 307 308 309 310 311 312
        resources :commits,   only: [:show], constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }
        resources :compare,   only: [:index, :create]

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

V
Vinnie Okada 已提交
315 316 317 318 319
        resources :network,   only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ }
        resources :graphs,    only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } do
          member do
            get :commits
          end
320
        end
V
Valery Sizov 已提交
321

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

V
Vinnie Okada 已提交
325 326 327 328
        resources :snippets, constraints: { id: /\d+/ } do
          member do
            get 'raw'
          end
329
        end
330

V
Vinnie Okada 已提交
331 332 333 334 335 336
        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 已提交
337

V
Vinnie Okada 已提交
338 339 340
          member do
            get 'history'
          end
341
        end
342

V
Vinnie Okada 已提交
343 344 345 346 347
        resource :repository, only: [:show, :create] do
          member do
            get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
          end
        end
M
miks 已提交
348

V
Vinnie Okada 已提交
349 350 351 352
        resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
          member do
            get :test
          end
353
        end
G
gitlabhq 已提交
354

V
Vinnie Okada 已提交
355 356 357 358 359
        resources :deploy_keys, constraints: { id: /\d+/ } do
          member do
            put :enable
            put :disable
          end
360
        end
G
gitlabhq 已提交
361

V
Vinnie Okada 已提交
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377
        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
378
        end
379

V
Vinnie Okada 已提交
380 381 382 383 384 385 386 387 388 389 390 391 392
        resources :merge_requests, constraints: { id: /\d+/ }, except: [:destroy] do
          member do
            get :diffs
            post :automerge
            get :automerge_check
            get :ci_status
          end

          collection do
            get :branch_from
            get :branch_to
            get :update_branches
          end
393
        end
394

V
Vinnie Okada 已提交
395 396 397 398 399 400 401 402
        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
403
        end
404

V
Vinnie Okada 已提交
405 406 407 408 409 410
        resources :team, controller: 'team_members', only: [:index]
        resources :milestones, except: [:destroy], constraints: { id: /\d+/ } do
          member do
            put :sort_issues
            put :sort_merge_requests
          end
D
Dmitriy Zaporozhets 已提交
411
        end
412

V
Vinnie Okada 已提交
413 414 415 416
        resources :labels, constraints: { id: /\d+/ } do
          collection do
            post :generate
          end
417
        end
418

V
Vinnie Okada 已提交
419 420 421 422
        resources :issues, constraints: { id: /\d+/ }, except: [:destroy] do
          collection do
            post  :bulk_update
          end
423
        end
R
Robert Speicher 已提交
424

V
Vinnie Okada 已提交
425 426 427
        resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
          collection do
            delete :leave
D
Dmitriy Zaporozhets 已提交
428

V
Vinnie Okada 已提交
429 430 431 432 433
            # Used for import team
            # from another project
            get :import
            post :apply_import
          end
434
        end
D
Dmitriy Zaporozhets 已提交
435

V
Vinnie Okada 已提交
436 437 438 439
        resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do
          member do
            delete :delete_attachment
          end
440
        end
441
      end
442

443
    end
G
gitlabhq 已提交
444
  end
R
Robert Speicher 已提交
445

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