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