BigW Consortium Gitlab

routes.rb 8.04 KB
Newer Older
Dmitriy Zaporozhets committed
1
require 'sidekiq/web'
2
require 'api/api'
Dmitriy Zaporozhets committed
3

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

10
  # API
11 12
  API::API.logger Rails.logger
  mount API::API => '/api'
13

Dmitriy Zaporozhets committed
14 15
  constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
  constraints constraint do
16
    mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq
Dmitriy Zaporozhets committed
17
  end
18

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

27 28 29
  #
  # Help
  #
Riyad Preukschas committed
30 31
  get 'help'                => 'help#index'
  get 'help/api'            => 'help#api'
Dmitriy Zaporozhets committed
32
  get 'help/api/:category'  => 'help#api', as: 'help_api_file'
Riyad Preukschas committed
33 34
  get 'help/markdown'       => 'help#markdown'
  get 'help/permissions'    => 'help#permissions'
35
  get 'help/public_access'  => 'help#public_access'
Riyad Preukschas committed
36 37 38 39 40
  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'
41
  get 'help/shortcuts'
42
  get 'help/security'
43

Andrew8xx8 committed
44 45 46 47 48 49 50 51
  #
  # Global snippets
  #
  resources :snippets do
    member do
      get "raw"
    end
  end
Andrew8xx8 committed
52
  get "/s/:username" => "snippets#user_index", as: :user_snippets, constraints: { username: /.*/ }
Andrew8xx8 committed
53

54 55 56 57 58 59 60 61
  #
  # Public namespace
  #
  namespace :public do
    resources :projects, only: [:index]
    root to: "projects#index"
  end

62 63 64
  #
  # Attachments serving
  #
65
  get 'files/:type/:id/:filename' => 'files#download', constraints: { id: /\d+/, type: /[a-z]+/, filename:  /.+/ }
66

67 68 69
  #
  # Admin Area
  #
Nihad Abbasov committed
70
  namespace :admin do
71
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
72
      member do
73
        put :team_update
74 75
        put :block
        put :unblock
76 77
      end
    end
Andrey Kumanyaev committed
78

79 80
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
81
        put :project_teams_update
82
      end
83
    end
Andrey Kumanyaev committed
84

85
    resources :hooks, only: [:index, :create, :destroy] do
86 87
      get :test
    end
Andrey Kumanyaev committed
88

89
    resource :logs, only: [:show]
90
    resource :background_jobs, controller: 'background_jobs', only: [:show]
91
    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, only: [:index, :show]
92
    root to: "dashboard#index"
gitlabhq committed
93 94
  end

95
  get "errors/githost"
randx committed
96 97 98 99

  #
  # Profile Area
  #
100 101 102 103 104 105 106 107 108 109 110
  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
111

112 113 114 115
    scope module: :profiles do
      resource :notifications, only: [:show, :update]
      resource :password, only: [:new, :create]
      resources :keys
116 117 118 119 120
      resources :groups, only: [:index] do
        member do
          delete :leave
        end
      end
121
    end
122
  end
123

124
  match "/u/:username" => "users#show", as: :user, constraints: { username: /.*/ }
125 126


Dmitriy Zaporozhets committed
127

randx committed
128 129 130
  #
  # Dashboard Area
  #
131
  resource :dashboard, controller: "dashboard", only: [:show] do
132 133 134 135 136 137
    member do
      get :projects
      get :issues
      get :merge_requests
    end
  end
gitlabhq committed
138

139 140 141
  #
  # Groups Area
  #
142
  resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}  do
143 144 145
    member do
      get :issues
      get :merge_requests
146
      get :members
147
    end
148 149

    resources :users_groups, only: [:create, :update, :destroy]
150 151
  end

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

Marin Jankovski committed
154
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations }
gitlabhq committed
155

156 157 158
  #
  # Project Area
  #
159
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
160 161
    member do
      put :transfer
162
      post :fork
163
      get :autocomplete_sources
164 165
    end

166
    scope module: :projects do
167 168 169 170 171 172 173 174 175 176 177 178
      resources :blob,    only: [:show], constraints: {id: /.+/}
      resources :raw,    only: [:show], constraints: {id: /.+/}
      resources :tree,    only: [:show], constraints: {id: /.+/, format: /(html|js)/ }
      resources :edit_tree,    only: [:show, :update], constraints: {id: /.+/}, path: 'edit'
      resources :commit,  only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
      resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
      resources :compare, only: [:index, :create]
      resources :blame,   only: [:show], constraints: {id: /.+/}
      resources :network,   only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
      resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/}
      match "/compare/:from...:to" => "compare#show", as: "compare", via: [:get, :post], constraints: {from: /.+/, to: /.+/}

179
        resources :snippets, constraints: {id: /\d+/} do
180 181 182
          member do
            get "raw"
          end
183 184
        end

185
      resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-]+/} do
186 187 188 189 190
        collection do
          get :pages
          put ':id' => 'wikis#update'
          get :git_access
        end
Dmitriy Zaporozhets committed
191

192 193 194
        member do
          get "history"
        end
Valery Sizov committed
195
      end
196

197
      resource :wall, only: [:show], constraints: {id: /\d+/} do
198 199 200
        member do
          get 'notes'
        end
201 202
      end

203 204 205 206 207
      resource :repository, only: [:show] do
        member do
          get "stats"
          get "archive"
        end
208
      end
209

210 211 212 213
      resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
        member do
          get :test
        end
214 215
      end

216
      resources :deploy_keys, constraints: {id: /\d+/} do
217 218 219 220
        member do
          put :enable
          put :disable
        end
221 222
      end

223
      resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
224 225 226 227 228
        collection do
          get :recent
        end
      end

229 230
      resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
      resources :protected_branches, only: [:index, :create, :destroy], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
miks committed
231

232 233 234 235
      resources :refs, only: [] do
        collection do
          get "switch"
        end
gitlabhq committed
236

237 238 239 240 241 242 243 244 245 246
        member do
          # tree viewer logs
          get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ }
          get "logs_tree/:path" => "refs#logs_tree",
            as: :logs_file,
            constraints: {
              id:   /[a-zA-Z.0-9\/_\-#%+]+/,
              path: /.*/
            }
        end
gitlabhq committed
247
      end
gitlabhq committed
248

249 250 251 252 253 254 255
      resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
        member do
          get :diffs
          get :automerge
          get :automerge_check
          get :ci_status
        end
256

257 258 259
        collection do
          get :branch_from
          get :branch_to
260
          get :update_branches
261
        end
262
      end
263

264
      resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do
265 266 267
        member do
          get :test
        end
268
      end
269

270
      resources :team, controller: 'team_members', only: [:index]
271
      resources :milestones, except: [:destroy], constraints: {id: /\d+/}
272

273 274 275 276
      resources :labels, only: [:index] do
        collection do
          post :generate
        end
277 278
      end

279
      resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
280 281 282
        collection do
          post  :bulk_update
        end
283
      end
Robert Speicher committed
284

285
      resources :team_members, except: [:index, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
286
        collection do
287

288 289 290 291 292
          # Used for import team
          # from another project
          get :import
          post :apply_import
        end
293 294
      end

295
      resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do
296
        member do
297
          delete :delete_attachment
298 299
        end

300 301 302 303
        collection do
          post :preview
        end
      end
304
    end
gitlabhq committed
305
  end
306

307
  root to: "dashboard#show"
gitlabhq committed
308
end