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
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 53
    resources :users do
      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 87 88 89 90 91

    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, except: [:new, :create] do
      member do
        get :team
        put :team_update
      end
      scope module: :projects, constraints: { id: /[^\/]+/ } do
        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 122 123
  get "dashboard"                => "dashboard#index"
  get "dashboard/issues"         => "dashboard#issues"
  get "dashboard/merge_requests" => "dashboard#merge_requests"
G
gitlabhq 已提交
124

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

A
Andrey Kumanyaev 已提交
138 139 140 141
  #
  # Teams Area
  #
  resources :teams, constraints: { id: /[^\/]+/ } do
142 143 144 145 146
    member do
      get :issues
      get :merge_requests
      get :search
    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 153 154 155
    collection do
      get :search
    end
  end

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

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

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

D
Dmitriy Zaporozhets 已提交
170 171 172 173 174 175 176 177 178
    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 已提交
179
    resources :wikis, only: [:show, :edit, :destroy, :create] do
D
Dmitriy Zaporozhets 已提交
180 181 182 183
      collection do
        get :pages
      end

V
Valery Sizov 已提交
184
      member do
185
        get "history"
V
Valery Sizov 已提交
186 187
      end
    end
V
Valery Sizov 已提交
188

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

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

M
miks 已提交
204
    resources :deploy_keys
R
Robert Speicher 已提交
205
    resources :protected_branches, only: [:index, :create, :destroy]
M
miks 已提交
206

207
    resources :refs, only: [] do
208
      collection do
G
gitlabhq 已提交
209 210 211
        get "switch"
      end

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

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

232
      collection do
233 234 235
        get :branch_from
        get :branch_to
      end
236
    end
237 238 239

    resources :snippets do
      member do
R
randx 已提交
240 241 242 243
        get "raw"
      end
    end

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


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

D
Dmitriy Zaporozhets 已提交
262 263 264 265 266 267 268 269 270 271
    resources :team_members do
      collection do

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

272 273 274 275 276 277 278 279 280 281 282 283
    scope module: :projects do
      resources :teams, only: [] do
        collection do
          get :avaliable
          post :assign
        end
        member do
          delete :resign
        end
      end
    end

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

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