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

G
gitlabhq 已提交
3
Gitlab::Application.routes.draw do
4 5 6
  #
  # Search
  #
7
  get 'search' => "search#show"
V
Valery Sizov 已提交
8

9 10 11 12
  # API
  require 'api'
  mount Gitlab::API => '/api'

D
sidekiq  
Dmitriy Zaporozhets 已提交
13 14
  constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
  constraints constraint do
15
    mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq
D
sidekiq  
Dmitriy Zaporozhets 已提交
16
  end
A
Ariejan de Vroom 已提交
17

18 19
  # Enable Grack support
  mount Grack::Bundle.new({
20 21 22 23
    git_path:     Gitlab.config.git.bin_path,
    project_root: Gitlab.config.gitolite.repos_path,
    upload_pack:  Gitlab.config.gitolite.upload_pack,
    receive_pack: Gitlab.config.gitolite.receive_pack
A
Andrey Kumanyaev 已提交
24
  }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }
25

26 27 28
  #
  # Help
  #
R
Riyad Preukschas 已提交
29 30 31 32
  get 'help'                => 'help#index'
  get 'help/api'            => 'help#api'
  get 'help/markdown'       => 'help#markdown'
  get 'help/permissions'    => 'help#permissions'
33
  get 'help/public_access'  => 'help#public_access'
R
Riyad Preukschas 已提交
34 35 36 37 38
  get 'help/raketasks'      => 'help#raketasks'
  get 'help/ssh'            => 'help#ssh'
  get 'help/system_hooks'   => 'help#system_hooks'
  get 'help/web_hooks'      => 'help#web_hooks'
  get 'help/workflow'       => 'help#workflow'
39

40 41 42 43 44 45 46 47
  #
  # Public namespace
  #
  namespace :public do
    resources :projects, only: [:index]
    root to: "projects#index"
  end

48 49 50
  #
  # Admin Area
  #
N
Nihad Abbasov 已提交
51
  namespace :admin do
52
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
53
      member do
D
Dmitriy Zaporozhets 已提交
54
        put :team_update
55 56
        put :block
        put :unblock
D
Dmitriy Zaporozhets 已提交
57 58
      end
    end
A
Andrey Kumanyaev 已提交
59

60 61 62
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
        put :project_update
A
Andrey Kumanyaev 已提交
63
        put :project_teams_update
64
        delete :remove_project
65 66
      end
    end
A
Andrey Kumanyaev 已提交
67 68

    resources :teams, constraints: { id: /[^\/]+/ } do
69
      scope module: :teams do
A
Andrey Kumanyaev 已提交
70 71
        resources :members,   only: [:edit, :update, :destroy, :new, :create]
        resources :projects,  only: [:edit, :update, :destroy, :new, :create], constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
72
      end
A
Andrey Kumanyaev 已提交
73
    end
A
Andrey Kumanyaev 已提交
74

R
Robert Speicher 已提交
75
    resources :hooks, only: [:index, :create, :destroy] do
V
Valeriy Sizov 已提交
76 77
      get :test
    end
A
Andrey Kumanyaev 已提交
78

79
    resource :logs, only: [:show]
R
Robert Speicher 已提交
80
    resource :resque, controller: 'resque', only: [:show]
A
Andrey Kumanyaev 已提交
81 82 83 84 85 86

    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, except: [:new, :create] do
      member do
        get :team
        put :team_update
      end
87
      scope module: :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
A
Andrey Kumanyaev 已提交
88 89 90 91
        resources :members, only: [:edit, :update, :destroy]
      end
    end

R
Robert Speicher 已提交
92
    root to: "dashboard#index"
G
gitlabhq 已提交
93 94
  end

95
  get "errors/githost"
R
randx 已提交
96 97 98 99

  #
  # Profile Area
  #
100 101 102 103 104 105 106 107 108 109 110 111
  resource :profile, only: [:show, :update] do
    member do
      get :account
      get :history
      get :token
      get :design

      put :update_password
      put :reset_private_token
      put :update_username
    end
  end
R
Robert Speicher 已提交
112

113
  resources :keys
114
  match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }
D
Dmitriy Zaporozhets 已提交
115 116


D
Dmitriy Zaporozhets 已提交
117

R
randx 已提交
118 119 120
  #
  # Dashboard Area
  #
R
Robert Speicher 已提交
121
  get "dashboard"                => "dashboard#index"
122
  get "dashboard/projects"       => "dashboard#projects"
R
Robert Speicher 已提交
123 124
  get "dashboard/issues"         => "dashboard#issues"
  get "dashboard/merge_requests" => "dashboard#merge_requests"
G
gitlabhq 已提交
125

R
randx 已提交
126 127 128
  #
  # Groups Area
  #
D
Dmitriy Zaporozhets 已提交
129
  resources :groups, constraints: { id: /[^\/]+/ }, only: [:show, :new, :create] do
R
randx 已提交
130 131 132 133 134
    member do
      get :issues
      get :merge_requests
      get :search
      get :people
A
Andrey Kumanyaev 已提交
135
      post :team_members
R
randx 已提交
136 137 138
    end
  end

A
Andrey Kumanyaev 已提交
139 140 141 142
  #
  # Teams Area
  #
  resources :teams, constraints: { id: /[^\/]+/ } do
