]> git.openstreetmap.org Git - rails.git/blob - config/routes.rb
Move api changeset upload-download tests
[rails.git] / config / routes.rb
1 OpenStreetMap::Application.routes.draw do
2   use_doorkeeper :scope => "oauth2" do
3     controllers :authorizations => "oauth2_authorizations",
4                 :applications => "oauth2_applications",
5                 :authorized_applications => "oauth2_authorized_applications"
6   end
7
8   use_doorkeeper_openid_connect :scope => "oauth2" if Settings.key?(:doorkeeper_signing_key)
9
10   # API
11   namespace :api do
12     get "capabilities" => "capabilities#show" # Deprecated, remove when 0.6 support is removed
13     get "versions" => "versions#show"
14   end
15
16   scope "api/0.6", :module => :api do
17     get "capabilities" => "capabilities#show"
18     get "permissions" => "permissions#show"
19   end
20
21   namespace :api, :path => "api/0.6" do
22     resources :changesets, :only => [:index, :create]
23     resources :changesets, :path => "changeset", :id => /\d+/, :only => [:show, :update] do
24       scope :module => :changesets do
25         resource :upload, :only => :create
26         resource :download, :only => :show
27         resource :close, :only => :update
28       end
29       resource :subscription, :controller => :changeset_subscriptions, :only => [:create, :destroy]
30       resources :changeset_comments, :path => "comment", :only => :create
31     end
32     put "changeset/create" => "changesets#create", :as => nil
33     post "changeset/:changeset_id/subscribe" => "changeset_subscriptions#create", :changeset_id => /\d+/, :as => nil
34     post "changeset/:changeset_id/unsubscribe" => "changeset_subscriptions#destroy", :changeset_id => /\d+/, :as => nil
35
36     resources :changeset_comments, :id => /\d+/, :only => :index do
37       resource :visibility, :module => :changeset_comments, :only => [:create, :destroy]
38     end
39     post "changeset/comment/:changeset_comment_id/unhide" => "changeset_comments/visibilities#create", :changeset_comment_id => /\d+/, :as => nil
40     post "changeset/comment/:changeset_comment_id/hide" => "changeset_comments/visibilities#destroy", :changeset_comment_id => /\d+/, :as => nil
41
42     resources :nodes, :only => [:index, :create]
43     resources :nodes, :path => "node", :id => /\d+/, :only => [:show, :update, :destroy] do
44       scope :module => :nodes do
45         resources :ways, :only => :index
46         resources :relations, :only => :index
47       end
48       resources :versions, :path => "history", :controller => :old_nodes, :only => :index
49       resource :version, :path => ":version", :version => /\d+/, :controller => :old_nodes, :only => :show do
50         resource :redaction, :module => :old_nodes, :only => [:create, :destroy]
51       end
52     end
53     put "node/create" => "nodes#create", :as => nil
54     post "node/:node_id/:version/redact" => "old_nodes/redactions#create", :node_id => /\d+/, :version => /\d+/, :allow_delete => true, :as => nil
55
56     resources :ways, :only => [:index, :create]
57     resources :ways, :path => "way", :id => /\d+/, :only => [:show, :update, :destroy] do
58       member do
59         get :full, :action => :show, :full => true, :as => nil
60       end
61       scope :module => :ways do
62         resources :relations, :only => :index
63       end
64       resources :versions, :path => "history", :controller => :old_ways, :only => :index
65       resource :version, :path => ":version", :version => /\d+/, :controller => :old_ways, :only => :show do
66         resource :redaction, :module => :old_ways, :only => [:create, :destroy]
67       end
68     end
69     put "way/create" => "ways#create", :as => nil
70     post "way/:way_id/:version/redact" => "old_ways/redactions#create", :way_id => /\d+/, :version => /\d+/, :allow_delete => true, :as => nil
71
72     resources :relations, :only => [:index, :create]
73     resources :relations, :path => "relation", :id => /\d+/, :only => [:show, :update, :destroy] do
74       member do
75         get :full, :action => :show, :full => true, :as => nil
76       end
77       scope :module => :relations do
78         resources :relations, :only => :index
79       end
80       resources :versions, :path => "history", :controller => :old_relations, :only => :index
81       resource :version, :path => ":version", :version => /\d+/, :controller => :old_relations, :only => :show do
82         resource :redaction, :module => :old_relations, :only => [:create, :destroy]
83       end
84     end
85     put "relation/create" => "relations#create", :as => nil
86     post "relation/:relation_id/:version/redact" => "old_relations/redactions#create", :relation_id => /\d+/, :version => /\d+/, :allow_delete => true, :as => nil
87
88     resource :map, :only => :show
89
90     resources :tracepoints, :path => "trackpoints", :only => :index
91
92     resources :users, :only => :index
93     resources :users, :path => "user", :id => /\d+/, :only => :show
94     resources :user_traces, :path => "user/gpx_files", :module => :users, :controller => :traces, :only => :index
95     get "user/details" => "users#details"
96
97     resources :user_preferences, :except => [:new, :create, :edit], :param => :preference_key, :path => "user/preferences" do
98       collection do
99         put "" => "user_preferences#update_all", :as => ""
100       end
101     end
102
103     resources :messages, :path => "user/messages", :constraints => { :id => /\d+/ }, :only => [:create, :show, :update, :destroy]
104     namespace :messages, :path => "user/messages" do
105       resource :inbox, :only => :show
106       resource :outbox, :only => :show
107     end
108     post "/user/messages/:id" => "messages#update", :as => nil
109
110     resources :traces, :path => "gpx", :only => [:create, :show, :update, :destroy], :id => /\d+/ do
111       scope :module => :traces do
112         resource :data, :only => :show
113       end
114     end
115     post "gpx/create" => "traces#create", :id => /\d+/, :as => :trace_create
116     get "gpx/:id/details" => "traces#show", :id => /\d+/, :as => :trace_details
117
118     # Map notes API
119     resources :notes, :except => [:new, :edit, :update], :id => /\d+/, :controller => "notes" do
120       collection do
121         get "search"
122         get "feed", :defaults => { :format => "rss" }
123       end
124
125       member do
126         post "comment"
127         post "close"
128         post "reopen"
129       end
130
131       resource :subscription, :only => [:create, :destroy], :controller => "note_subscriptions"
132     end
133
134     resources :user_blocks, :only => [:show, :create], :id => /\d+/, :controller => "user_blocks"
135     namespace :user_blocks, :path => "user/blocks" do
136       resource :active_list, :path => "active", :only => :show
137     end
138   end
139
140   # Data browsing
141   get "/way/:id" => "ways#show", :id => /\d+/, :as => :way
142   get "/way/:id/history" => "old_ways#index", :id => /\d+/, :as => :way_history
143   resources :old_ways, :path => "/way/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
144   get "/node/:id" => "nodes#show", :id => /\d+/, :as => :node
145   get "/node/:id/history" => "old_nodes#index", :id => /\d+/, :as => :node_history
146   resources :old_nodes, :path => "/node/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
147   get "/relation/:id" => "relations#show", :id => /\d+/, :as => :relation
148   get "/relation/:id/history" => "old_relations#index", :id => /\d+/, :as => :relation_history
149   resources :old_relations, :path => "/relation/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
150
151   resources :changesets, :path => "changeset", :id => /\d+/, :only => :show do
152     resource :subscription, :controller => :changeset_subscriptions, :only => [:show, :create, :destroy]
153     namespace :changeset_comments, :as => :comments, :path => :comments do
154       resource :feed, :only => :show, :defaults => { :format => "rss" }
155     end
156   end
157   get "/changeset/:id/subscribe", :id => /\d+/, :to => redirect(:path => "/changeset/%{id}/subscription")
158   get "/changeset/:id/unsubscribe", :id => /\d+/, :to => redirect(:path => "/changeset/%{id}/subscription")
159
160   resources :notes, :path => "note", :id => /\d+/, :only => [:show, :new]
161
162   get "/user/:display_name/history" => "changesets#index"
163   get "/user/:display_name/history/feed" => "changesets#feed", :defaults => { :format => :atom }
164   get "/user/:display_name/notes" => "notes#index", :as => :user_notes
165   get "/history/friends" => "changesets#index", :friends => true, :as => "friend_changesets", :defaults => { :format => :html }
166   get "/history/nearby" => "changesets#index", :nearby => true, :as => "nearby_changesets", :defaults => { :format => :html }
167
168   get "/browse/way/:id",                :to => redirect(:path => "/way/%{id}")
169   get "/browse/way/:id/history",        :to => redirect(:path => "/way/%{id}/history")
170   get "/browse/node/:id",               :to => redirect(:path => "/node/%{id}")
171   get "/browse/node/:id/history",       :to => redirect(:path => "/node/%{id}/history")
172   get "/browse/relation/:id",           :to => redirect(:path => "/relation/%{id}")
173   get "/browse/relation/:id/history",   :to => redirect(:path => "/relation/%{id}/history")
174   get "/browse/changeset/:id",          :to => redirect(:path => "/changeset/%{id}")
175   get "/browse/note/:id",               :to => redirect(:path => "/note/%{id}")
176   get "/user/:display_name/edits",      :to => redirect(:path => "/user/%{display_name}/history")
177   get "/user/:display_name/edits/feed", :to => redirect(:path => "/user/%{display_name}/history/feed")
178   get "/browse/friends",                :to => redirect(:path => "/history/friends")
179   get "/browse/nearby",                 :to => redirect(:path => "/history/nearby")
180   get "/browse/changesets/feed",        :to => redirect(:path => "/history/feed")
181   get "/browse/changesets",             :to => redirect(:path => "/history")
182   get "/browse",                        :to => redirect(:path => "/history")
183
184   # web site
185   root :to => "site#index", :via => [:get, :post]
186   get "/edit" => "site#edit"
187   get "/copyright/:copyright_locale" => "site#copyright"
188   get "/copyright" => "site#copyright"
189   get "/welcome" => "site#welcome"
190   get "/fixthemap" => "site#fixthemap"
191   get "/help" => "site#help"
192   get "/about/:about_locale" => "site#about"
193   get "/about" => "site#about"
194   get "/communities" => "site#communities"
195   get "/history" => "changesets#index"
196   get "/history/feed" => "changesets#feed", :defaults => { :format => :atom }
197   scope "/history" do
198     namespace :changeset_comments, :path => :comments, :as => :changesets_comments do
199       resource :feed, :only => :show, :defaults => { :format => "rss" }
200     end
201   end
202   get "/export" => "site#export"
203   get "/login" => "sessions#new"
204   post "/login" => "sessions#create"
205   match "/logout" => "sessions#destroy", :via => [:get, :post]
206   get "/offline" => "site#offline"
207   resource :map_key, :path => "key", :only => :show
208   get "/id" => "site#id"
209   resource :feature_query, :path => "query", :only => :show
210   post "/user/:display_name/confirm/resend" => "confirmations#confirm_resend", :as => :user_confirm_resend
211   match "/user/:display_name/confirm" => "confirmations#confirm", :via => [:get, :post]
212   match "/user/confirm" => "confirmations#confirm", :via => [:get, :post]
213   match "/user/confirm-email" => "confirmations#confirm_email", :via => [:get, :post]
214   post "/user/go_public" => "users#go_public"
215   scope :user, :as => "user" do
216     get "forgot-password" => "passwords#new"
217     post "forgot-password" => "passwords#create"
218     get "reset-password" => "passwords#edit"
219     post "reset-password" => "passwords#update"
220   end
221   get "/user/suspended" => "users#suspended"
222
223   get "/index.html", :to => redirect(:path => "/")
224   get "/create-account.html", :to => redirect(:path => "/user/new")
225   get "/forgot-password.html", :to => redirect(:path => "/user/forgot-password")
226
227   # omniauth
228   get "/auth/failure" => "users#auth_failure"
229   match "/auth/:provider/callback" => "users#auth_success", :via => [:get, :post], :as => :auth_success
230   match "/auth/:provider" => "users#auth", :via => [:post, :patch], :as => :auth
231
232   # permalink
233   get "/go/:code" => "site#permalink", :code => /[a-zA-Z0-9_@~]+[=-]*/, :as => :permalink
234
235   # rich text preview
236   post "/preview/:type" => "site#preview", :as => :preview
237
238   # traces
239   resources :traces, :id => /\d+/, :except => [:show] do
240     resource :data, :module => :traces, :only => :show
241   end
242   get "/user/:display_name/traces/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/traces/tag/%{tag}")
243   get "/user/:display_name/traces/tag/:tag" => "traces#index"
244   get "/user/:display_name/traces/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/traces")
245   get "/user/:display_name/traces" => "traces#index"
246   get "/user/:display_name/traces/:id" => "traces#show", :id => /\d+/, :as => "show_trace"
247   scope "/user/:display_name/traces/:trace_id", :module => :traces, :trace_id => /\d+/ do
248     get "picture" => "pictures#show", :as => "trace_picture"
249     get "icon" => "icons#show", :as => "trace_icon"
250   end
251   get "/traces/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/tag/%{tag}")
252   get "/traces/tag/:tag" => "traces#index"
253   get "/traces/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces")
254   get "/traces/mine/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/mine/tag/%{tag}")
255   get "/traces/mine/tag/:tag" => "traces#mine"
256   get "/traces/mine/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/mine")
257   get "/traces/mine" => "traces#mine"
258   get "/trace/create", :to => redirect(:path => "/traces/new")
259   get "/trace/:id/data", :format => false, :id => /\d+/, :to => redirect(:path => "/traces/%{id}/data")
260   get "/trace/:id/data.:format", :id => /\d+/, :to => redirect(:path => "/traces/%{id}/data.%{format}")
261   get "/trace/:id/edit", :id => /\d+/, :to => redirect(:path => "/traces/%{id}/edit")
262
263   namespace :traces, :path => "" do
264     resource :feed, :path => "(/user/:display_name)/traces(/tag/:tag)/rss", :only => :show, :defaults => { :format => :rss }
265   end
266
267   # diary pages
268   resources :diary_entries, :path => "diary", :only => [:new, :create, :index] do
269     collection do
270       get "friends" => "diary_entries#index", :friends => true
271       get "nearby" => "diary_entries#index", :nearby => true
272     end
273   end
274   get "/user/:display_name/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
275   get "/diary/:language/rss" => "diary_entries#rss", :defaults => { :format => :rss }
276   get "/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
277   get "/user/:display_name/diary" => "diary_entries#index"
278   get "/diary/:language" => "diary_entries#index"
279   scope "/user/:display_name" do
280     resources :diary_entries, :path => "diary", :only => [:edit, :update, :show], :id => /\d+/ do
281       member do
282         post :hide
283         post :unhide
284       end
285     end
286   end
287   match "/user/:display_name/diary/:id/subscribe" => "diary_entries#subscribe", :via => [:get, :post], :as => :diary_entry_subscribe, :id => /\d+/
288   match "/user/:display_name/diary/:id/unsubscribe" => "diary_entries#unsubscribe", :via => [:get, :post], :as => :diary_entry_unsubscribe, :id => /\d+/
289   post "/user/:display_name/diary/:id/comments" => "diary_comments#create", :id => /\d+/, :as => :comment_diary_entry
290   post "/diary_comments/:comment/hide" => "diary_comments#hide", :comment => /\d+/, :as => :hide_diary_comment
291   post "/diary_comments/:comment/unhide" => "diary_comments#unhide", :comment => /\d+/, :as => :unhide_diary_comment
292
293   # user pages
294   get "/user/terms", :to => redirect(:path => "/account/terms")
295   resources :users, :path => "user", :param => :display_name, :only => [:new, :create, :show] do
296     resource :role, :controller => "user_roles", :path => "roles/:role", :only => [:create, :destroy]
297     scope :module => :users do
298       resources :diary_comments, :only => :index
299       resources :changeset_comments, :only => :index
300       resource :issued_blocks, :path => "blocks_by", :only => :show
301       resource :received_blocks, :path => "blocks", :only => [:show, :edit, :destroy]
302       resource :status, :only => :update
303     end
304   end
305   get "/user/:display_name/account", :to => redirect(:path => "/account")
306   get "/user/:display_name/diary/comments(/:page)", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/diary_comments")
307
308   resource :account, :only => [:show, :update, :destroy] do
309     scope :module => :accounts do
310       resource :terms, :only => [:show, :update]
311       resource :pd_declaration, :only => [:show, :create]
312       resource :deletion, :only => :show
313       resource :home, :only => :show
314     end
315   end
316   get "/account/edit", :to => redirect(:path => "/account"), :as => nil
317
318   resource :dashboard, :only => [:show]
319   resource :preferences, :only => [:show, :update]
320   get "/preferences/edit", :to => redirect(:path => "/preferences")
321   resource :profile, :only => [:edit, :update]
322
323   # friendships
324   scope "/user/:display_name" do
325     resource :follow, :only => [:create, :destroy, :show], :path => "follow"
326
327     get "make_friend", :to => redirect("/user/%{display_name}/follow")
328     get "remove_friend", :to => redirect("/user/%{display_name}/follow")
329   end
330
331   # user lists
332   namespace :users do
333     resource :list, :path => "(:status)", :only => [:show, :update]
334   end
335
336   # geocoder
337   resource :search, :only => :show do
338     scope :module => :searches do
339       resource :latlon_query, :only => :create
340       resource :nominatim_query, :only => :create
341       resource :nominatim_reverse_query, :only => :create
342     end
343   end
344
345   # directions
346   get "/directions" => "directions#search"
347
348   # export
349   post "/export/finish" => "export#finish"
350   get "/export/embed" => "export#embed"
351
352   # messages
353   resources :messages, :path_names => { :new => "new/:display_name" }, :id => /\d+/, :only => [:new, :create, :show, :destroy] do
354     scope :module => :messages do
355       resource :reply, :path_names => { :new => "new" }, :only => :new
356       resource :read_mark, :only => [:create, :destroy]
357       resource :mute, :only => :destroy
358     end
359   end
360   namespace :messages, :path => "/messages" do
361     resource :inbox, :only => :show
362     resource :muted_inbox, :path => "muted", :only => :show
363     resource :outbox, :only => :show
364   end
365   get "/user/:display_name/inbox", :to => redirect(:path => "/messages/inbox")
366   get "/user/:display_name/outbox", :to => redirect(:path => "/messages/outbox")
367   get "/message/new/:display_name", :to => redirect(:path => "/messages/new/%{display_name}")
368   get "/message/read/:message_id", :to => redirect(:path => "/messages/%{message_id}")
369   get "/messages/:message_id/reply", :to => redirect(:path => "/messages/%{message_id}/reply/new")
370
371   # muting users
372   scope "/user/:display_name" do
373     resource :user_mute, :only => [:create, :destroy], :path => "mute"
374   end
375   resources :user_mutes, :only => [:index]
376
377   # banning pages
378   resources :user_blocks, :path_names => { :new => "new/:display_name" }
379
380   # issues and reports
381   resources :issues do
382     resources :comments, :controller => :issue_comments
383     resources :reporters, :module => :issues, :only => :index
384     member do
385       post "resolve"
386       post "assign"
387       post "ignore"
388       post "reopen"
389     end
390   end
391
392   resources :reports
393
394   # redactions
395   resources :redactions
396
397   # errors
398   match "/400", :to => "errors#bad_request", :via => :all
399   match "/403", :to => "errors#forbidden", :via => :all
400   match "/404", :to => "errors#not_found", :via => :all
401   match "/500", :to => "errors#internal_server_error", :via => :all
402 end