diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb
index e4b9dcf6bf..200911a414 100644
--- a/app/abilities/ability.rb
+++ b/app/abilities/ability.rb
@@ -4,11 +4,11 @@ class Ability
include CanCan::Ability
def initialize(user)
- can :query, :browse
+ can :read, [:feature_query, :feature_key]
can :read, [Node, Way, Relation, OldNode, OldWay, OldRelation]
can [:show, :create], Note
can :search, :direction
- can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :key, :id], :site
+ can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :id], :site
can [:finish, :embed], :export
can [:search, :search_latlon, :search_osm_nominatim, :search_osm_nominatim_reverse], :geocoder
diff --git a/app/controllers/browse_controller.rb b/app/controllers/browse_controller.rb
deleted file mode 100644
index a3e65a1b7b..0000000000
--- a/app/controllers/browse_controller.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class BrowseController < ApplicationController
- layout :map_layout
-
- before_action :authorize_web
- before_action :set_locale
- before_action -> { check_database_readable(:need_api => true) }
- before_action :require_oauth
- before_action :update_totp, :only => [:query]
- around_action :web_timeout
- authorize_resource :class => false
-
- def query; end
-end
diff --git a/app/controllers/features/keys_controller.rb b/app/controllers/features/keys_controller.rb
new file mode 100644
index 0000000000..ad1ae63f3c
--- /dev/null
+++ b/app/controllers/features/keys_controller.rb
@@ -0,0 +1,21 @@
+module Features
+ class KeysController < ApplicationController
+ before_action :authorize_web
+ before_action :set_locale
+
+ authorize_resource :class => :feature_key
+
+ def show
+ expires_in 7.days, :public => true
+ @key = YAML.load_file(Rails.root.join("config/key.yml"))
+ @key.each_value do |layer_data|
+ layer_data.each do |entry|
+ entry["name"] = Array(entry["name"])
+ end
+ layer_data.each_cons(2) do |entry, next_entry|
+ entry["max_zoom"] = next_entry["min_zoom"] - 1 if entry["name"] == next_entry["name"] && !entry["max_zoom"] && next_entry["min_zoom"]
+ end
+ end
+ end
+ end
+end
diff --git a/app/controllers/features/queries_controller.rb b/app/controllers/features/queries_controller.rb
new file mode 100644
index 0000000000..78b4088c2e
--- /dev/null
+++ b/app/controllers/features/queries_controller.rb
@@ -0,0 +1,15 @@
+module Features
+ class QueriesController < ApplicationController
+ layout :map_layout
+
+ before_action :authorize_web
+ before_action :set_locale
+ before_action -> { check_database_readable(:need_api => true) }
+ before_action :require_oauth
+ before_action :update_totp
+ around_action :web_timeout
+ authorize_resource :class => :feature_query
+
+ def show; end
+ end
+end
diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb
index 58f0a11c93..3fd7242c74 100644
--- a/app/controllers/site_controller.rb
+++ b/app/controllers/site_controller.rb
@@ -57,20 +57,6 @@ def permalink
redirect_to path
end
- def key
- expires_in 7.days, :public => true
- @key = YAML.load_file(Rails.root.join("config/key.yml"))
- @key.each_value do |layer_data|
- layer_data.each do |entry|
- entry["name"] = Array(entry["name"])
- end
- layer_data.each_cons(2) do |entry, next_entry|
- entry["max_zoom"] = next_entry["min_zoom"] - 1 if entry["name"] == next_entry["name"] && !entry["max_zoom"] && next_entry["min_zoom"]
- end
- end
- render :layout => false
- end
-
def edit
editor = preferred_editor
diff --git a/app/views/site/key.html.erb b/app/views/features/keys/show.html.erb
similarity index 87%
rename from app/views/site/key.html.erb
rename to app/views/features/keys/show.html.erb
index 82105097e7..2453f14921 100644
--- a/app/views/site/key.html.erb
+++ b/app/views/features/keys/show.html.erb
@@ -11,7 +11,7 @@
<% end %>
- <%= entry["name"].map { |feature_name| t ".table.entry.#{feature_name}" }.join(" · ") %>
+ <%= entry["name"].map { |feature_name| t ".entries.#{feature_name}" }.join(" · ") %>
|
<% end %>
<% end %>
diff --git a/app/views/browse/query.html.erb b/app/views/features/queries/show.html.erb
similarity index 100%
rename from app/views/browse/query.html.erb
rename to app/views/features/queries/show.html.erb
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 7faf3bebcf..38116f752a 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -398,11 +398,102 @@ en:
telephone_link: "Call %{phone_number}"
colour_preview: "Colour %{colour_value} preview"
email_link: "Email %{email}"
- query:
- title: "Query Features"
- introduction: "Click on the map to find nearby features."
- nearby: "Nearby features"
- enclosing: "Enclosing features"
+ features:
+ keys:
+ show:
+ entries:
+ motorway: "Motorway"
+ main_road: "Main road"
+ trunk: "Trunk road"
+ primary: "Primary road"
+ secondary: "Secondary road"
+ unclassified: "Unclassified road"
+ pedestrian: "Pedestrian way"
+ track: "Track"
+ bridleway: "Bridleway"
+ cycleway: "Cycleway"
+ cycleway_national: "National cycleway"
+ cycleway_regional: "Regional cycleway"
+ cycleway_local: "Local cycleway"
+ cycleway_mtb: "Mountain bike route"
+ footway: "Footway"
+ rail: "Railway"
+ train: "Train"
+ subway: "Subway"
+ ferry: "Ferry"
+ light_rail: "Light rail"
+ tram: "Tram"
+ trolleybus: "Trolleybus"
+ bus: "Bus"
+ cable_car: "Cable car"
+ chair_lift: "Chair lift"
+ runway: "Airport Runway"
+ taxiway: "Taxiway"
+ apron: "Airport apron"
+ admin: "Administrative boundary"
+ capital: "Capital"
+ city: "City"
+ orchard: "Orchard"
+ vineyard: "Vineyard"
+ forest: "Forest"
+ wood: "Wood"
+ farmland: "Farmland"
+ grass: "Grass"
+ meadow: "Meadow"
+ bare_rock: "Bare rock"
+ sand: "Sand"
+ golf: "Golf course"
+ park: "Park"
+ common: "Common"
+ built_up: "Built-up area"
+ resident: "Residential area"
+ retail: "Retail area"
+ industrial: "Industrial area"
+ commercial: "Commercial area"
+ heathland: "Heathland"
+ scrubland: "Scrubland"
+ lake: "Lake"
+ reservoir: "Reservoir"
+ intermittent_water: "Intermittent waterbody"
+ glacier: "Glacier"
+ reef: "Reef"
+ wetland: "Wetland"
+ farm: "Farm"
+ brownfield: "Brownfield site"
+ cemetery: "Cemetery"
+ allotments: "Allotments"
+ pitch: "Sports pitch"
+ centre: "Sports centre"
+ beach: "Beach"
+ reserve: "Nature reserve"
+ military: "Military area"
+ school: "School"
+ university: "University"
+ hospital: "Hospital"
+ building: "Significant building"
+ station: "Railway station"
+ railway_halt: "Railway halt"
+ subway_station: "Subway station"
+ tram_stop: "Tram stop"
+ summit: "Summit"
+ peak: "Peak"
+ tunnel: "Dashed casing = tunnel"
+ bridge: "Black casing = bridge"
+ private: "Private access"
+ destination: "Destination access"
+ construction: "Roads under construction"
+ bus_stop: "Bus stop"
+ bicycle_shop: "Bicycle shop"
+ bicycle_rental: "Bicycle rental"
+ bicycle_parking: "Bicycle parking"
+ bicycle_parking_small: "Small bicycle parking"
+ toilets: "Toilets"
+ queries:
+ show:
+ title: "Query Features"
+ introduction: "Click on the map to find nearby features."
+ nearby: "Nearby features"
+ enclosing: "Enclosing features"
nodes:
timeout:
sorry: "Sorry, the data for the node with the id %{id} took too long to retrieve."
@@ -2334,95 +2425,6 @@ en:
where_am_i_title: Describe the current location using the search engine
submit_text: "Go"
reverse_directions_text: "Reverse Directions"
- key:
- table:
- entry:
- motorway: "Motorway"
- main_road: "Main road"
- trunk: "Trunk road"
- primary: "Primary road"
- secondary: "Secondary road"
- unclassified: "Unclassified road"
- pedestrian: "Pedestrian way"
- track: "Track"
- bridleway: "Bridleway"
- cycleway: "Cycleway"
- cycleway_national: "National cycleway"
- cycleway_regional: "Regional cycleway"
- cycleway_local: "Local cycleway"
- cycleway_mtb: "Mountain bike route"
- footway: "Footway"
- rail: "Railway"
- train: "Train"
- subway: "Subway"
- ferry: "Ferry"
- light_rail: "Light rail"
- tram: "Tram"
- trolleybus: "Trolleybus"
- bus: "Bus"
- cable_car: "Cable car"
- chair_lift: "Chair lift"
- runway: "Airport Runway"
- taxiway: "Taxiway"
- apron: "Airport apron"
- admin: "Administrative boundary"
- capital: "Capital"
- city: "City"
- orchard: "Orchard"
- vineyard: "Vineyard"
- forest: "Forest"
- wood: "Wood"
- farmland: "Farmland"
- grass: "Grass"
- meadow: "Meadow"
- bare_rock: "Bare rock"
- sand: "Sand"
- golf: "Golf course"
- park: "Park"
- common: "Common"
- built_up: "Built-up area"
- resident: "Residential area"
- retail: "Retail area"
- industrial: "Industrial area"
- commercial: "Commercial area"
- heathland: "Heathland"
- scrubland: "Scrubland"
- lake: "Lake"
- reservoir: "Reservoir"
- intermittent_water: "Intermittent waterbody"
- glacier: "Glacier"
- reef: "Reef"
- wetland: "Wetland"
- farm: "Farm"
- brownfield: "Brownfield site"
- cemetery: "Cemetery"
- allotments: "Allotments"
- pitch: "Sports pitch"
- centre: "Sports centre"
- beach: "Beach"
- reserve: "Nature reserve"
- military: "Military area"
- school: "School"
- university: "University"
- hospital: "Hospital"
- building: "Significant building"
- station: "Railway station"
- railway_halt: "Railway halt"
- subway_station: "Subway station"
- tram_stop: "Tram stop"
- summit: "Summit"
- peak: "Peak"
- tunnel: "Dashed casing = tunnel"
- bridge: "Black casing = bridge"
- private: "Private access"
- destination: "Destination access"
- construction: "Roads under construction"
- bus_stop: "Bus stop"
- bicycle_shop: "Bicycle shop"
- bicycle_rental: "Bicycle rental"
- bicycle_parking: "Bicycle parking"
- bicycle_parking_small: "Small bicycle parking"
- toilets: "Toilets"
welcome:
title: Welcome!
introduction: |
diff --git a/config/routes.rb b/config/routes.rb
index 0e00da9e3b..61c8adbf88 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -179,9 +179,11 @@
post "/login" => "sessions#create"
match "/logout" => "sessions#destroy", :via => [:get, :post]
get "/offline" => "site#offline"
- get "/key" => "site#key"
get "/id" => "site#id"
- get "/query" => "browse#query"
+ namespace :features, :path => "" do
+ resource :key, :only => :show
+ resource :query, :only => :show
+ end
get "/user/new" => "users#new"
post "/user/new" => "users#create"
get "/user/terms" => "users#terms"
diff --git a/test/controllers/browse_controller_test.rb b/test/controllers/browse_controller_test.rb
deleted file mode 100644
index 1844dcc6cc..0000000000
--- a/test/controllers/browse_controller_test.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-require "test_helper"
-
-class BrowseControllerTest < ActionDispatch::IntegrationTest
- ##
- # test all routes which lead to this controller
- def test_routes
- assert_routing(
- { :path => "/query", :method => :get },
- { :controller => "browse", :action => "query" }
- )
- end
-
- def test_query
- get query_path
- assert_response :success
- assert_template "browse/query"
- end
-end
diff --git a/test/controllers/features/keys_controller_test.rb b/test/controllers/features/keys_controller_test.rb
new file mode 100644
index 0000000000..6d30f1329e
--- /dev/null
+++ b/test/controllers/features/keys_controller_test.rb
@@ -0,0 +1,22 @@
+require "test_helper"
+
+module Features
+ class KeysControllerTest < ActionDispatch::IntegrationTest
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/key", :method => :get },
+ { :controller => "features/keys", :action => "show" }
+ )
+ end
+
+ def test_show
+ get features_key_path, :xhr => true
+
+ assert_response :success
+ assert_template "features/keys/show"
+ assert_template :layout => false
+ end
+ end
+end
diff --git a/test/controllers/features/queries_controller_test.rb b/test/controllers/features/queries_controller_test.rb
new file mode 100644
index 0000000000..1e8f8da194
--- /dev/null
+++ b/test/controllers/features/queries_controller_test.rb
@@ -0,0 +1,21 @@
+require "test_helper"
+
+module Features
+ class QueriesControllerTest < ActionDispatch::IntegrationTest
+ ##
+ # test all routes which lead to this controller
+ def test_routes
+ assert_routing(
+ { :path => "/query", :method => :get },
+ { :controller => "features/queries", :action => "show" }
+ )
+ end
+
+ def test_show
+ get features_query_path
+
+ assert_response :success
+ assert_template "features/queries/show"
+ end
+ end
+end
diff --git a/test/controllers/site_controller_test.rb b/test/controllers/site_controller_test.rb
index 5bd8df18d2..37ab5b7a11 100644
--- a/test/controllers/site_controller_test.rb
+++ b/test/controllers/site_controller_test.rb
@@ -60,10 +60,6 @@ def test_routes
{ :path => "/offline", :method => :get },
{ :controller => "site", :action => "offline" }
)
- assert_routing(
- { :path => "/key", :method => :get },
- { :controller => "site", :action => "key" }
- )
assert_routing(
{ :path => "/go/shortcode", :method => :get },
{ :controller => "site", :action => "permalink", :code => "shortcode" }
@@ -143,15 +139,6 @@ def test_permalink
assert_redirected_to changeset_path(4, :anchor => "map=3/4.8779296875/3.955078125")
end
- # Test the key page
- def test_key
- get key_path, :xhr => true
-
- assert_response :success
- assert_template "key"
- assert_template :layout => false
- end
-
# Test the edit page redirects when you aren't logged in
def test_edit
get edit_path