143 144 145 146
    member do
      get :issues
      get :merge_requests
    end
A
Andrey Kumanyaev 已提交
147
    scope module: :teams do
A
Andrey Kumanyaev 已提交
148 149
      resources :members,   only: [:index, :new, :create, :edit, :update, :destroy]
      resources :projects,  only: [:index, :new, :create, :edit, :update, :destroy], constraints: { id: /[a-zA-Z.0-9_\-\/]+/ }
A
Andrey Kumanyaev 已提交
150
    end
151 152
  end

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

M
Marin Jankovski 已提交
155
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations }
G
gitlabhq 已提交
156

157 158 159
  #
  # Project Area
  #
160
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-\/]+/ }, except: [:new, :create, :index], path: "/" do
N
Nihad Abbasov 已提交
161
    member do
G
gitlabhq 已提交
162
      get "wall"
V
Valery Sizov 已提交
163
      get "graph"
164
      get "files"
G
gitlabhq 已提交
165
    end
G
gitlabhq 已提交
166

D
Dmitriy Zaporozhets 已提交
167 168 169 170 171 172 173 174 175
    resources :tree,    only: [:show, :edit, :update], constraints: {id: /.+/}
    resources :commit,  only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
    resources :commits, only: [:show], constraints: {id: /.+/}
    resources :compare, only: [:index, :create]
    resources :blame,   only: [:show], constraints: {id: /.+/}
    resources :blob,    only: [:show], constraints: {id: /.+/}
    match "/compare/:from...:to" => "compare#show", as: "compare",
                    :via => [:get, :post], constraints: {from: /.+/, to: /.+/}

R
Robert Speicher 已提交
176
    resources :wikis, only: [:show, :edit, :destroy, :create] do
D
Dmitriy Zaporozhets 已提交
177 178 179 180
      collection do
        get :pages
      end

V
Valery Sizov 已提交
181
      member do
182
        get "history"
V
Valery Sizov 已提交
183 184
      end
    end
V
Valery Sizov 已提交
185

186 187
    resource :repository do
      member do
D
Dmitriy Zaporozhets 已提交
188 189
        get "branches"
        get "tags"
R
randx 已提交
190
        get "stats"
191
        get "archive"
D
Dmitriy Zaporozhets 已提交
192 193
      end
    end
194

D
Dmitriy Zaporozhets 已提交
195 196 197 198 199 200
    resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
      member do
        get :test
      end
    end

M
miks 已提交
201
    resources :deploy_keys
R
Robert Speicher 已提交
202
    resources :protected_branches, only: [:index, :create, :destroy]
M
miks 已提交
203

204
    resources :refs, only: [] do
205
      collection do
G
gitlabhq 已提交
206 207 208
        get "switch"
      end

209
      member do
210 211
        # tree viewer logs
        get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
R
randx 已提交
212
        get "logs_tree/:path" => "refs#logs_tree",
R
Robert Speicher 已提交
213 214 215 216
          as: :logs_file,
          constraints: {
            id:   /[a-zA-Z.0-9\/_\-]+/,
            path: /.*/
R
randx 已提交
217
          }
G
gitlabhq 已提交
218
      end
G
gitlabhq 已提交
219
    end
G
gitlabhq 已提交
220

D
Dmitriy Zaporozhets 已提交
221
    resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
222
      member do
223
        get :diffs
R
randx 已提交
224
        get :automerge
V
Valery Sizov 已提交
225
        get :automerge_check
226
        get :ci_status
227
      end
228

229
      collection do
230 231 232
        get :branch_from
        get :branch_to
      end
233
    end
234 235 236

    resources :snippets do
      member do
R
randx 已提交
237 238 239 240
        get "raw"
      end
    end

R
Robert Speicher 已提交
241
    resources :hooks, only: [:index, :create, :destroy] do
242
      member do
243 244 245
        get :test
      end
    end
246 247


R
Robert Speicher 已提交
248
    resources :team, controller: 'team_members', only: [:index]
D
Dmitriy Zaporozhets 已提交
249
    resources :milestones, except: [:destroy]
R
Robert Speicher 已提交
250
    resources :labels, only: [:index]
D
Dmitriy Zaporozhets 已提交
251
    resources :issues, except: [:destroy] do
V
VSizov 已提交
252
      collection do
253
        post  :sort
R
randx 已提交
254
        post  :bulk_update
255
        get   :search
A
Adam Leonard 已提交
256
      end
V
VSizov 已提交
257
    end
R
Robert Speicher 已提交
258

D
Dmitriy Zaporozhets 已提交
259 260 261 262 263 264 265 266 267 268
    resources :team_members do
      collection do

        # Used for import team
        # from another project
        get :import
        post :apply_import
      end
    end

269 270 271
    scope module: :projects do
      resources :teams, only: [] do
        collection do
272
          get :available
273 274 275 276 277 278 279 280
          post :assign
        end
        member do
          delete :resign
        end
      end
    end

R
Robert Speicher 已提交
281
    resources :notes, only: [:index, :create, :destroy] do
282 283 284 285
      collection do
        post :preview
      end
    end
G
gitlabhq 已提交
286
  end
R
Robert Speicher 已提交
287 288

  root to: "dashboard#index"
G
gitlabhq 已提交
289
end