routes.rb 6.06 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
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
59 60 61
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
        put :project_update
62
        put :project_teams_update
63
        delete :remove_project
64 65
      end
    end
66
    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, except: [:new, :create] do
67
      member do
68 69 70 71
        get :team
        put :team_update
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
72 73 74 75 76 77 78 79
    resources :teams do #, constraints: { id: /[^\/]+/ } do end
      member do
        post :delegate_projects
        delete :relegate_project
        post :add_members
        delete :remove_member
      end
    end
80 81
    resources :team_members, only: [:edit, :update, :destroy]
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
82 83
      get :test
    end
84
    resource :logs, only: [:show]
85 86
    resource :resque, controller: 'resque', only: [:show]
    root to: "dashboard#index"
gitlabhq's avatar
gitlabhq committed
87 88
  end

89
  get "errors/githost"
randx's avatar
randx committed
90 91 92 93

  #
  # Profile Area
  #
94 95 96 97 98 99 100 101 102 103 104 105
  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
106

107
  resources :keys
108
  match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
109 110


Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
111

randx's avatar
randx committed
112 113 114
  #
  # Dashboard Area
  #
115 116 117
  get "dashboard"                => "dashboard#index"
  get "dashboard/issues"         => "dashboard#issues"
  get "dashboard/merge_requests" => "dashboard#merge_requests"
gitlabhq's avatar
gitlabhq committed
118

randx's avatar
randx committed
119 120 121 122

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

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

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

137 138 139
  #
  # Project Area
  #
140
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-\/]+/ }, except: [:new, :create, :index], path: "/" do
Nihad Abbasov's avatar
Nihad Abbasov committed
141
    member do
gitlabhq's avatar
gitlabhq committed
142
      get "wall"
Valery Sizov's avatar
Valery Sizov committed
143
      get "graph"
144
      get "files"
gitlabhq's avatar
gitlabhq committed
145
    end
gitlabhq's avatar
gitlabhq committed
146

147 148 149 150 151 152 153 154 155
    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: /.+/}

156
    resources :wikis, only: [:show, :edit, :destroy, :create] do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
157 158 159 160
      collection do
        get :pages
      end

Valery Sizov's avatar
Valery Sizov committed
161
      member do
162
        get "history"
Valery Sizov's avatar
Valery Sizov committed
163 164
      end
    end
165

166 167
    resource :repository do
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
168 169
        get "branches"
        get "tags"
randx's avatar
randx committed
170
        get "stats"
171
        get "archive"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
172 173
      end
    end
174

175 176 177 178 179 180
    resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
      member do
        get :test
      end
    end

miks's avatar
miks committed
181
    resources :deploy_keys
182
    resources :protected_branches, only: [:index, :create, :destroy]
miks's avatar
miks committed
183

184
    resources :refs, only: [] do
185
      collection do
gitlabhq's avatar
gitlabhq committed
186 187 188
        get "switch"
      end

189
      member do
190 191
        # tree viewer logs
        get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
192
        get "logs_tree/:path" => "refs#logs_tree",
193 194 195 196
          as: :logs_file,
          constraints: {
            id:   /[a-zA-Z.0-9\/_\-]+/,
            path: /.*/
197
          }
gitlabhq's avatar
gitlabhq committed
198
      end
gitlabhq's avatar
gitlabhq committed
199
    end
gitlabhq's avatar
gitlabhq committed
200

201
    resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
202
      member do
203
        get :diffs
randx's avatar
randx committed
204
        get :automerge
Valery Sizov's avatar
Valery Sizov committed
205
        get :automerge_check
206
        get :ci_status
207
      end
208

209
      collection do
210 211 212
        get :branch_from
        get :branch_to
      end
213
    end
214 215 216

    resources :snippets do
      member do
217 218 219 220
        get "raw"
      end
    end

221
    resources :hooks, only: [:index, :create, :destroy] do
222
      member do
223 224 225
        get :test
      end
    end
226 227


228
    resources :team, controller: 'team_members', only: [:index]
229
    resources :milestones, except: [:destroy]
230
    resources :labels, only: [:index]
231
    resources :issues, except: [:destroy] do
VSizov's avatar
VSizov committed
232
      collection do
233
        post  :sort
randx's avatar
randx committed
234
        post  :bulk_update
235
        get   :search
Adam Leonard's avatar
Adam Leonard committed
236
      end
VSizov's avatar
VSizov committed
237
    end
Robert Speicher's avatar
Robert Speicher committed
238

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
239 240 241 242 243 244 245 246 247 248
    resources :team_members do
      collection do

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

249
    resources :notes, only: [:index, :create, :destroy] do
250 251 252 253
      collection do
        post :preview
      end
    end
gitlabhq's avatar
gitlabhq committed
254
  end
255 256

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