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"
8 use_doorkeeper_openid_connect :scope => "oauth2" if Settings.key?(:doorkeeper_signing_key)
12 get "capabilities" => "capabilities#show" # Deprecated, remove when 0.6 support is removed
13 get "versions" => "versions#show"
16 scope "api/0.6", :module => :api do
17 get "capabilities" => "capabilities#show"
18 get "permissions" => "permissions#show"
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+/
33 get "node/:id/history" => "old_nodes#history", :as => :api_node_history, :id => /\d+/
34 post "node/:id/:version/redact" => "old_nodes#redact", :as => :node_version_redact, :version => /\d+/, :id => /\d+/
35 get "node/:id/:version" => "old_nodes#show", :as => :api_old_node, :id => /\d+/, :version => /\d+/
37 get "way/:id/history" => "old_ways#history", :as => :api_way_history, :id => /\d+/
38 post "way/:id/:version/redact" => "old_ways#redact", :as => :way_version_redact, :version => /\d+/, :id => /\d+/
39 get "way/:id/:version" => "old_ways#show", :as => :api_old_way, :id => /\d+/, :version => /\d+/
41 get "relation/:id/relations" => "relations#relations_for_relation", :as => :relation_relations, :id => /\d+/
42 get "relation/:id/history" => "old_relations#history", :as => :api_relation_history, :id => /\d+/
43 post "relation/:id/:version/redact" => "old_relations#redact", :as => :relation_version_redact, :version => /\d+/, :id => /\d+/
44 get "relation/:id/:version" => "old_relations#show", :as => :api_old_relation, :id => /\d+/, :version => /\d+/
47 namespace :api, :path => "api/0.6" do
48 resources :nodes, :only => [:index, :create]
49 resources :nodes, :path => "node", :id => /\d+/, :only => [:show, :update, :destroy] do
50 scope :module => :nodes do
51 resources :ways, :only => :index
52 resources :relations, :only => :index
55 put "node/create" => "nodes#create", :as => nil
57 resources :ways, :only => [:index, :create]
58 resources :ways, :path => "way", :id => /\d+/, :only => [:show, :update, :destroy] do
60 get :full, :action => :show, :full => true, :as => nil
62 scope :module => :ways do
63 resources :relations, :only => :index
66 put "way/create" => "ways#create", :as => nil
68 resources :relations, :only => [:index, :create]
69 resources :relations, :path => "relation", :id => /\d+/, :only => [:show, :update, :destroy] do
71 get :full, :action => :show, :full => true, :as => nil
74 put "relation/create" => "relations#create", :as => nil
76 resource :map, :only => :show
78 resources :tracepoints, :path => "trackpoints", :only => :index
80 resources :users, :only => :index
81 resources :users, :path => "user", :id => /\d+/, :only => :show
82 resources :user_traces, :path => "user/gpx_files", :module => :users, :controller => :traces, :only => :index
83 get "user/details" => "users#details"
85 resources :user_preferences, :except => [:new, :create, :edit], :param => :preference_key, :path => "user/preferences" do
87 put "" => "user_preferences#update_all", :as => ""
91 resources :messages, :path => "user/messages", :constraints => { :id => /\d+/ }, :only => [:create, :show, :update, :destroy]
92 namespace :messages, :path => "user/messages" do
93 resource :inbox, :only => :show
94 resource :outbox, :only => :show
96 post "/user/messages/:id" => "messages#update", :as => nil
98 resources :traces, :path => "gpx", :only => [:create, :show, :update, :destroy], :id => /\d+/ do
99 scope :module => :traces do
100 resource :data, :only => :show
103 post "gpx/create" => "traces#create", :id => /\d+/, :as => :trace_create
104 get "gpx/:id/details" => "traces#show", :id => /\d+/, :as => :trace_details
107 resources :notes, :except => [:new, :edit, :update], :id => /\d+/, :controller => "notes" do
110 get "feed", :defaults => { :format => "rss" }
119 resource :subscription, :only => [:create, :destroy], :controller => "note_subscriptions"
122 resources :user_blocks, :only => :show, :id => /\d+/, :controller => "user_blocks"
126 get "/way/:id" => "ways#show", :id => /\d+/, :as => :way
127 get "/way/:id/history" => "old_ways#index", :id => /\d+/, :as => :way_history
128 resources :old_ways, :path => "/way/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
129 get "/node/:id" => "nodes#show", :id => /\d+/, :as => :node
130 get "/node/:id/history" => "old_nodes#index", :id => /\d+/, :as => :node_history
131 resources :old_nodes, :path => "/node/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
132 get "/relation/:id" => "relations#show", :id => /\d+/, :as => :relation
133 get "/relation/:id/history" => "old_relations#index", :id => /\d+/, :as => :relation_history
134 resources :old_relations, :path => "/relation/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
136 resources :changesets, :path => "changeset", :id => /\d+/, :only => :show do
137 resource :subscription, :controller => :changeset_subscriptions, :only => [:show, :create, :destroy]
138 namespace :changeset_comments, :as => :comments, :path => :comments do
139 resource :feed, :only => :show, :defaults => { :format => "rss" }
142 get "/changeset/:id/subscribe", :id => /\d+/, :to => redirect(:path => "/changeset/%{id}/subscription")
143 get "/changeset/:id/unsubscribe", :id => /\d+/, :to => redirect(:path => "/changeset/%{id}/subscription")
145 resources :notes, :path => "note", :id => /\d+/, :only => [:show, :new]
147 get "/user/:display_name/history" => "changesets#index"
148 get "/user/:display_name/history/feed" => "changesets#feed", :defaults => { :format => :atom }
149 get "/user/:display_name/notes" => "notes#index", :as => :user_notes
150 get "/history/friends" => "changesets#index", :friends => true, :as => "friend_changesets", :defaults => { :format => :html }
151 get "/history/nearby" => "changesets#index", :nearby => true, :as => "nearby_changesets", :defaults => { :format => :html }
153 get "/browse/way/:id", :to => redirect(:path => "/way/%{id}")
154 get "/browse/way/:id/history", :to => redirect(:path => "/way/%{id}/history")
155 get "/browse/node/:id", :to => redirect(:path => "/node/%{id}")
156 get "/browse/node/:id/history", :to => redirect(:path => "/node/%{id}/history")
157 get "/browse/relation/:id", :to => redirect(:path => "/relation/%{id}")
158 get "/browse/relation/:id/history", :to => redirect(:path => "/relation/%{id}/history")
159 get "/browse/changeset/:id", :to => redirect(:path => "/changeset/%{id}")
160 get "/browse/note/:id", :to => redirect(:path => "/note/%{id}")
161 get "/user/:display_name/edits", :to => redirect(:path => "/user/%{display_name}/history")
162 get "/user/:display_name/edits/feed", :to => redirect(:path => "/user/%{display_name}/history/feed")
163 get "/browse/friends", :to => redirect(:path => "/history/friends")
164 get "/browse/nearby", :to => redirect(:path => "/history/nearby")
165 get "/browse/changesets/feed", :to => redirect(:path => "/history/feed")
166 get "/browse/changesets", :to => redirect(:path => "/history")
167 get "/browse", :to => redirect(:path => "/history")
170 root :to => "site#index", :via => [:get, :post]
171 get "/edit" => "site#edit"
172 get "/copyright/:copyright_locale" => "site#copyright"
173 get "/copyright" => "site#copyright"
174 get "/welcome" => "site#welcome"
175 get "/fixthemap" => "site#fixthemap"
176 get "/help" => "site#help"
177 get "/about/:about_locale" => "site#about"
178 get "/about" => "site#about"
179 get "/communities" => "site#communities"
180 get "/history" => "changesets#index"
181 get "/history/feed" => "changesets#feed", :defaults => { :format => :atom }
183 namespace :changeset_comments, :path => :comments, :as => :changesets_comments do
184 resource :feed, :only => :show, :defaults => { :format => "rss" }
187 get "/export" => "site#export"
188 get "/login" => "sessions#new"
189 post "/login" => "sessions#create"
190 match "/logout" => "sessions#destroy", :via => [:get, :post]
191 get "/offline" => "site#offline"
192 get "/key" => "site#key"
193 get "/id" => "site#id"
194 get "/query" => "browse#query"
195 post "/user/:display_name/confirm/resend" => "confirmations#confirm_resend", :as => :user_confirm_resend
196 match "/user/:display_name/confirm" => "confirmations#confirm", :via => [:get, :post]
197 match "/user/confirm" => "confirmations#confirm", :via => [:get, :post]
198 match "/user/confirm-email" => "confirmations#confirm_email", :via => [:get, :post]
199 post "/user/go_public" => "users#go_public"
200 scope :user, :as => "user" do
201 get "forgot-password" => "passwords#new"
202 post "forgot-password" => "passwords#create"
203 get "reset-password" => "passwords#edit"
204 post "reset-password" => "passwords#update"
206 get "/user/suspended" => "users#suspended"
208 get "/index.html", :to => redirect(:path => "/")
209 get "/create-account.html", :to => redirect(:path => "/user/new")
210 get "/forgot-password.html", :to => redirect(:path => "/user/forgot-password")
213 get "/auth/failure" => "users#auth_failure"
214 match "/auth/:provider/callback" => "users#auth_success", :via => [:get, :post], :as => :auth_success
215 match "/auth/:provider" => "users#auth", :via => [:post, :patch], :as => :auth
218 get "/go/:code" => "site#permalink", :code => /[a-zA-Z0-9_@~]+[=-]*/, :as => :permalink
221 post "/preview/:type" => "site#preview", :as => :preview
224 resources :traces, :id => /\d+/, :except => [:show] do
225 resource :data, :module => :traces, :only => :show
227 get "/user/:display_name/traces/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/traces/tag/%{tag}")
228 get "/user/:display_name/traces/tag/:tag" => "traces#index"
229 get "/user/:display_name/traces/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/traces")
230 get "/user/:display_name/traces" => "traces#index"
231 get "/user/:display_name/traces/:id" => "traces#show", :id => /\d+/, :as => "show_trace"
232 scope "/user/:display_name/traces/:trace_id", :module => :traces, :trace_id => /\d+/ do
233 get "picture" => "pictures#show", :as => "trace_picture"
234 get "icon" => "icons#show", :as => "trace_icon"
236 get "/traces/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/tag/%{tag}")
237 get "/traces/tag/:tag" => "traces#index"
238 get "/traces/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces")
239 get "/traces/mine/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/mine/tag/%{tag}")
240 get "/traces/mine/tag/:tag" => "traces#mine"
241 get "/traces/mine/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/mine")
242 get "/traces/mine" => "traces#mine"
243 get "/trace/create", :to => redirect(:path => "/traces/new")
244 get "/trace/:id/data", :format => false, :id => /\d+/, :to => redirect(:path => "/traces/%{id}/data")
245 get "/trace/:id/data.:format", :id => /\d+/, :to => redirect(:path => "/traces/%{id}/data.%{format}")
246 get "/trace/:id/edit", :id => /\d+/, :to => redirect(:path => "/traces/%{id}/edit")
248 namespace :traces, :path => "" do
249 resource :feed, :path => "(/user/:display_name)/traces(/tag/:tag)/rss", :only => :show, :defaults => { :format => :rss }
253 resources :diary_entries, :path => "diary", :only => [:new, :create, :index] do
255 get "friends" => "diary_entries#index", :friends => true
256 get "nearby" => "diary_entries#index", :nearby => true
259 get "/user/:display_name/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
260 get "/diary/:language/rss" => "diary_entries#rss", :defaults => { :format => :rss }
261 get "/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
262 get "/user/:display_name/diary" => "diary_entries#index"
263 get "/diary/:language" => "diary_entries#index"
264 scope "/user/:display_name" do
265 resources :diary_entries, :path => "diary", :only => [:edit, :update, :show], :id => /\d+/ do
272 match "/user/:display_name/diary/:id/subscribe" => "diary_entries#subscribe", :via => [:get, :post], :as => :diary_entry_subscribe, :id => /\d+/
273 match "/user/:display_name/diary/:id/unsubscribe" => "diary_entries#unsubscribe", :via => [:get, :post], :as => :diary_entry_unsubscribe, :id => /\d+/
274 post "/user/:display_name/diary/:id/comments" => "diary_comments#create", :id => /\d+/, :as => :comment_diary_entry
275 post "/diary_comments/:comment/hide" => "diary_comments#hide", :comment => /\d+/, :as => :hide_diary_comment
276 post "/diary_comments/:comment/unhide" => "diary_comments#unhide", :comment => /\d+/, :as => :unhide_diary_comment
279 get "/user/terms", :to => redirect(:path => "/account/terms")
280 resources :users, :path => "user", :param => :display_name, :only => [:new, :create, :show] do
281 resource :role, :controller => "user_roles", :path => "roles/:role", :only => [:create, :destroy]
282 scope :module => :users do
283 resources :diary_comments, :only => :index
284 resources :changeset_comments, :only => :index
285 resource :issued_blocks, :path => "blocks_by", :only => :show
286 resource :received_blocks, :path => "blocks", :only => [:show, :edit, :destroy]
287 resource :status, :only => :update
290 get "/user/:display_name/account", :to => redirect(:path => "/account/edit")
291 get "/user/:display_name/diary/comments(/:page)", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/diary_comments")
293 resource :account, :only => [:edit, :update, :destroy] do
294 scope :module => :accounts do
295 resource :terms, :only => [:show, :update]
296 resource :deletion, :only => :show
300 resource :dashboard, :only => [:show]
301 resource :preferences, :only => [:show, :update]
302 get "/preferences/edit", :to => redirect(:path => "/preferences")
303 resource :profile, :only => [:edit, :update]
306 scope "/user/:display_name" do
307 resource :follow, :only => [:create, :destroy, :show], :path => "follow"
309 get "make_friend", :to => redirect("/user/%{display_name}/follow")
310 get "remove_friend", :to => redirect("/user/%{display_name}/follow")
315 resource :list, :path => "(:status)", :only => [:show, :update]
319 get "/search" => "geocoder#search"
320 post "/geocoder/search_latlon" => "geocoder#search_latlon"
321 post "/geocoder/search_osm_nominatim" => "geocoder#search_osm_nominatim"
322 post "/geocoder/search_osm_nominatim_reverse" => "geocoder#search_osm_nominatim_reverse"
325 get "/directions" => "directions#search"
328 post "/export/finish" => "export#finish"
329 get "/export/embed" => "export#embed"
332 resources :messages, :path_names => { :new => "new/:display_name" }, :id => /\d+/, :only => [:new, :create, :show, :destroy] do
333 scope :module => :messages do
334 resource :reply, :path_names => { :new => "new" }, :only => :new
335 resource :read_mark, :only => [:create, :destroy]
336 resource :mute, :only => :destroy
339 namespace :messages, :path => "/messages" do
340 resource :inbox, :only => :show
341 resource :muted_inbox, :path => "muted", :only => :show
342 resource :outbox, :only => :show
344 get "/user/:display_name/inbox", :to => redirect(:path => "/messages/inbox")
345 get "/user/:display_name/outbox", :to => redirect(:path => "/messages/outbox")
346 get "/message/new/:display_name", :to => redirect(:path => "/messages/new/%{display_name}")
347 get "/message/read/:message_id", :to => redirect(:path => "/messages/%{message_id}")
348 get "/messages/:message_id/reply", :to => redirect(:path => "/messages/%{message_id}/reply/new")
351 scope "/user/:display_name" do
352 resource :user_mute, :only => [:create, :destroy], :path => "mute"
354 resources :user_mutes, :only => [:index]
357 resources :user_blocks, :path_names => { :new => "new/:display_name" }
361 resources :comments, :controller => :issue_comments
373 resources :redactions
376 match "/400", :to => "errors#bad_request", :via => :all
377 match "/403", :to => "errors#forbidden", :via => :all
378 match "/404", :to => "errors#not_found", :via => :all
379 match "/500", :to => "errors#internal_server_error", :via => :all