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