From: Tom Hughes Date: Wed, 8 Jul 2020 18:09:55 +0000 (+0100) Subject: Merge remote-tracking branch 'upstream/pull/2696' X-Git-Tag: live~3062 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/efa2c20bff4d68cfdaf5fc532ba5eb0711e7cd2d?hp=1977e66ace0751b8b4fdf3b55bde367ec33e7c57 Merge remote-tracking branch 'upstream/pull/2696' --- diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index e72b4e85b..d91b7a2e7 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -17,7 +17,7 @@ class Ability can [:index, :feed], Changeset can :index, ChangesetComment can [:index, :rss, :show, :comments], DiaryEntry - can [:mine], Note + can [:index], Note can [:index, :show], Redaction can [:index, :show, :data, :georss, :picture, :icon], Trace can [:terms, :login, :logout, :new, :create, :save, :confirm, :confirm_resend, :confirm_email, :lost_password, :reset_password, :show, :auth_success, :auth_failure], User diff --git a/app/assets/javascripts/embed.js.erb b/app/assets/javascripts/embed.js.erb index ceb488f98..858b31302 100644 --- a/app/assets/javascripts/embed.js.erb +++ b/app/assets/javascripts/embed.js.erb @@ -35,6 +35,8 @@ window.onload = function () { new L.OSM.CycleMap(thunderforestOptions).addTo(map); } else if (args.layer === "transportmap") { new L.OSM.TransportMap(thunderforestOptions).addTo(map); + } else if (args.layer === "opnvkarte") { + new L.OSM.OPNVKarte().addTo(map); } else if (args.layer === "hot") { new L.OSM.HOT().addTo(map); } diff --git a/app/assets/javascripts/leaflet.map.js b/app/assets/javascripts/leaflet.map.js index a139b6dcd..497062e44 100644 --- a/app/assets/javascripts/leaflet.map.js +++ b/app/assets/javascripts/leaflet.map.js @@ -19,6 +19,7 @@ L.OSM.Map = L.Map.extend({ var donate = I18n.t("javascripts.map.donate_link_text", { donate_url: "https://donate.openstreetmap.org" }); var terms = I18n.t("javascripts.map.terms", { terms_url: "https://wiki.osmfoundation.org/wiki/Terms_of_Use" }); var thunderforest = I18n.t("javascripts.map.thunderforest", { thunderforest_url: "https://www.thunderforest.com/" }); + var memomaps = I18n.t("javascripts.map.opnvkarte", { memomaps_url: "https://memomaps.de/" }); var hotosm = I18n.t("javascripts.map.hotosm", { hotosm_url: "https://www.hotosm.org/", osmfrance_url: "https://openstreetmap.fr/" }); this.baseLayers = []; @@ -48,6 +49,13 @@ L.OSM.Map = L.Map.extend({ })); } + this.baseLayers.push(new L.OSM.OPNVKarte ({ + attribution: copyright + ". " + memomaps + ". " + terms, + code: "O", + keyid: "opnvkarte", + name: I18n.t("javascripts.map.base.opnvkarte") + })); + this.baseLayers.push(new L.OSM.HOT({ attribution: copyright + ". " + hotosm + ". " + terms, code: "H", diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 2f7c959c0..260504ac3 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -30,11 +30,6 @@ small, aside { #container { position: relative; } -.column-1 { - width: 50%; - margin: 0 0 $lineheight/2 0; -} - .small_icon { vertical-align: middle; margin-right: $lineheight/4; @@ -1275,12 +1270,15 @@ tr.turn:hover { /* Rules for small maps in content areas */ .content_map { - position: relative; - width: 45%; - height: 400px; + height: 200px; border: 1px solid $grey; margin-bottom: $lineheight; - float: right; +} + +@include media-breakpoint-up(md) { + .content_map { + height: 400px; + } } /* Rules for the new trace form */ @@ -1333,16 +1331,6 @@ tr.turn:hover { margin-right: $lineheight; } -.activity-block { - clear: left; - border-bottom: 1px solid $grey; - padding-bottom: $lineheight; - float: left; - h3 { - margin-bottom: $lineheight/2; - } -} - .contact-activity { margin-top: $lineheight; width: 100%; @@ -1571,11 +1559,6 @@ tr.turn:hover { display: inline !important; } -.content_map.settings_map { - width: 50%; - float: none; -} - /* Rules for the oauth settings page */ .oauth_clients .buttons .oauth-edit { diff --git a/app/assets/stylesheets/small.scss b/app/assets/stylesheets/small.scss index ed3eb3064..4b741baae 100644 --- a/app/assets/stylesheets/small.scss +++ b/app/assets/stylesheets/small.scss @@ -9,10 +9,6 @@ body.small { -webkit-appearance: none; } - .column-1 { - width: 100%; - } - #menu-icon { display: inline-block !important; } @@ -105,15 +101,6 @@ body.small { top: 10px !important; } - .content_map { - width: 100%; - border: none; - float: none; - height: 200px; - max-height: none; - min-height: auto; - } - /* Rules for the login form */ #login_login input#user_email { diff --git a/app/controllers/api/changesets_controller.rb b/app/controllers/api/changesets_controller.rb index 316015228..a5a37b485 100644 --- a/app/controllers/api/changesets_controller.rb +++ b/app/controllers/api/changesets_controller.rb @@ -2,7 +2,6 @@ module Api class ChangesetsController < ApiController - layout "site" require "xml/libxml" before_action :authorize, :only => [:create, :update, :upload, :close, :subscribe, :unsubscribe] diff --git a/app/controllers/api/notes_controller.rb b/app/controllers/api/notes_controller.rb index a73240e5f..cd71b4374 100644 --- a/app/controllers/api/notes_controller.rb +++ b/app/controllers/api/notes_controller.rb @@ -1,7 +1,5 @@ module Api class NotesController < ApiController - layout "site", :only => [:mine] - before_action :check_api_readable before_action :setup_user_auth, :only => [:create, :comment, :show] before_action :authorize, :only => [:close, :reopen, :destroy, :comment] diff --git a/app/controllers/api/traces_controller.rb b/app/controllers/api/traces_controller.rb index 0b441bef9..6c77f9dc4 100644 --- a/app/controllers/api/traces_controller.rb +++ b/app/controllers/api/traces_controller.rb @@ -1,7 +1,5 @@ module Api class TracesController < ApiController - layout "site", :except => :georss - before_action :authorize_web before_action :set_locale before_action :authorize diff --git a/app/controllers/api/users_controller.rb b/app/controllers/api/users_controller.rb index d3387bd5f..d97e8774e 100644 --- a/app/controllers/api/users_controller.rb +++ b/app/controllers/api/users_controller.rb @@ -1,7 +1,5 @@ module Api class UsersController < ApiController - layout "site", :except => [:api_details] - before_action :disable_terms_redirect, :only => [:details] before_action :authorize, :only => [:details, :gpx_files] diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index 7c6b033ca..9f2fdb7e2 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -1,5 +1,5 @@ class NotesController < ApplicationController - layout "site", :only => [:mine] + layout "site" before_action :check_api_readable before_action :authorize_web @@ -11,11 +11,11 @@ class NotesController < ApplicationController ## # Display a list of notes by a specified user - def mine + def index if params[:display_name] if @user = User.active.find_by(:display_name => params[:display_name]) @params = params.permit(:display_name) - @title = t "notes.mine.title", :user => @user.display_name + @title = t ".title", :user => @user.display_name @page = (params[:page] || 1).to_i @page_size = 10 @notes = @user.notes diff --git a/app/views/notes/mine.html.erb b/app/views/notes/index.html.erb similarity index 85% rename from app/views/notes/mine.html.erb rename to app/views/notes/index.html.erb index 2f68ba5c6..50059625d 100644 --- a/app/views/notes/mine.html.erb +++ b/app/views/notes/index.html.erb @@ -1,6 +1,6 @@ <% content_for :heading do %> -

<%= t "notes.mine.heading", :user => @user.display_name %>

-

<%= t "notes.mine.subheading_html", :user => link_to(@user.display_name, user_path(@user)) %>

+

<%= t ".heading", :user => @user.display_name %>

+

<%= t ".subheading_html", :user => link_to(@user.display_name, user_path(@user)) %>

<% end %> <%= render :partial => "notes_paging_nav" %> diff --git a/app/views/users/account.html.erb b/app/views/users/account.html.erb index 0f2f3741f..ad6614c76 100644 --- a/app/views/users/account.html.erb +++ b/app/views/users/account.html.erb @@ -166,7 +166,7 @@ checked="checked" <% end %> id="updatehome" /> - <%= tag.div "", :id => "map", :class => "content_map settings_map set_location" %> + <%= tag.div "", :id => "map", :class => "content_map set_location" %> <%= submit_tag t(".save changes button") %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 1bd5f8fa5..440d68874 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -11,7 +11,7 @@ <%= number_with_delimiter(current_user.changesets.size) %>
  • - <%= link_to t(".my notes"), :controller => "notes", :action => "mine" %> + <%= link_to t(".my notes"), user_notes_path(@user) %>
  • <%= link_to t(".my traces"), :controller => "traces", :action => "mine" %> @@ -53,7 +53,7 @@ <%= number_with_delimiter(@user.changesets.size) %>
  • - <%= link_to t(".notes"), :controller => "notes", :action => "mine" %> + <%= link_to t(".notes"), user_notes_path(@user) %>
  • <%= link_to t(".traces"), :controller => "traces", :action => "index", :display_name => @user.display_name %> @@ -180,56 +180,60 @@ <% end %> +
    <% if current_user and @user.id == current_user.id %> - <% if @user.home_lat.nil? or @user.home_lon.nil? %> -
    -

    <%= t(".if_set_location_html", :settings_link => (link_to t(".settings_link_text"), :controller => "users", :action => "account", :display_name => current_user.display_name)) %>

    -
    - <% else %> - <% content_for :head do %> - <%= javascript_include_tag "user" %> +
    + <% if @user.home_lat.nil? or @user.home_lon.nil? %> +
    +

    <%= t(".if_set_location_html", :settings_link => (link_to t(".settings_link_text"), :controller => "users", :action => "account", :display_name => current_user.display_name)) %>

    +
    + <% else %> + <% content_for :head do %> + <%= javascript_include_tag "user" %> + <% end %> + <% user_data = { + :lon => current_user.home_lon, + :lat => current_user.home_lat, + :icon => image_path("marker-red.png"), + :description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" }) + } %> + <%= tag.div "", :id => "map", :class => "content_map", :data => { :user => user_data } %> <% end %> - <% user_data = { - :lon => current_user.home_lon, - :lat => current_user.home_lat, - :icon => image_path("marker-red.png"), - :description => render(:partial => "popup", :object => current_user, :locals => { :type => "your location" }) - } %> - <%= tag.div "", :id => "map", :class => "content_map", :data => { :user => user_data } %> - <% end %> - - <% friends = @user.friends %> - <% nearby = @user.nearby - friends %> - -
    -

    <%= t ".my friends" %>

    - - <% if friends.empty? %> - <%= t ".no friends" %> - <% else %> -
      -
    • <%= link_to t(".friends_changesets"), friend_changesets_path %>
    • -
    • <%= link_to t(".friends_diaries"), friends_diary_entries_path %>
    • -
    -
    - <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %> -
    - <% end %> -
    -
    -

    <%= t ".nearby users" %>

    - - <% if nearby.empty? %> - <%= t ".no nearby users" %> - <% else %> -
      -
    • <%= link_to t(".nearby_changesets"), nearby_changesets_path %>
    • -
    • <%= link_to t(".nearby_diaries"), nearby_diary_entries_path %>
    • -
    -
    - <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %> -
    - <% end %> -
    -<% end %> + <% friends = @user.friends %> + <% nearby = @user.nearby - friends %> +
    + +
    +

    <%= t ".my friends" %>

    + + <% if friends.empty? %> + <%= t ".no friends" %> + <% else %> +
      +
    • <%= link_to t(".friends_changesets"), friend_changesets_path %>
    • +
    • <%= link_to t(".friends_diaries"), friends_diary_entries_path %>
    • +
    +
    + <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %> +
    + <% end %> + +
    + +

    <%= t ".nearby users" %>

    + + <% if nearby.empty? %> + <%= t ".no nearby users" %> + <% else %> +
      +
    • <%= link_to t(".nearby_changesets"), nearby_changesets_path %>
    • +
    • <%= link_to t(".nearby_diaries"), nearby_diary_entries_path %>
    • +
    +
    + <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %> +
    + <% end %> +
    + <% end %> +
    diff --git a/config/initializers/secure_headers.rb b/config/initializers/secure_headers.rb index 78e9fee37..daf66bfc7 100644 --- a/config/initializers/secure_headers.rb +++ b/config/initializers/secure_headers.rb @@ -7,7 +7,7 @@ csp_policy = { :form_action => %w['self'], :frame_ancestors => %w['self'], :frame_src => %w['self'], - :img_src => %w['self' data: www.gravatar.com *.wp.com tile.openstreetmap.org *.tile.openstreetmap.org *.tile.thunderforest.com *.openstreetmap.fr], + :img_src => %w['self' data: www.gravatar.com *.wp.com tile.openstreetmap.org *.tile.openstreetmap.org *.tile.thunderforest.com tileserver.memomaps.de *.openstreetmap.fr], :manifest_src => %w['self'], :media_src => %w['none'], :object_src => %w['self'], diff --git a/config/locales/en.yml b/config/locales/en.yml index 2f2145b24..9142c2eda 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2448,7 +2448,7 @@ en: next: "Next »" previous: "« Previous" notes: - mine: + index: title: "Notes submitted or commented on by %{user}" heading: "%{user}'s notes" subheading_html: "Notes submitted or commented on by %{user}" @@ -2502,6 +2502,7 @@ en: cycle_map: Cycle Map transport_map: Transport Map hot: Humanitarian + opnvkarte: ÖPNVKarte layers: header: Map Layers notes: Map Notes @@ -2513,6 +2514,7 @@ en: donate_link_text: "" terms: "Website and API terms" thunderforest: "Tiles courtesy of Andy Allan" + opnvkarte: "Tiles courtesy of MeMoMaps" hotosm: "Tiles style by Humanitarian OpenStreetMap Team hosted by OpenStreetMap France" site: edit_tooltip: Edit the map diff --git a/config/routes.rb b/config/routes.rb index a98a11430..41dc7cfc5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -117,7 +117,7 @@ OpenStreetMap::Application.routes.draw do get "/note/new" => "browse#new_note" get "/user/:display_name/history" => "changesets#index" get "/user/:display_name/history/feed" => "changesets#feed", :defaults => { :format => :atom } - get "/user/:display_name/notes" => "notes#mine", :as => :my_notes + get "/user/:display_name/notes" => "notes#index", :as => :user_notes get "/history/friends" => "changesets#index", :friends => true, :as => "friend_changesets", :defaults => { :format => :html } get "/history/nearby" => "changesets#index", :nearby => true, :as => "nearby_changesets", :defaults => { :format => :html } diff --git a/test/abilities/abilities_test.rb b/test/abilities/abilities_test.rb index 99154b4b7..c27f75833 100644 --- a/test/abilities/abilities_test.rb +++ b/test/abilities/abilities_test.rb @@ -29,7 +29,7 @@ class GuestAbilityTest < AbilityTest test "note permissions for a guest" do ability = Ability.new nil - [:mine].each do |action| + [:index].each do |action| assert ability.can?(action, Note), "should be able to #{action} Notes" end end diff --git a/test/controllers/notes_controller_test.rb b/test/controllers/notes_controller_test.rb index 6eda7d3a3..1450aced8 100644 --- a/test/controllers/notes_controller_test.rb +++ b/test/controllers/notes_controller_test.rb @@ -13,11 +13,11 @@ class NotesControllerTest < ActionDispatch::IntegrationTest def test_routes assert_routing( { :path => "/user/username/notes", :method => :get }, - { :controller => "notes", :action => "mine", :display_name => "username" } + { :controller => "notes", :action => "index", :display_name => "username" } ) end - def test_mine_success + def test_index_success first_user = create(:user) second_user = create(:user) moderator_user = create(:moderator_user) @@ -33,43 +33,43 @@ class NotesControllerTest < ActionDispatch::IntegrationTest end # Note that the table rows include a header row - get my_notes_path(:display_name => first_user.display_name) + get user_notes_path(:display_name => first_user.display_name) assert_response :success assert_select "table.note_list tr", :count => 2 - get my_notes_path(:display_name => second_user.display_name) + get user_notes_path(:display_name => second_user.display_name) assert_response :success assert_select "table.note_list tr", :count => 2 - get my_notes_path(:display_name => "non-existent") + get user_notes_path(:display_name => "non-existent") assert_response :not_found session_for(moderator_user) - get my_notes_path(:display_name => first_user.display_name) + get user_notes_path(:display_name => first_user.display_name) assert_response :success assert_select "table.note_list tr", :count => 2 - get my_notes_path(:display_name => second_user.display_name) + get user_notes_path(:display_name => second_user.display_name) assert_response :success assert_select "table.note_list tr", :count => 3 - get my_notes_path(:display_name => "non-existent") + get user_notes_path(:display_name => "non-existent") assert_response :not_found end - def test_mine_paged + def test_index_paged user = create(:user) create_list(:note, 50) do |note| create(:note_comment, :note => note, :author => user) end - get my_notes_path(:display_name => user.display_name) + get user_notes_path(:display_name => user.display_name) assert_response :success assert_select "table.note_list tr", :count => 11 - get my_notes_path(:display_name => user.display_name, :page => 2) + get user_notes_path(:display_name => user.display_name, :page => 2) assert_response :success assert_select "table.note_list tr", :count => 11 end diff --git a/vendor/assets/leaflet/leaflet.osm.js b/vendor/assets/leaflet/leaflet.osm.js index 0bde8f8a1..ad712e3a2 100644 --- a/vendor/assets/leaflet/leaflet.osm.js +++ b/vendor/assets/leaflet/leaflet.osm.js @@ -35,6 +35,14 @@ L.OSM.TransportMap = L.OSM.TileLayer.extend({ } }); +L.OSM.OPNVKarte = L.OSM.TileLayer.extend({ + options: { + url: 'https://tileserver.memomaps.de/tilegen/{z}/{x}/{y}.png', + maxZoom: 18, + attribution: '© OpenStreetMap contributors. Tiles courtesy of MeMoMaps' + } +}); + L.OSM.HOT = L.OSM.TileLayer.extend({ options: { url: 'https://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png',