1 # frozen_string_literal: true
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"
10 use_doorkeeper_openid_connect :scope => "oauth2" if Settings.key?(:doorkeeper_signing_key)
14 get "capabilities" => "capabilities#show", :as => nil # Deprecated, remove when 0.6 support is removed
15 resource :versions, :only => :show
18 namespace :api, :path => "api/0.6" do
19 resource :capabilities, :only => :show
20 resource :permissions, :only => :show
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
29 resource :subscription, :controller => :changeset_subscriptions, :only => [:create, :destroy]
30 resources :changeset_comments, :path => "comment", :only => :create
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
36 resources :changeset_comments, :id => /\d+/, :only => :index do
37 resource :visibility, :module => :changeset_comments, :only => [:create, :destroy]
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
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
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]
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
56 resources :ways, :only => [:index, :create]
57 resources :ways, :path => "way", :id => /\d+/, :only => [:show, :update, :destroy] do
59 get :full, :action => :show, :full => true, :as => nil
61 scope :module => :ways do
62 resources :relations, :only => :index
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]
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
72 resources :relations, :only => [:index, :create]
73 resources :relations, :path => "relation", :id => /\d+/, :only => [:show, :update, :destroy] do
75 get :full, :action => :show, :full => true, :as => nil
77 scope :module => :relations do
78 resources :relations, :only => :index
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]
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
88 resource :map, :only => :show
90 resources :users, :only => :index
91 resources :users, :path => "user", :id => /\d+/, :only => :show
92 get "user/details" => "users#details"
94 resources :user_preferences, :except => [:new, :create, :edit], :param => :preference_key, :path => "user/preferences" do
96 put "" => "user_preferences#update_all", :as => ""
100 resources :messages, :path => "user/messages", :constraints => { :id => /\d+/ }, :only => [:create, :show, :update, :destroy]
101 namespace :messages, :path => "user/messages" do
102 resource :inbox, :only => :show
103 resource :outbox, :only => :show
105 post "/user/messages/:id" => "messages#update", :as => nil
107 # Lambda constraint, rather than a static if, so tests can toggle the setting per-request with with_settings
108 constraints(->(_req) { !Settings.traces_disabled }) do
109 resources :tracepoints, :path => "trackpoints", :only => :index
110 resources :user_traces, :path => "user/gpx_files", :module => :users, :controller => :traces, :only => :index
111 resources :traces, :path => "gpx", :only => [:create, :show, :update, :destroy], :id => /\d+/ do
112 scope :module => :traces do
113 resource :data, :only => :show
116 post "gpx/create" => "traces#create", :id => /\d+/, :as => :trace_create
117 get "gpx/:id/details" => "traces#show", :id => /\d+/, :as => :trace_details
121 resources :notes, :except => [:new, :edit, :update], :id => /\d+/, :controller => "notes" do
124 get "feed", :defaults => { :format => "rss" }
133 resource :subscription, :only => [:create, :destroy], :controller => "note_subscriptions"
136 resources :user_blocks, :only => [:show, :create], :id => /\d+/, :controller => "user_blocks"
137 namespace :user_blocks, :path => "user/blocks" do
138 resource :active_list, :path => "active", :only => :show
143 get "/way/:id" => "ways#show", :id => /\d+/, :as => :way
144 get "/way/:id/history" => "old_ways#index", :id => /\d+/, :as => :way_history
145 resources :old_ways, :path => "/way/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
146 get "/node/:id" => "nodes#show", :id => /\d+/, :as => :node
147 get "/node/:id/history" => "old_nodes#index", :id => /\d+/, :as => :node_history
148 resources :old_nodes, :path => "/node/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
150 get "/relation/:id" => "relations#show", :id => /\d+/, :as => :relation
151 get "/relation/:id/members" => "relation_members#show", :id => /\d+/, :as => :relation_members
153 get "/relation/:id/history" => "old_relations#index", :id => /\d+/, :as => :relation_history
154 resources :old_relations, :path => "/relation/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
155 get "/relation/:id/history/:version/members" => "old_relation_members#show", :id => /\d+/, :version => /\d+/, :as => :old_relation_members
157 resources :changesets, :path => "changeset", :id => /\d+/, :only => :show do
158 resource :subscription, :controller => :changeset_subscriptions, :only => [:show, :create, :destroy]
159 namespace :changeset_comments, :as => :comments, :path => :comments do
160 resource :feed, :only => :show, :defaults => { :format => "rss" }
163 get "/changeset/:id/subscribe", :id => /\d+/, :to => redirect(:path => "/changeset/%{id}/subscription")
164 get "/changeset/:id/unsubscribe", :id => /\d+/, :to => redirect(:path => "/changeset/%{id}/subscription")
166 resources :notes, :path => "note", :id => /\d+/, :only => [:show, :new]
168 get "/user/:display_name/history" => "changesets#index", :as => :user_history
169 get "/user/:display_name/history/feed" => "changesets#feed", :defaults => { :format => :atom }
170 get "/user/:display_name/notes" => "notes#index", :as => :user_notes
171 get "/history/friends" => "changesets#index", :friends => true, :as => "friend_changesets", :defaults => { :format => :html }
172 get "/history/nearby" => "changesets#index", :nearby => true, :as => "nearby_changesets", :defaults => { :format => :html }
174 get "/browse/way/:id", :to => redirect(:path => "/way/%{id}")
175 get "/browse/way/:id/history", :to => redirect(:path => "/way/%{id}/history")
176 get "/browse/node/:id", :to => redirect(:path => "/node/%{id}")
177 get "/browse/node/:id/history", :to => redirect(:path => "/node/%{id}/history")
178 get "/browse/relation/:id", :to => redirect(:path => "/relation/%{id}")
179 get "/browse/relation/:id/history", :to => redirect(:path => "/relation/%{id}/history")
180 get "/browse/changeset/:id", :to => redirect(:path => "/changeset/%{id}")
181 get "/browse/note/:id", :to => redirect(:path => "/note/%{id}")
182 get "/user/:display_name/edits", :to => redirect(:path => "/user/%{display_name}/history")
183 get "/user/:display_name/edits/feed", :to => redirect(:path => "/user/%{display_name}/history/feed")
184 get "/browse/friends", :to => redirect(:path => "/history/friends")
185 get "/browse/nearby", :to => redirect(:path => "/history/nearby")
186 get "/browse/changesets/feed", :to => redirect(:path => "/history/feed")
187 get "/browse/changesets", :to => redirect(:path => "/history")
188 get "/browse", :to => redirect(:path => "/history")
191 root :to => "site#index", :via => [:get, :post]
192 get "/edit" => "site#edit"
193 get "/copyright/:copyright_locale" => "site#copyright"
194 get "/copyright" => "site#copyright"
195 get "/welcome" => "site#welcome"
196 get "/fixthemap" => "site#fixthemap"
197 get "/help" => "site#help"
198 get "/about/:about_locale" => "site#about"
199 get "/about" => "site#about"
200 get "/communities" => "site#communities"
201 get "/history" => "changesets#index"
202 get "/history/feed" => "changesets#feed", :defaults => { :format => :atom }
204 namespace :changeset_comments, :path => :comments, :as => :changesets_comments do
205 resource :feed, :only => :show, :defaults => { :format => "rss" }
208 get "/export" => "site#export"
209 get "/login" => "sessions#new"
210 post "/login" => "sessions#create"
211 match "/logout" => "sessions#destroy", :via => [:get, :post]
212 get "/offline" => "site#offline"
213 resource :languages_pane, :path => "/panes/languages", :only => :show
214 resource :layers_pane, :path => "/panes/layers", :only => :show
215 resource :legend_pane, :path => "/panes/legend", :only => :show
216 resource :share_pane, :path => "/panes/share", :only => :show
217 resource :webgl_error_pane, :path => "/panes/webgl_error", :only => :show
218 get "/id" => "site#id"
219 resource :feature_query, :path => "query", :only => :show
220 post "/user/:display_name/confirm/resend" => "confirmations#confirm_resend", :as => :user_confirm_resend
221 match "/user/:display_name/confirm" => "confirmations#confirm", :via => [:get, :post]
222 match "/user/confirm" => "confirmations#confirm", :via => [:get, :post]
223 match "/user/confirm-email" => "confirmations#confirm_email", :via => [:get, :post]
224 post "/user/go_public" => "users#go_public"
225 scope :user, :as => "user" do
226 get "forgot-password" => "passwords#new"
227 post "forgot-password" => "passwords#create"
228 get "reset-password" => "passwords#edit"
229 post "reset-password" => "passwords#update"
231 get "/user/suspended" => "users#suspended"
233 get "/index.html", :to => redirect(:path => "/")
234 get "/create-account.html", :to => redirect(:path => "/user/new")
235 get "/forgot-password.html", :to => redirect(:path => "/user/forgot-password")
238 scope "/auth", :as => :auth do
239 get "/failure" => "users#auth_failure"
242 match "/callback" => "users#auth_success", :via => [:get, :post], :as => :success
243 match "" => "users#auth", :via => [:post, :patch]
245 resources :deletions, :only => [:show, :create], :module => "accounts", :controller => "auth_deletions", :param => :confirmation_code
250 get "/go/:code" => "site#permalink", :code => /[a-zA-Z0-9_@~]+[=-]*/, :as => :permalink
253 post "/preview/:type" => "site#preview", :as => :preview
256 constraints(->(_req) { !Settings.traces_disabled }) do
257 resources :traces, :id => /\d+/, :except => [:show] do
258 resource :data, :module => :traces, :only => :show
260 get "/user/:display_name/traces/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/traces/tag/%{tag}")
261 get "/user/:display_name/traces/tag/:tag" => "traces#index"
262 get "/user/:display_name/traces/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/traces")
263 get "/user/:display_name/traces" => "traces#index"
264 get "/user/:display_name/traces/:id" => "traces#show", :id => /\d+/, :as => "show_trace"
265 scope "/user/:display_name/traces/:trace_id", :module => :traces, :trace_id => /\d+/ do
266 get "picture" => "pictures#show", :as => "trace_picture"
267 get "icon" => "icons#show", :as => "trace_icon"
269 get "/traces/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/tag/%{tag}")
270 get "/traces/tag/:tag" => "traces#index"
271 get "/traces/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces")
272 get "/traces/mine/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/mine/tag/%{tag}")
273 get "/traces/mine/tag/:tag" => "traces#mine"
274 get "/traces/mine/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/mine")
275 get "/traces/mine" => "traces#mine"
276 get "/trace/create", :to => redirect(:path => "/traces/new")
277 get "/trace/:id/data", :format => false, :id => /\d+/, :to => redirect(:path => "/traces/%{id}/data")
278 get "/trace/:id/data.:format", :id => /\d+/, :to => redirect(:path => "/traces/%{id}/data.%{format}")
279 get "/trace/:id/edit", :id => /\d+/, :to => redirect(:path => "/traces/%{id}/edit")
281 namespace :traces, :path => "" do
282 resource :feed, :path => "(/user/:display_name)/traces(/tag/:tag)/rss", :only => :show, :defaults => { :format => :rss }
283 resource :legacy_visibility, :path => "/traces/mine/legacy_visibility", :only => [:edit, :update]
288 resources :diary_entries, :path => "diary", :only => [:new, :create, :index] do
290 get "friends" => "diary_entries#index", :friends => true
291 get "nearby" => "diary_entries#index", :nearby => true
294 get "/user/:display_name/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
295 get "/diary/:language/rss" => "diary_entries#rss", :defaults => { :format => :rss }
296 get "/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
297 get "/user/:display_name/diary" => "diary_entries#index", :as => :user_diary_entries
298 get "/diary/:language" => "diary_entries#index"
299 scope "/user/:display_name" do
300 resources :diary_entries, :path => "diary", :only => [:edit, :update, :show], :id => /\d+/ do
307 match "/user/:display_name/diary/:id/subscribe" => "diary_entries#subscribe", :via => [:get, :post], :as => :diary_entry_subscribe, :id => /\d+/
308 match "/user/:display_name/diary/:id/unsubscribe" => "diary_entries#unsubscribe", :via => [:get, :post], :as => :diary_entry_unsubscribe, :id => /\d+/
309 post "/user/:display_name/diary/:id/comments" => "diary_comments#create", :id => /\d+/, :as => :comment_diary_entry
310 post "/diary_comments/:comment/hide" => "diary_comments#hide", :comment => /\d+/, :as => :hide_diary_comment
311 post "/diary_comments/:comment/unhide" => "diary_comments#unhide", :comment => /\d+/, :as => :unhide_diary_comment
314 get "/user/terms", :to => redirect(:path => "/account/terms")
315 resources :users, :path => "user", :param => :display_name, :only => [:new, :create, :show] do
316 resource :role, :controller => "user_roles", :path => "roles/:role", :only => [:create, :destroy]
317 scope :module => :users do
318 resource :heatmap, :only => :show
319 resources :diary_comments, :only => :index
320 resources :changeset_comments, :only => :index
321 resource :issued_blocks, :path => "blocks_by", :only => :show
322 resource :received_blocks, :path => "blocks", :only => [:show, :edit, :destroy]
323 resource :status, :only => :update
326 get "/user/:display_name/account", :to => redirect(:path => "/account")
327 get "/user/:display_name/diary/comments(/:page)", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/diary_comments")
329 resource :account, :only => [:show, :update, :destroy] do
330 scope :module => :accounts do
331 resource :terms, :only => [:show, :update]
332 resource :pd_declaration, :only => [:show, :create]
333 resource :deletion, :only => :show
334 resource :home, :only => :show
337 get "/account/edit", :to => redirect(:path => "/account"), :as => nil
339 resource :dashboard, :only => [:show]
341 namespace :profile, :module => :profiles do
342 resource :description, :only => [:show, :update]
343 resource :links, :only => [:show, :update]
344 resource :heatmap, :only => [:show, :update]
345 resource :image, :only => [:show, :update]
346 resource :company, :only => [:show, :update]
347 resource :location, :only => [:show, :update]
349 get "/profile", :to => redirect(:path => "/profile/description"), :as => nil
350 get "/profile/edit", :to => redirect(:path => "/profile/description"), :as => nil
352 scope :preferences, :module => :preferences do
353 resource :basic_preferences, :path => "basic", :only => [:show, :update]
354 resource :notification_preferences, :path => "notifications", :only => [:show, :update]
355 resource :advanced_preferences, :path => "advanced", :only => [:show, :update]
357 get "/preferences", :to => redirect(:path => "/preferences/basic"), :as => nil
358 get "/preferences/edit", :to => redirect(:path => "/preferences/basic"), :as => nil
360 resources :notifications, :only => [:index]
363 scope "/user/:display_name" do
364 resource :follow, :only => [:create, :destroy, :show], :path => "follow"
366 get "make_friend", :to => redirect("/user/%{display_name}/follow")
367 get "remove_friend", :to => redirect("/user/%{display_name}/follow")
372 resource :list, :path => "(:status)", :only => [:show, :update]
376 resource :search, :only => :show do
377 scope :module => :searches do
378 resource :latlon_query, :only => :create
379 resource :nominatim_query, :only => :create
380 resource :nominatim_reverse_query, :only => :create
385 resource :directions, :only => :show
388 post "/export/finish" => "export#create"
389 get "/export/embed" => "export#show"
392 resources :messages, :path_names => { :new => "new/:display_name" }, :id => /\d+/, :only => [:new, :create, :show, :destroy] do
393 scope :module => :messages do
394 resource :reply, :path_names => { :new => "new" }, :only => :new
395 resource :read_mark, :only => [:create, :destroy]
396 resource :mute, :only => :destroy
399 namespace :messages, :path => "/messages" do
400 resource :inbox, :only => :show
401 resource :muted_inbox, :path => "muted", :only => :show
402 resource :outbox, :only => :show
404 get "/user/:display_name/inbox", :to => redirect(:path => "/messages/inbox")
405 get "/user/:display_name/outbox", :to => redirect(:path => "/messages/outbox")
406 get "/message/new/:display_name", :to => redirect(:path => "/messages/new/%{display_name}")
407 get "/message/read/:message_id", :to => redirect(:path => "/messages/%{message_id}")
408 get "/messages/:message_id/reply", :to => redirect(:path => "/messages/%{message_id}/reply/new")
411 scope "/user/:display_name" do
412 resource :user_mute, :only => [:create, :destroy], :path => "mute"
414 resources :user_mutes, :only => [:index]
417 resources :user_blocks, :path_names => { :new => "new/:display_name" }
421 resources :comments, :controller => :issue_comments
422 resources :reporters, :module => :issues, :only => :index
434 resources :redactions
437 resources :acls, :except => [:show]
440 resources :moderation_zones, :only => [:index, :new, :create, :edit, :update]
443 match "/400", :to => "errors#bad_request", :via => :all
444 match "/403", :to => "errors#forbidden", :via => :all
445 match "/404", :to => "errors#not_found", :via => :all
446 match "/500", :to => "errors#internal_server_error", :via => :all