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