routes.rb 5.52 KB
Newer Older
Dmitriy Zaporozhets's avatar
sidekiq    
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
sidekiq    
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
sidekiq    
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
  #
Robert Speicher's avatar
Robert Speicher committed
29
30
31
32
33
  get 'help'              => 'help#index'
  get 'help/permissions'  => 'help#permissions'
  get 'help/workflow'     => 'help#workflow'
  get 'help/api'          => 'help#api'
  get 'help/web_hooks'    => 'help#web_hooks'
Valeriy Sizov's avatar
Valeriy Sizov committed
34
  get 'help/system_hooks' => 'help#system_hooks'
Robert Speicher's avatar
Robert Speicher committed
35
36
  get 'help/markdown'     => 'help#markdown'
  get 'help/ssh'          => 'help#ssh'
37
  get 'help/raketasks'    => 'help#raketasks'
38

39
40
41
  #
  # Admin Area
  #
Nihad Abbasov's avatar
Nihad Abbasov committed
42
  namespace :admin do
43
44
    resources :users do
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
45
        put :team_update
46
47
        put :block
        put :unblock
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
48
49
      end
    end
50
51
52
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
        put :project_update
53
        put :project_teams_update
54
        delete :remove_project
55
56
      end
    end
57
    resources :projects, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }, except: [:new, :create] do
58
      member do
59
60
61
62
        get :team
        put :team_update
      end
    end
Robert Speicher's avatar
Robert Speicher committed
63
64
    resources :team_members, only: [:edit, :update, :destroy]
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
65
66
      get :test
    end
67
    resource :logs, only: [:show]
Robert Speicher's avatar
Robert Speicher committed
68
69
    resource :resque, controller: 'resque', only: [:show]
    root to: "dashboard#index"
gitlabhq's avatar
gitlabhq committed
70
71
  end

72
  get "errors/githost"
randx's avatar
randx committed
73
74
75
76

  #
  # Profile Area
  #
77
78
79
80
81
82
83
84
85
86
87
88
  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
Robert Speicher's avatar
Robert Speicher committed
89

90
  resources :keys
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
91

randx's avatar
randx committed
92
93
94
  #
  # Dashboard Area
  #
Robert Speicher's avatar
Robert Speicher committed
95
96
97
  get "dashboard"                => "dashboard#index"
  get "dashboard/issues"         => "dashboard#issues"
  get "dashboard/merge_requests" => "dashboard#merge_requests"
gitlabhq's avatar
gitlabhq committed
98

randx's avatar
randx committed
99
100
101
102
103
104
105
106
107
108

  #
  # Groups Area
  #
  resources :groups, constraints: { id: /[^\/]+/ }, only: [:show] do
    member do
      get :issues
      get :merge_requests
      get :search
      get :people
109
      post :team_members
randx's avatar
randx committed
110
111
112
    end
  end

Robert Speicher's avatar
Robert Speicher committed
113
  resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
114

Robert Speicher's avatar
Robert Speicher committed
115
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks }
gitlabhq's avatar
gitlabhq committed
116

117
118
119
  #
  # Project Area
  #
120
  resources :projects, constraints: { id: /[a-zA-Z.0-9_\-\/]+/ }, except: [:new, :create, :index], path: "/" do
Nihad Abbasov's avatar
Nihad Abbasov committed
121
    member do
gitlabhq's avatar
gitlabhq committed
122
      get "wall"
Valery Sizov's avatar
Valery Sizov committed
123
      get "graph"
124
      get "files"
gitlabhq's avatar
gitlabhq committed
125
    end
gitlabhq's avatar
gitlabhq committed
126

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
127
128
129
130
131
132
133
134
135
    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: /.+/}

Robert Speicher's avatar
Robert Speicher committed
136
    resources :wikis, only: [:show, :edit, :destroy, :create] do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
137
138
139
140
      collection do
        get :pages
      end

Valery Sizov's avatar
Valery Sizov committed
141
      member do
142
        get "history"
Valery Sizov's avatar
Valery Sizov committed
143
144
      end
    end
Valery Sizov's avatar
Valery Sizov committed
145

146
147
    resource :repository do
      member do
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
148
149
        get "branches"
        get "tags"
randx's avatar
randx committed
150
        get "stats"
151
        get "archive"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
152
153
      end
    end
154

155
156
157
158
159
160
    resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
      member do
        get :test
      end
    end

miks's avatar
miks committed
161
    resources :deploy_keys
Robert Speicher's avatar
Robert Speicher committed
162
    resources :protected_branches, only: [:index, :create, :destroy]
miks's avatar
miks committed
163

164
    resources :refs, only: [] do
165
      collection do
gitlabhq's avatar
gitlabhq committed
166
167
168
        get "switch"
      end

169
      member do
170
171
        # tree viewer logs
        get "logs_tree", constraints: { id: /[a-zA-Z.\/0-9_\-]+/ }
randx's avatar
randx committed
172
        get "logs_tree/:path" => "refs#logs_tree",
Robert Speicher's avatar
Robert Speicher committed
173
174
175
176
          as: :logs_file,
          constraints: {
            id:   /[a-zA-Z.0-9\/_\-]+/,
            path: /.*/
randx's avatar
randx committed
177
          }
gitlabhq's avatar
gitlabhq committed
178
      end
gitlabhq's avatar
gitlabhq committed
179
    end
gitlabhq's avatar
gitlabhq committed
180

181
    resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do
182
      member do
183
        get :diffs
randx's avatar
randx committed
184
        get :automerge
Valery Sizov's avatar
Valery Sizov committed
185
        get :automerge_check
186
        get :ci_status
187
      end
188

189
      collection do
190
191
192
        get :branch_from
        get :branch_to
      end
193
    end
194
195
196

    resources :snippets do
      member do
197
198
199
200
        get "raw"
      end
    end

Robert Speicher's avatar
Robert Speicher committed
201
    resources :hooks, only: [:index, :create, :destroy] do
202
      member do
203
204
205
        get :test
      end
    end
206
207


Robert Speicher's avatar
Robert Speicher committed
208
    resources :team, controller: 'team_members', only: [:index]
209
    resources :milestones, except: [:destroy]
Robert Speicher's avatar
Robert Speicher committed
210
    resources :labels, only: [:index]
211
    resources :issues, except: [:destroy] do
VSizov's avatar
VSizov committed
212
      collection do
213
        post  :sort
randx's avatar
randx committed
214
        post  :bulk_update
215
        get   :search
Adam Leonard's avatar
Adam Leonard committed
216
      end
VSizov's avatar
VSizov committed
217
    end
Robert Speicher's avatar
Robert Speicher committed
218

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
219
220
221
222
223
224
225
226
227
228
    resources :team_members do
      collection do

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

Robert Speicher's avatar
Robert Speicher committed
229
    resources :notes, only: [:index, :create, :destroy] do
230
231
232
233
      collection do
        post :preview
      end
    end
gitlabhq's avatar
gitlabhq committed
234
  end
Robert Speicher's avatar
Robert Speicher committed
235
236

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