]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/2696'
authorTom Hughes <tom@compton.nu>
Wed, 8 Jul 2020 18:09:55 +0000 (19:09 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 8 Jul 2020 18:09:55 +0000 (19:09 +0100)
19 files changed:
app/abilities/ability.rb
app/assets/javascripts/embed.js.erb
app/assets/javascripts/leaflet.map.js
app/assets/stylesheets/common.scss
app/assets/stylesheets/small.scss
app/controllers/api/changesets_controller.rb
app/controllers/api/notes_controller.rb
app/controllers/api/traces_controller.rb
app/controllers/api/users_controller.rb
app/controllers/notes_controller.rb
app/views/notes/index.html.erb [moved from app/views/notes/mine.html.erb with 85% similarity]
app/views/users/account.html.erb
app/views/users/show.html.erb
config/initializers/secure_headers.rb
config/locales/en.yml
config/routes.rb
test/abilities/abilities_test.rb
test/controllers/notes_controller_test.rb
vendor/assets/leaflet/leaflet.osm.js

index e72b4e85b64d55e6787cca9604c2dca29e0e3c78..d91b7a2e738015a163671fb1674107fc27c84152 100644 (file)
@@ -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
index ceb488f987681871e05c87476e5a464de126c79d..858b3130284a0857e8d48d5f37ff7cb1f14a7f2c 100644 (file)
@@ -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);
   }
index a139b6dcd7080ab40045611dc9ab0ea8779f411c..497062e440167ae3f9478e26cdf6f39952c5c2e9 100644 (file)
@@ -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",
index 2f7c959c0fbc90c76ce32769988427a148631aab..260504ac3314ebfda02d7384a153d3ad063cf3c8 100644 (file)
@@ -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 {
index ed3eb306477bdc0eb0627e44fc460d685417f7b1..4b741baaed981cb65afe892ce39b866145fe1146 100644 (file)
@@ -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 {
index 31601522877dce62e24ee81bbd91a385eededa8a..a5a37b485868f8e986053cd723b17e0b671f5710 100644 (file)
@@ -2,7 +2,6 @@
 
 module Api
   class ChangesetsController < ApiController
-    layout "site"
     require "xml/libxml"
 
     before_action :authorize, :only => [:create, :update, :upload, :close, :subscribe, :unsubscribe]
index a73240e5fabc4f849780cbcb9e2dd42a26c30352..cd71b437457e302f2e33c13d6faf90f9761c5e6f 100644 (file)
@@ -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]
index 0b441bef986d9aa5ba4bfd1625001a6144b7115f..6c77f9dc4bae539cb581a60402e372f49dc80d7d 100644 (file)
@@ -1,7 +1,5 @@
 module Api
   class TracesController < ApiController
-    layout "site", :except => :georss
-
     before_action :authorize_web
     before_action :set_locale
     before_action :authorize
index d3387bd5ffaaa1f48a0e32dff1b32d25ae3eb639..d97e8774ecd7a5641f8cc94e301c9fef0ad3386d 100644 (file)
@@ -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]
 
index 7c6b033ca5adf6c6a8a10215d9ca94a49b89f80a..9f2fdb7e224c84233580ec6c146ac2bb5af19da9 100644 (file)
@@ -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
similarity index 85%
rename from app/views/notes/mine.html.erb
rename to app/views/notes/index.html.erb
index 2f68ba5c61359cb89591030d033543b821cfefc7..50059625d3b687e5980ac200224b05a7de48888b 100644 (file)
@@ -1,6 +1,6 @@
 <% content_for :heading do %>
-  <h2><%= t "notes.mine.heading", :user => @user.display_name %></h2>
-  <p><%= t "notes.mine.subheading_html", :user => link_to(@user.display_name, user_path(@user)) %></p>
+  <h2><%= t ".heading", :user => @user.display_name %></h2>
+  <p><%= t ".subheading_html", :user => link_to(@user.display_name, user_path(@user)) %></p>
 <% end %>
 
 <%= render :partial => "notes_paging_nav" %>
index 0f2f3741fafafe874b136506fc669985c1c76e55..ad6614c76ca51a5f02a1c85330310f70d8b419b1 100644 (file)
       <input type="checkbox" name="updatehome" value="1" <% unless current_user.home_lat and current_user.home_lon %> checked="checked" <% end %> id="updatehome" />
       <label class="standard-label" for="updatehome"><%= t ".update home location on click" %></label>
     </div>
-    <%= tag.div "", :id => "map", :class => "content_map settings_map set_location" %>
+    <%= tag.div "", :id => "map", :class => "content_map set_location" %>
   </fieldset>
 
   <%= submit_tag t(".save changes button") %>
index 1bd5f8fa5ba531c50225568472ed27a901f80b2b..440d68874ff9e323b38e63f3f8a9f86086f2d5b7 100644 (file)
@@ -11,7 +11,7 @@
             <span class='count-number'><%= number_with_delimiter(current_user.changesets.size) %></span>
           </li>
           <li>
-            <%= link_to t(".my notes"), :controller => "notes", :action => "mine" %>
+            <%= link_to t(".my notes"), user_notes_path(@user) %>
           </li>
           <li>
             <%= link_to t(".my traces"), :controller => "traces", :action => "mine" %>
@@ -53,7 +53,7 @@
             <span class='count-number'><%= number_with_delimiter(@user.changesets.size) %></span>
           </li>
           <li>
