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     post "way/:way_id/:version/redact" => "old_ways#redact", :as => :way_version_redact, :version => /\d+/, :id => /\d+/
 
  35     post "relation/:relation_id/:version/redact" => "old_relations#redact", :as => :relation_version_redact, :version => /\d+/, :id => /\d+/
 
  38   namespace :api, :path => "api/0.6" do
 
  39     resources :changeset_comments, :only => :index
 
  41     resources :nodes, :only => [:index, :create]
 
  42     resources :nodes, :path => "node", :id => /\d+/, :only => [:show, :update, :destroy] do
 
  43       scope :module => :nodes do
 
  44         resources :ways, :only => :index
 
  45         resources :relations, :only => :index
 
  47       resources :versions, :path => "history", :controller => :old_nodes, :only => :index
 
  48       resource :version, :path => ":version", :version => /\d+/, :controller => :old_nodes, :only => :show do
 
  49         resource :redaction, :module => :old_nodes, :only => [:create, :destroy]
 
  52     put "node/create" => "nodes#create", :as => nil
 
  53     post "node/:node_id/:version/redact" => "old_nodes/redactions#create", :node_id => /\d+/, :version => /\d+/, :allow_delete => true, :as => nil
 
  55     resources :ways, :only => [:index, :create]
 
  56     resources :ways, :path => "way", :id => /\d+/, :only => [:show, :update, :destroy] do
 
  58         get :full, :action => :show, :full => true, :as => nil
 
  60       scope :module => :ways do
 
  61         resources :relations, :only => :index
 
  63       resources :versions, :path => "history", :controller => :old_ways, :only => :index
 
  64       resources :versions, :path => "", :version => /\d+/, :param => :version, :controller => :old_ways, :only => :show
 
  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
 
  73       scope :module => :relations do
 
  74         resources :relations, :only => :index
 
  76       resources :versions, :path => "history", :controller => :old_relations, :only => :index
 
  77       resources :versions, :path => "", :version => /\d+/, :param => :version, :controller => :old_relations, :only => :show
 
  79     put "relation/create" => "relations#create", :as => nil
 
  81     resource :map, :only => :show
 
  83     resources :tracepoints, :path => "trackpoints", :only => :index
 
  85     resources :users, :only => :index
 
  86     resources :users, :path => "user", :id => /\d+/, :only => :show
 
  87     resources :user_traces, :path => "user/gpx_files", :module => :users, :controller => :traces, :only => :index
 
  88     get "user/details" => "users#details"
 
  90     resources :user_preferences, :except => [:new, :create, :edit], :param => :preference_key, :path => "user/preferences" do
 
  92         put "" => "user_preferences#update_all", :as => ""
 
  96     resources :messages, :path => "user/messages", :constraints => { :id => /\d+/ }, :only => [:create, :show, :update, :destroy]
 
  97     namespace :messages, :path => "user/messages" do
 
  98       resource :inbox, :only => :show
 
  99       resource :outbox, :only => :show
 
 101     post "/user/messages/:id" => "messages#update", :as => nil
 
 103     resources :traces, :path => "gpx", :only => [:create, :show, :update, :destroy], :id => /\d+/ do
 
 104       scope :module => :traces do
 
 105         resource :data, :only => :show
 
 108     post "gpx/create" => "traces#create", :id => /\d+/, :as => :trace_create
 
 109     get "gpx/:id/details" => "traces#show", :id => /\d+/, :as => :trace_details
 
 112     resources :notes, :except => [:new, :edit, :update], :id => /\d+/, :controller => "notes" do
 
 115         get "feed", :defaults => { :format => "rss" }
 
 124       resource :subscription, :only => [:create, :destroy], :controller => "note_subscriptions"
 
 127     resources :user_blocks, :only => [:show, :create], :id => /\d+/, :controller => "user_blocks"
 
 128     namespace :user_blocks, :path => "user/blocks" do
 
 129       resource :active_list, :path => "active", :only => :show
 
 134   get "/way/:id" => "ways#show", :id => /\d+/, :as => :way
 
 135   get "/way/:id/history" => "old_ways#index", :id => /\d+/, :as => :way_history
 
 136   resources :old_ways, :path => "/way/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
 
 137   get "/node/:id" => "nodes#show", :id => /\d+/, :as => :node
 
 138   get "/node/:id/history" => "old_nodes#index", :id => /\d+/, :as => :node_history
 
 139   resources :old_nodes, :path => "/node/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
 
 140   get "/relation/:id" => "relations#show", :id => /\d+/, :as => :relation
 
 141   get "/relation/:id/history" => "old_relations#index", :id => /\d+/, :as => :relation_history
 
 142   resources :old_relations, :path => "/relation/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
 
 144   resources :changesets, :path => "changeset", :id => /\d+/, :only => :show do
 
 145     resource :subscription, :controller => :changeset_subscriptions, :only => [:show, :create, :destroy]
 
 146     namespace :changeset_comments, :as => :comments, :path => :comments do
 
 147       resource :feed, :only => :show, :defaults => { :format => "rss" }
 
 150   get "/changeset/:id/subscribe", :id => /\d+/, :to => redirect(:path => "/changeset/%{id}/subscription")
 
 151   get "/changeset/:id/unsubscribe", :id => /\d+/, :to => redirect(:path => "/changeset/%{id}/subscription")
 
 153   resources :notes, :path => "note", :id => /\d+/, :only => [:show, :new]
 
 155   get "/user/:display_name/history" => "changesets#index"
 
 156   get "/user/:display_name/history/feed" => "changesets#feed", :defaults => { :format => :atom }
 
 157   get "/user/:display_name/notes" => "notes#index", :as => :user_notes
 
 158   get "/history/friends" => "changesets#index", :friends => true, :as => "friend_changesets", :defaults => { :format => :html }
 
 159   get "/history/nearby" => "changesets#index", :nearby => true, :as => "nearby_changesets", :defaults => { :format => :html }
 
 161   get "/browse/way/:id",                :to => redirect(:path => "/way/%{id}")
 
 162   get "/browse/way/:id/history",        :to => redirect(:path => "/way/%{id}/history")
 
 163   get "/browse/node/:id",               :to => redirect(:path => "/node/%{id}")
 
 164   get "/browse/node/:id/history",       :to => redirect(:path => "/node/%{id}/history")
 
 165   get "/browse/relation/:id",           :to => redirect(:path => "/relation/%{id}")
 
 166   get "/browse/relation/:id/history",   :to => redirect(:path => "/relation/%{id}/history")
 
 167   get "/browse/changeset/:id",          :to => redirect(:path => "/changeset/%{id}")
 
 168   get "/browse/note/:id",               :to => redirect(:path => "/note/%{id}")
 
 169   get "/user/:display_name/edits",      :to => redirect(:path => "/user/%{display_name}/history")
 
 170   get "/user/:display_name/edits/feed", :to => redirect(:path => "/user/%{display_name}/history/feed")
 
 171   get "/browse/friends",                :to => redirect(:path => "/history/friends")
 
 172   get "/browse/nearby",                 :to => redirect(:path => "/history/nearby")
 
 173   get "/browse/changesets/feed",        :to => redirect(:path => "/history/feed")
 
 174   get "/browse/changesets",             :to => redirect(:path => "/history")
 
 175   get "/browse",                        :to => redirect(:path => "/history")
 
 178   root :to => "site#index", :via => [:get, :post]
 
 179   get "/edit" => "site#edit"
 
 180   get "/copyright/:copyright_locale" => "site#copyright"
 
 181   get "/copyright" => "site#copyright"
 
 182   get "/welcome" => "site#welcome"
 
 183   get "/fixthemap" => "site#fixthemap"
 
 184   get "/help" => "site#help"
 
 185   get "/about/:about_locale" => "site#about"
 
 186   get "/about" => "site#about"
 
 187   get "/communities" => "site#communities"
 
 188   get "/history" => "changesets#index"
 
 189   get "/history/feed" => "changesets#feed", :defaults => { :format => :atom }
 
 191     namespace :changeset_comments, :path => :comments, :as => :changesets_comments do
 
 192       resource :feed, :only => :show, :defaults => { :format => "rss" }
 
 195   get "/export" => "site#export"
 
 196   get "/login" => "sessions#new"
 
 197   post "/login" => "sessions#create"
 
 198   match "/logout" => "sessions#destroy", :via => [:get, :post]
 
 199   get "/offline" => "site#offline"
 
 200   get "/key" => "site#key"
 
 201   get "/id" => "site#id"
 
 202   get "/query" => "browse#query"
 
 203   post "/user/:display_name/confirm/resend" => "confirmations#confirm_resend", :as => :user_confirm_resend
 
 204   match "/user/:display_name/confirm" => "confirmations#confirm", :via => [:get, :post]
 
 205   match "/user/confirm" => "confirmations#confirm", :via => [:get, :post]
 
 206   match "/user/confirm-email" => "confirmations#confirm_email", :via => [:get, :post]
 
 207   post "/user/go_public" => "users#go_public"
 
 208   scope :user, :as => "user" do
 
 209     get "forgot-password" => "passwords#new"
 
 210     post "forgot-password" => "passwords#create"
 
 211     get "reset-password" => "passwords#edit"
 
 212     post "reset-password" => "passwords#update"
 
 214   get "/user/suspended" => "users#suspended"
 
 216   get "/index.html", :to => redirect(:path => "/")
 
 217   get "/create-account.html", :to => redirect(:path => "/user/new")
 
 218   get "/forgot-password.html", :to => redirect(:path => "/user/forgot-password")
 
 221   get "/auth/failure" => "users#auth_failure"
 
 222   match "/auth/:provider/callback" => "users#auth_success", :via => [:get, :post], :as => :auth_success
 
 223   match "/auth/:provider" => "users#auth", :via => [:post, :patch], :as => :auth
 
 226   get "/go/:code" => "site#permalink", :code => /[a-zA-Z0-9_@~]+[=-]*/, :as => :permalink
 
 229   post "/preview/:type" => "site#preview", :as => :preview
 
 232   resources :traces, :id => /\d+/, :except => [:show] do
 
 233     resource :data, :module => :traces, :only => :show
 
 235   get "/user/:display_name/traces/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/traces/tag/%{tag}")
 
 236   get "/user/:display_name/traces/tag/:tag" => "traces#index"
 
 237   get "/user/:display_name/traces/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/traces")
 
 238   get "/user/:display_name/traces" => "traces#index"
 
 239   get "/user/:display_name/traces/:id" => "traces#show", :id => /\d+/, :as => "show_trace"
 
 240   scope "/user/:display_name/traces/:trace_id", :module => :traces, :trace_id => /\d+/ do
 
 241     get "picture" => "pictures#show", :as => "trace_picture"
 
 242     get "icon" => "icons#show", :as => "trace_icon"
 
 244   get "/traces/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/tag/%{tag}")
 
 245   get "/traces/tag/:tag" => "traces#index"
 
 246   get "/traces/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces")
 
 247   get "/traces/mine/tag/:tag/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/mine/tag/%{tag}")
 
 248   get "/traces/mine/tag/:tag" => "traces#mine"
 
 249   get "/traces/mine/page/:page", :page => /[1-9][0-9]*/, :to => redirect(:path => "/traces/mine")
 
 250   get "/traces/mine" => "traces#mine"
 
 251   get "/trace/create", :to => redirect(:path => "/traces/new")
 
 252   get "/trace/:id/data", :format => false, :id => /\d+/, :to => redirect(:path => "/traces/%{id}/data")
 
 253   get "/trace/:id/data.:format", :id => /\d+/, :to => redirect(:path => "/traces/%{id}/data.%{format}")
 
 254   get "/trace/:id/edit", :id => /\d+/, :to => redirect(:path => "/traces/%{id}/edit")
 
 256   namespace :traces, :path => "" do
 
 257     resource :feed, :path => "(/user/:display_name)/traces(/tag/:tag)/rss", :only => :show, :defaults => { :format => :rss }
 
 261   resources :diary_entries, :path => "diary", :only => [:new, :create, :index] do
 
 263       get "friends" => "diary_entries#index", :friends => true
 
 264       get "nearby" => "diary_entries#index", :nearby => true
 
 267   get "/user/:display_name/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
 
 268   get "/diary/:language/rss" => "diary_entries#rss", :defaults => { :format => :rss }
 
 269   get "/diary/rss" => "diary_entries#rss", :defaults => { :format => :rss }
 
 270   get "/user/:display_name/diary" => "diary_entries#index"
 
 271   get "/diary/:language" => "diary_entries#index"
 
 272   scope "/user/:display_name" do
 
 273     resources :diary_entries, :path => "diary", :only => [:edit, :update, :show], :id => /\d+/ do
 
 280   match "/user/:display_name/diary/:id/subscribe" => "diary_entries#subscribe", :via => [:get, :post], :as => :diary_entry_subscribe, :id => /\d+/
 
 281   match "/user/:display_name/diary/:id/unsubscribe" => "diary_entries#unsubscribe", :via => [:get, :post], :as => :diary_entry_unsubscribe, :id => /\d+/
 
 282   post "/user/:display_name/diary/:id/comments" => "diary_comments#create", :id => /\d+/, :as => :comment_diary_entry
 
 283   post "/diary_comments/:comment/hide" => "diary_comments#hide", :comment => /\d+/, :as => :hide_diary_comment
 
 284   post "/diary_comments/:comment/unhide" => "diary_comments#unhide", :comment => /\d+/, :as => :unhide_diary_comment
 
 287   get "/user/terms", :to => redirect(:path => "/account/terms")
 
 288   resources :users, :path => "user", :param => :display_name, :only => [:new, :create, :show] do
 
 289     resource :role, :controller => "user_roles", :path => "roles/:role", :only => [:create, :destroy]
 
 290     scope :module => :users do
 
 291       resources :diary_comments, :only => :index
 
 292       resources :changeset_comments, :only => :index
 
 293       resource :issued_blocks, :path => "blocks_by", :only => :show
 
 294       resource :received_blocks, :path => "blocks", :only => [:show, :edit, :destroy]
 
 295       resource :status, :only => :update
 
 298   get "/user/:display_name/account", :to => redirect(:path => "/account/edit")
 
 299   get "/user/:display_name/diary/comments(/:page)", :page => /[1-9][0-9]*/, :to => redirect(:path => "/user/%{display_name}/diary_comments")
 
 301   resource :account, :only => [:edit, :update, :destroy] do
 
 302     scope :module => :accounts do
 
 303       resource :terms, :only => [:show, :update]
 
 304       resource :pd_declaration, :only => [:show, :create]
 
 305       resource :deletion, :only => :show
 
 306       resource :home, :only => :show
 
 310   resource :dashboard, :only => [:show]
 
 311   resource :preferences, :only => [:show, :update]
 
 312   get "/preferences/edit", :to => redirect(:path => "/preferences")
 
 313   resource :profile, :only => [:edit, :update]
 
 316   scope "/user/:display_name" do
 
 317     resource :follow, :only => [:create, :destroy, :show], :path => "follow"
 
 319     get "make_friend", :to => redirect("/user/%{display_name}/follow")
 
 320     get "remove_friend", :to => redirect("/user/%{display_name}/follow")
 
 325     resource :list, :path => "(:status)", :only => [:show, :update]
 
 329   get "/search" => "geocoder#search"
 
 330   post "/geocoder/search_latlon" => "geocoder#search_latlon"
 
 331   post "/geocoder/search_osm_nominatim" => "geocoder#search_osm_nominatim"
 
 332   post "/geocoder/search_osm_nominatim_reverse" => "geocoder#search_osm_nominatim_reverse"
 
 335   get "/directions" => "directions#search"
 
 338   post "/export/finish" => "export#finish"
 
 339   get "/export/embed" => "export#embed"
 
 342   resources :messages, :path_names => { :new => "new/:display_name" }, :id => /\d+/, :only => [:new, :create, :show, :destroy] do
 
 343     scope :module => :messages do
 
 344       resource :reply, :path_names => { :new => "new" }, :only => :new
 
 345       resource :read_mark, :only => [:create, :destroy]
 
 346       resource :mute, :only => :destroy
 
 349   namespace :messages, :path => "/messages" do
 
 350     resource :inbox, :only => :show
 
 351     resource :muted_inbox, :path => "muted", :only => :show
 
 352     resource :outbox, :only => :show
 
 354   get "/user/:display_name/inbox", :to => redirect(:path => "/messages/inbox")
 
 355   get "/user/:display_name/outbox", :to => redirect(:path => "/messages/outbox")
 
 356   get "/message/new/:display_name", :to => redirect(:path => "/messages/new/%{display_name}")
 
 357   get "/message/read/:message_id", :to => redirect(:path => "/messages/%{message_id}")
 
 358   get "/messages/:message_id/reply", :to => redirect(:path => "/messages/%{message_id}/reply/new")
 
 361   scope "/user/:display_name" do
 
 362     resource :user_mute, :only => [:create, :destroy], :path => "mute"
 
 364   resources :user_mutes, :only => [:index]
 
 367   resources :user_blocks, :path_names => { :new => "new/:display_name" }
 
 371     resources :comments, :controller => :issue_comments
 
 383   resources :redactions
 
 386   match "/400", :to => "errors#bad_request", :via => :all
 
 387   match "/403", :to => "errors#forbidden", :via => :all
 
 388   match "/404", :to => "errors#not_found", :via => :all
 
 389   match "/500", :to => "errors#internal_server_error", :via => :all