]> git.openstreetmap.org Git - rails.git/blob - config/routes.rb
Add frozen_string_literal comments to ruby files
[rails.git] / config / routes.rb
1 # frozen_string_literal: true
2
3 OpenStreetMap::Application.routes.draw do
4   use_doorkeeper :scope => "oauth2" do
5     controllers :authorizations => "oauth2_authorizations",
6                 :applications => "oauth2_applications",
7                 :authorized_applications => "oauth2_authorized_applications"
8   end
9
10   use_doorkeeper_openid_connect :scope => "oauth2" if Settings.key?(:doorkeeper_signing_key)
11
12   # API
13   namespace :api do
14     get "capabilities" => "capabilities#show", :as => nil # Deprecated, remove when 0.6 support is removed
15     resource :versions, :only => :show
16   end
17
18   namespace :api, :path => "api/0.6" do
19     resource :capabilities, :only => :show
20     resource :permissions, :only => :show
21
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
148   get "/relation/:id" => "relations#show", :id => /\d+/, :as => :relation
149   get "/relation/:id/members" => "relation_members#show", :id => /\d+/, :as => :relation_members
150
151   get "/relation/:id/history" => "old_relations#index", :id => /\d+/, :as => :relation_history
152   resources :old_relations, :path => "/relation/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
153   get "/relation/:id/history/:version/members" => "old_relation_members#show", :id => /\d+/, :version => /\d+/, :as => :old_relation_members
154
155   resources :changesets, :path => "changeset", :id => /\d+/, :only => :show do
156     resource :subscription, :controller => :changeset_subscriptions, :only => [:show, :create, :destroy]
157     namespace :changeset_comments, :as => :comments, :path => :comments do
158       resource :feed, :only => :show, :defaults => { :format => "rss" }
159     end
160   end
161   get "/changeset/:id/subscribe", :id => /\d+/, :to => redirect(:path => "/changeset/%{id}/subscription")
162   get "/changeset/:id/unsubscribe", :id => /\d+/, :to => redirect(:path => "/changeset/%{id}/subscription")
163
164   resources :notes, :path => "note", :id => /\d+/, :only => [:show, :new]
165
166   get "/user/:display_name/history" => "changesets#index", :as => :user_history
167   get "/user/:display_name/history/feed" => "changesets#feed", :defaults => { :format => :atom }
168   get "/user/:display_name/notes" => "notes#index", :as => :user_notes
169   get "/history/friends" => "changesets#index", :friends => true, :as => "friend_changesets", :defaults => { :format => :html }
170   get "/history/nearby" => "changesets#index", :nearby => true, :as => "nearby_changesets", :defaults => { :format => :html }
171
172   get "/browse/way/:id",                :to => redirect(:path => "/way/%{id}")
173   get "/browse/way/:id/history",        :to => redirect(:path => "/way/%{id}/history")
174   get "/browse/node/:id",               :to => redirect(:path => "/node/%{id}")
175   get "/browse/node/:id/history",       :to => redirect(:path => "/node/%{id}/history")
176   get "/browse/relation/:id",           :to => redirect(:path => "/relation/%{id}")
177   get "/browse/relation/:id/history",   :to => redirect(:path => "/relation/%{id}/history")
178   get "/browse/changeset/:id",          :to => redirect(:path => "/changeset/%{id}")
179   get "/browse/note/:id",               :to => redirect(:path => "/note/%{id}")
180   get "/user/:display_name/edits",      :to => redirect(:path => "/user/%{display_name}/history")
181   get "/user/:display_name/edits/feed", :to => redirect(:path => "/user/%{display_name}/history/feed")
182   get "/browse/friends",                :to => redirect(:path => "/history/friends")
183   get "/browse/nearby",                 :to => redirect(:path => "/history/nearby")
184   get "/browse/changesets/feed",        :to => redirect(:path => "/history/feed")
185   get "/browse/changesets",             :to => redirect(:path => "/history")
186   get "/browse",                        :to => redirect(:path => "/history")
187
188   # web site
189   root :to => "site#index", :via => [:get, :post]
190   get "/edit" => "site#edit"
191   get "/copyright/:copyright_locale" => "site#copyright"
192   get "/copyright" => "site#copyright"
193   get "/welcome" => "site#welcome"
194   get "/fixthemap" => "site#fixthemap"
195   get "/help" => "site#help"
196   get "/about/:about_locale" => "site#about"
197   get "/about" => "site#about"
198   get "/communities" => "site#communities"
199   get "/history" => "changesets#index"
200   get "/history/feed" => "changesets#feed", :defaults => { :format => :atom }
201   scope "/history" do
202     namespace :changeset_comments, :path => :comments, :as => :changesets_comments do
203       resource :feed, :only => :show, :defaults => { :format => "rss" }
204     end
205   end
206   get "/export" => "site#export"
207   get "/login" => "sessions#new"
208   post "/login" => "sessions#create"
209   match "/logout" => "sessions#destroy", :via => [:get, :post]
210   get "/offline" => "site#offline"
211   resource :layers_pane, :path => "/panes/layers", :only => :show
212   resource :legend_pane, :path => "/panes/legend", :only => :show
213   resource :share_pane, :path => "/panes/share", :only => :show
214   get "/id" => "site#id"
215   resource :feature_query, :path => "query", :only => :show
216   post "/user/:display_name/confirm/resend" => "confirmations#confirm_resend", :as => :user_confirm_resend
217   match "/user/:display_name/confirm" => "confirmations#confirm", :via => [:get, :post]
218   match "/user/confirm" => "confirmations#confirm", :via => [:get, :post]
219   match "/user/confirm-email" => "confirmations#confirm_email", :via => [:get, :post]
220   post "/user/go_public" => "users#go_public"
221   scope :user, :as => "user" do
222     get "forgot-password" => "passwords#new"
223     post "forgot-password" => "passwords#create"
224     get "reset-password" => "passwords#edit"
225     post "reset-password" => "passwords#update"
226   end
227   get "/user/suspended" => "users#suspended"
228
229   get "/index.html", :to => redirect(:path => "/")
230   get "/create-account.html", :to => redirect(:path => "/user/new")
231   get "/forgot-password.html", :to => redirect(:path => "/user/forgot-password")
232
233   # omniauth
234   get "/auth/failure" => "users#auth_failure"
235   match "/auth/:provider/callback" => "users#auth_success", :via => [:get, :post], :as => :auth_success
236   match "/auth/:provider" => "users#auth", :via => [:post, :patch], :as => :auth
237
238   # permalink
239   get "/go/:code" => "site#permalink", :code => /[a-zA-Z0-9_@~]+[=-]*/, :as => :permalink
240
241   # rich text preview
242   post "/preview/:type" => "site#preview", :as => :preview
243
244   # traces
245   resources :traces, :id => /\d+/, :except => [:show] do
246     resource :data, :module => :traces, :only => :show
247   end
248   get "/user/:display_name/traces/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/traces/tag/%{tag}")
249   get "/user/:display_name/traces/tag/:tag" => "traces#index"
250   get "/user/:display_name/traces/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/traces")
251   get "/user/:display_name/traces" => "traces#index"
252   get "/user/:display_name/traces/:id" => "traces#show", :id => /\d+/, :as => "show_trace"
253   scope "/user/:display_name/traces/:trace_id", :module => :traces, :trace_id => /\d+/ do
254     get "picture" => "pictures#show", :as => "trace_picture"
255     get "icon" => "icons#show", :as => "trace_icon"
256   end
257   get "/traces/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/tag/%{tag}")
258   get "/traces/tag/:tag" => "traces#index"
259   get "/traces/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces")
260   get "/traces/mine/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/mine/tag/%{tag}")
261   get "/traces/mine/tag/:tag" => "traces#mine"
262   get "/traces/mine/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/mine")
263   get "/traces/mine" => "traces#mine"
264   get "/trace/create", :to => redirect(:path => "/traces/new")
265   get "/trace/:id/data", :format => false, :id => /\d+/, :to => redirect(:path => "/traces/%{id}/data")
266   get "/trace/:id/data.:format", :id => /\d+/, :to => redirect(:path => "/traces/%{id}/data.%{format}")
267   get "/trace/:id/edit", :id => /\d+/, :to => redirect(:path => "/traces/%{id}/edit")
268
269   namespace :traces, :path => "" do
270     resource :feed, :path => "(/user/:display_name)/traces(/tag/:tag)/rss", :only => :show, :defaults => { :format => :rss }
271   end
272
273   # diary pages
274   resources :diary_entries, :path => "diary", :only => [:new, :create, :index] do
275     collection do
276       get "friends" => "diary_entries#index", :friends => true
277       get "nearby" => "diary_entries#index", :nearby => true
278     end
279   end
280   get "/user/:display_name/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
281   get "/diary/:language/rss" => "diary_entries#rss", :defaults => { :format => :rss }
282   get "/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
283   get "/user/:display_name/diary" => "diary_entries#index", :as => :user_diary_entries
284   get "/diary/:language" => "diary_entries#index"
285   scope "/user/:display_name" do
286     resources :diary_entries, :path => "diary", :only => [:edit, :update, :show], :id => /\d+/ do
287       member do
288         post :hide
289         post :unhide
290       end
291     end
292   end
293   match "/user/:display_name/diary/:id/subscribe" => "diary_entries#subscribe", :via => [:get, :post], :as => :diary_entry_subscribe, :id => /\d+/
294   match "/user/:display_name/diary/:id/unsubscribe" => "diary_entries#unsubscribe", :via => [:get, :post], :as => :diary_entry_unsubscribe, :id => /\d+/
295   post "/user/:display_name/diary/:id/comments" => "diary_comments#create", :id => /\d+/, :as => :comment_diary_entry
296   post "/diary_comments/:comment/hide" => "diary_comments#hide", :comment => /\d+/, :as => :hide_diary_comment
297   post "/diary_comments/:comment/unhide" => "diary_comments#unhide", :comment => /\d+/, :as => :unhide_diary_comment
298
299   # user pages
300   get "/user/terms", :to => redirect(:path => "/account/terms")
301   resources :users, :path => "user", :param => :display_name, :only => [:new, :create, :show] do
302     resource :role, :controller => "user_roles", :path => "roles/:role", :only => [:create, :destroy]
303     scope :module => :users do
304       resource :heatmap, :only => :show
305       resources :diary_comments, :only => :index
306       resources :changeset_comments, :only => :index
307       resource :issued_blocks, :path => "blocks_by", :only => :show
308       resource :received_blocks, :path => "blocks", :only => [:show, :edit, :destroy]
309       resource :status, :only => :update
310     end
311   end
312   get "/user/:display_name/account", :to => redirect(:path => "/account")
313   get "/user/:display_name/diary/comments(/:page)", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/diary_comments")
314
315   resource :account, :only => [:show, :update, :destroy] do
316     scope :module => :accounts do
317       resource :terms, :only => [:show, :update]
318       resource :pd_declaration, :only => [:show, :create]
319       resource :deletion, :only => :show
320       resource :home, :only => :show
321     end
322   end
323   get "/account/edit", :to => redirect(:path => "/account"), :as => nil
324
325   resource :dashboard, :only => [:show]
326
327   namespace :profile, :module => :profiles do
328     resource :description, :only => [:show, :update]
329     resource :links, :only => [:show, :update]
330     resource :image, :only => [:show, :update]
331     resource :company, :only => [:show, :update]
332     resource :location, :only => [:show, :update]
333   end
334   get "/profile", :to => redirect(:path => "/profile/description"), :as => nil
335   get "/profile/edit", :to => redirect(:path => "/profile/description"), :as => nil
336
337   scope :preferences, :module => :preferences do
338     resource :basic_preferences, :path => "basic", :only => [:show, :update]
339     resource :advanced_preferences, :path => "advanced", :only => [:show, :update]
340   end
341   get "/preferences", :to => redirect(:path => "/preferences/basic"), :as => nil
342   get "/preferences/edit", :to => redirect(:path => "/preferences/basic"), :as => nil
343
344   # friendships
345   scope "/user/:display_name" do
346     resource :follow, :only => [:create, :destroy, :show], :path => "follow"
347
348     get "make_friend", :to => redirect("/user/%{display_name}/follow")
349     get "remove_friend", :to => redirect("/user/%{display_name}/follow")
350   end
351
352   # user lists
353   namespace :users do
354     resource :list, :path => "(:status)", :only => [:show, :update]
355   end
356
357   # geocoder
358   resource :search, :only => :show do
359     scope :module => :searches do
360       resource :latlon_query, :only => :create
361       resource :nominatim_query, :only => :create
362       resource :nominatim_reverse_query, :only => :create
363     end
364   end
365
366   # directions
367   resource :directions, :only => :show
368
369   # export
370   post "/export/finish" => "export#finish"
371   get "/export/embed" => "export#embed"
372
373   # messages
374   resources :messages, :path_names => { :new => "new/:display_name" }, :id => /\d+/, :only => [:new, :create, :show, :destroy] do
375     scope :module => :messages do
376       resource :reply, :path_names => { :new => "new" }, :only => :new
377       resource :read_mark, :only => [:create, :destroy]
378       resource :mute, :only => :destroy
379     end
380   end
381   namespace :messages, :path => "/messages" do
382     resource :inbox, :only => :show
383     resource :muted_inbox, :path => "muted", :only => :show
384     resource :outbox, :only => :show
385   end
386   get "/user/:display_name/inbox", :to => redirect(:path => "/messages/inbox")
387   get "/user/:display_name/outbox", :to => redirect(:path => "/messages/outbox")
388   get "/message/new/:display_name", :to => redirect(:path => "/messages/new/%{display_name}")
389   get "/message/read/:message_id", :to => redirect(:path => "/messages/%{message_id}")
390   get "/messages/:message_id/reply", :to => redirect(:path => "/messages/%{message_id}/reply/new")
391
392   # muting users
393   scope "/user/:display_name" do
394     resource :user_mute, :only => [:create, :destroy], :path => "mute"
395   end
396   resources :user_mutes, :only => [:index]
397
398   # banning pages
399   resources :user_blocks, :path_names => { :new => "new/:display_name" }
400
401   # issues and reports
402   resources :issues do
403     resources :comments, :controller => :issue_comments
404     resources :reporters, :module => :issues, :only => :index
405     member do
406       post "resolve"
407       post "assign"
408       post "ignore"
409       post "reopen"
410     end
411   end
412
413   resources :reports
414
415   # redactions
416   resources :redactions
417
418   # errors
419   match "/400", :to => "errors#bad_request", :via => :all
420   match "/403", :to => "errors#forbidden", :via => :all
421   match "/404", :to => "errors#not_found", :via => :all
422   match "/500", :to => "errors#internal_server_error", :via => :all
423 end