-            <%= link_to t(".notes"), :controller => "notes", :action => "mine" %>
+            <%= link_to t(".notes"), user_notes_path(@user) %>
           </li>
           <li>
             <%= link_to t(".traces"), :controller => "traces", :action => "index", :display_name => @user.display_name %>
 
 <% end %>
 
+<div class="row">
   <% if current_user and @user.id == current_user.id %>
-    <% if @user.home_lat.nil? or @user.home_lon.nil? %>
-      <div id="map" class="content_map">
-        <p id="no_home_location"><%= t(".if_set_location_html", :settings_link => (link_to t(".settings_link_text"), :controller => "users", :action => "account", :display_name => current_user.display_name)) %></p>
-      </div>
-    <% else %>
-      <% content_for :head do %>
-        <%= javascript_include_tag "user" %>
+    <div class="col-md order-md-last">
+      <% if @user.home_lat.nil? or @user.home_lon.nil? %>
+        <div id="map" class="content_map">
+          <p id="no_home_location"><%= t(".if_set_location_html", :settings_link => (link_to t(".settings_link_text"), :controller => "users", :action => "account", :display_name => current_user.display_name)) %></p>
+        </div>
+      <% 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 %>
-
-  <div class="activity-block column-1">
-    <h3><%= t ".my friends" %></h3>
-
-    <% if friends.empty? %>
-      <%= t ".no friends" %>
-    <% else %>
-      <ul class='secondary-actions clearfix'>
-        <li><%= link_to t(".friends_changesets"), friend_changesets_path %></li>
-        <li><%= link_to t(".friends_diaries"), friends_diary_entries_path %></li>
-      </ul>
-      <div id="friends-container">
-        <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
-      </div>
-    <% end %>
-  </div>
 
-  <div class="activity-block column-1">
-    <h3><%= t ".nearby users" %></h3>
-
-    <% if nearby.empty? %>
-      <%= t ".no nearby users" %>
-    <% else %>
-      <ul class='secondary-actions clearfix'>
-        <li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
-        <li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
-      </ul>
-      <div id="nearbyusers">
-        <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
-      </div>
-    <% end %>
-  </div>
-<% end %>
+      <% friends = @user.friends %>
+      <% nearby = @user.nearby - friends %>
+    </div>
+
+    <div class="col-md">
+      <h3><%= t ".my friends" %></h3>
+
+      <% if friends.empty? %>
+        <%= t ".no friends" %>
+      <% else %>
+        <ul class='secondary-actions clearfix'>
+          <li><%= link_to t(".friends_changesets"), friend_changesets_path %></li>
+          <li><%= link_to t(".friends_diaries"), friends_diary_entries_path %></li>
+        </ul>
+        <div id="friends-container">
+          <%= render :partial => "contact", :collection => friends, :locals => { :type => "friend" } %>
+        </div>
+      <% end %>
+
+      <hr>
+
+      <h3><%= t ".nearby users" %></h3>
+
+      <% if nearby.empty? %>
+        <%= t ".no nearby users" %>
+      <% else %>
+        <ul class='secondary-actions clearfix'>
+          <li><%= link_to t(".nearby_changesets"), nearby_changesets_path %></li>
+          <li><%= link_to t(".nearby_diaries"), nearby_diary_entries_path %></li>
+        </ul>
+        <div id="nearbyusers">
+          <%= render :partial => "contact", :collection => nearby, :locals => { :type => "nearby mapper" } %>
+        </div>
+      <% end %>
+    </div>
+  <% end %>
+</div>
index 78e9fee371f74ec480073aeed2bc146a7f134965..daf66bfc75eba53a48db397dbd656c9084256bcd 100644 (file)
@@ -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'],
index 2f2145b244653259fb9b3ef8c953465576747da4..9142c2eda3dcce0a8f66bd7d517c2b0230d1d0c3 100644 (file)
@@ -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: "<a class='donate-attr' href='%{donate_url}'>Make a Donation</a>"
       terms: "<a href='%{terms_url}' target='_blank'>Website and API terms</a>"
       thunderforest: "Tiles courtesy of <a href='%{thunderforest_url}' target='_blank'>Andy Allan</a>"
+      opnvkarte: "Tiles courtesy of <a href='%{memomaps_url}' target='_blank'>MeMoMaps</a>"
       hotosm: "Tiles style by <a href='%{hotosm_url}' target='_blank'>Humanitarian OpenStreetMap Team</a> hosted by <a href='%{osmfrance_url}' target='_blank'>OpenStreetMap France</a>"
     site:
       edit_tooltip: Edit the map
index a98a114302d0576d33fecc637056107d647af49b..41dc7cfc536cddf041d114a0babb448d2732ad2b 100644 (file)
@@ -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 }
 
index 99154b4b72cfaeb79ef35019ed4bdb0293f6c174..c27f758333d7d5818f2e6d1b52011369472707fb 100644 (file)
@@ -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
index 6eda7d3a310cfbcf1197a0696eb4e335dcf67743..1450aced88275bec8b6e02c90199d81ba7469a43 100644 (file)
@@ -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
index 0bde8f8a1b889fa2c1d24b1d45019daa45d74030..ad712e3a2f78bb07b13da28ff7f639541683333a 100644 (file)
@@ -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: '© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors. Tiles courtesy of <a href="http://memomaps.de/" target="_blank">MeMoMaps</a>'
+  }
+});
+
 L.OSM.HOT = L.OSM.TileLayer.extend({
   options: {
     url: 'https://tile-{s}.openstreetmap.fr/hot/{z}/{x}/{y}.png',