routes.rb 6.88 KB
Newer Older
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
1 2
require 'sidekiq/web'

gitlabhq's avatar
gitlabhq committed
3
Gitlab::Application.routes.draw do
4 5 6
  #
  # Search
  #
7
  get 'search' => "search#show"
Valery Sizov's avatar
Valery Sizov committed
8

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

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
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
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
16
  end
Ariejan de Vroom's avatar
Ariejan de Vroom committed
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
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
24
  }), at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }
25

26 27 28
  #
  # Help
  #
Riyad Preukschas's avatar
Riyad Preukschas committed
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'
Riyad Preukschas's avatar
Riyad Preukschas committed
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
  #
Nihad Abbasov's avatar
Nihad Abbasov committed
51
  namespace :admin do
52 53
    resources :users do
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
54
        put :team_update
55 56
        put :block
        put :unblock
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
57 58
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
59

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

    resources :teams, constraints: { id: /[^\/]+/ } do
69
      scope module: :teams do
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
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
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
73
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
74

75
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
76 77
      get :test
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
78

79
    resource :logs, only: [:show]
80
    resource :resque, controller: 'resque', only: [:show]
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
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

92
    root to: "dashboard#index"
gitlabhq's avatar
gitlabhq committed
93 94
  end

95
  get "errors/githost"
randx's avatar
randx committed
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
112

113
  resources :keys
114
  match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
115 116


Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
117

randx's avatar
randx committed
118 119 120
  #
  # Dashboard Area
  #
121 122 123
  get "dashboard"                => "dashboard#index"
  get "dashboard/issues"         => "dashboard#issues"
  get "dashboard/merge_requests" => "dashboard#merge_requests"
gitlabhq's avatar
gitlabhq committed
124

randx's avatar
randx committed
125 126 127
  #
  # Groups Area
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
128
  resources :groups, constraints: { id: /[^\/]+/ }, only: [:show, :new, :create] do
randx's avatar
randx committed
129 130 131 132 133
    member do
      get :issues
      get :merge_requests
      get :search
      get :people
134
      post :team_members
randx's avatar
randx committed
135 136 137
    end
  end

Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
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
147
    scope module: :teams do
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
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_\-\/]+/ }
150
    end
151 152 153 154 155
    collection do
      get :search
    end
  end

156
  resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
157

Marin Jankovski's avatar
Marin Jankovski committed
158
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations }
gitlabhq's avatar
gitlabhq committed
159

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

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: /.+/}

179
    resources :wikis, only: [:show, :edit, :destroy, :create] do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
180 181 182 183
      collection do
        get :pages
      end

Valery Sizov's avatar
Valery Sizov committed
184
      member do
185
        get "history"
Valery Sizov's avatar
Valery Sizov committed
186 187
      end
    end
188

189 190
    resource :repository do
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
191 192
        get "branches"
        get "tags"
randx's avatar
randx committed
193
        get "stats"
194
        get "archive"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
195 196
      end
    end
197

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

miks's avatar
miks committed
204
    resources :deploy_keys
205
    resources :protected_branches, only: [:index, :create, :destroy]
miks's avatar
miks committed
206

207
    resources :refs, only: [] do
208
      collection do
gitlabhq's avatar
gitlabhq committed
209 210 211
        get "switch"
      end

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

224
    resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
225
      member do
226
        get :diffs
randx's avatar
randx committed
227
        get :automerge
Valery Sizov's avatar
Valery Sizov committed
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
240 241 242 243
        get "raw"
      end
    end

244
    resources :hooks, only: [:index, :create, :destroy] do
245
      member do
246 247 248
        get :test
      end
    end
249 250


251
    resources :team, controller: 'team_members', only: [:index]
252
    resources :milestones, except: [:destroy]
253
    resources :labels, only: [:index]
254
    resources :issues, except: [:destroy] do
VSizov's avatar
VSizov committed
255
      collection do
256
        post  :sort
randx's avatar
randx committed
257
        post  :bulk_update
258
        get   :search
Adam Leonard's avatar
Adam Leonard committed
259
      end
VSizov's avatar
VSizov committed
260
    end
Robert Speicher's avatar
Robert Speicher committed
261

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
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
    scope module: :projects do
      resources :teams, only: [] do
        collection do
275
          get :available
276 277 278 279 280 281 282 283
          post :assign
        end
        member do
          delete :resign
        end
      end
    end

284
    resources :notes, only: [:index, :create, :destroy] do
285 286 287 288
      collection do
        post :preview
      end
    end
gitlabhq's avatar
gitlabhq committed
289
  end
290 291

  root to: "dashboard#index"
gitlabhq's avatar
gitlabhq committed
292
end