]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/2983' into master
authorTom Hughes <tom@compton.nu>
Wed, 25 Nov 2020 16:59:23 +0000 (16:59 +0000)
committerTom Hughes <tom@compton.nu>
Wed, 25 Nov 2020 16:59:23 +0000 (16:59 +0000)
Gemfile.lock
app/mailers/user_mailer.rb
app/views/user_mailer/_gpx_description.html.erb
app/views/user_mailer/gpx_failure.html.erb
app/views/user_mailer/gpx_success.html.erb
config/initializers/sanitize.rb
config/locales/en.yml
test/mailers/user_mailer_test.rb

index 2c4860329459ebca97aaf673801f4deeb3784e1b..8b99e6628b0108274abb5141406bf57116fa122d 100644 (file)
@@ -443,7 +443,7 @@ GEM
       actionpack (>= 4.0)
       activesupport (>= 4.0)
       sprockets (>= 3.0.0)
-    strong_migrations (0.7.2)
+    strong_migrations (0.7.3)
       activerecord (>= 5)
     sync (0.5.0)
     term-ansicolor (1.7.1)
index 24444ce1b2d4bb3eecb11284cfba921a1488cba2..ba2ff525d5c077bf77276321af6426ab06b63d81 100644 (file)
@@ -44,6 +44,7 @@ class UserMailer < ApplicationMailer
 
   def gpx_success(trace, possible_points)
     with_recipient_locale trace.user do
+      @to_user = trace.user.display_name
       @trace_name = trace.name
       @trace_points = trace.size
       @trace_description = trace.description
@@ -51,19 +52,20 @@ class UserMailer < ApplicationMailer
       @possible_points = possible_points
 
       mail :to => trace.user.email,
-           :subject => I18n.t("user_mailer.gpx_notification.success.subject")
+           :subject => I18n.t("user_mailer.gpx_success.subject")
     end
   end
 
   def gpx_failure(trace, error)
     with_recipient_locale trace.user do
+      @to_user = trace.user.display_name
       @trace_name = trace.name
       @trace_description = trace.description
       @trace_tags = trace.tags
       @error = error
 
       mail :to => trace.user.email,
-           :subject => I18n.t("user_mailer.gpx_notification.failure.subject")
+           :subject => I18n.t("user_mailer.gpx_failure.subject")
     end
   end
 
index 4fdf929ac4874630d95d1559579714aa8e8e06dc..50fcd69600ff05d966de48f29318df88619113ae 100644 (file)
@@ -1,12 +1,8 @@
-<%= t "user_mailer.gpx_notification.your_gpx_file" %>
-<strong><%= @trace_name %></strong>
-<%= t "user_mailer.gpx_notification.with_description" %>
-<em><%= @trace_description %></em>
-<% if @trace_tags.length>0 %>
-  <%= t "user_mailer.gpx_notification.and_the_tags" %>
-  <em><% @trace_tags.each do |tag| %>
-    <%= tag.tag.rstrip %>
-  <% end %></em>
+<% trace_name = tag.strong(@trace_name) %>
+<% trace_description = tag.em(@trace_description) %>
+<% if @trace_tags.length > 0 %>
+  <% tags = @trace_tags.map(&:tag).join(" ") %>
+  <%= t ".description_with_tags_html", :trace_name => trace_name, :trace_description => trace_description, :tags => tags %>
 <% else %>
-  <%= t "user_mailer.gpx_notification.and_no_tags" %>
+  <%= t ".description_with_no_tags_html", :trace_name => trace_name, :trace_description => trace_description %>
 <% end %>
index a398661a693aea9857ff5c33c9ddf45cd9d57699..d2059af38209904c473ec7310d6a113a59db12de 100644 (file)
@@ -1,8 +1,8 @@
-<p><%= t "user_mailer.gpx_notification.greeting" %></p>
+<p><%= t ".hi", :to_user => @to_user %></p>
 
 <p>
   <%= render :partial => "gpx_description" %>
-  <%= t "user_mailer.gpx_notification.failure.failed_to_import" %>
+  <%= t ".failed_to_import" %>
 </p>
 
 <blockquote>
@@ -10,7 +10,5 @@
 </blockquote>
 
 <p>
-  <%= t "user_mailer.gpx_notification.failure.more_info_1" %>
-  <%= t "user_mailer.gpx_notification.failure.more_info_2" %>
-  <%= t "user_mailer.gpx_notification.failure.import_failures_url" %>
+  <%= t ".more_info_html", :url => link_to(t(".import_failures_url"), t(".import_failures_url")) %>
 </p>
index 78af1166cd0febf70fc709b8566da871f4b8db60..73afa4295fe9b314051fab891505fb7288c7f678 100644 (file)
@@ -1,7 +1,7 @@
-<p><%= t "user_mailer.gpx_notification.greeting" %></p>
+<p><%= t ".hi", :to_user => @to_user %></p>
 
 <p>
   <%= render :partial => "gpx_description" %>
-  <%= t("user_mailer.gpx_notification.success.loaded_successfully",
+  <%= t(".loaded_successfully",
         :trace_points => @trace_points, :possible_points => @possible_points, :count => @possible_points) %>
 </p>
index 30fe37820fb0dac8a1303288806e81805501d998..6f2e30852029f17d0deafa615b4068daf540d9c3 100644 (file)
@@ -3,3 +3,6 @@ Sanitize::Config::OSM = Sanitize::Config::RELAXED.dup
 Sanitize::Config::OSM[:elements] -= %w[div style]
 Sanitize::Config::OSM[:add_attributes] = { "a" => { "rel" => "nofollow noopener noreferrer" } }
 Sanitize::Config::OSM[:remove_contents] = %w[script style]
+Sanitize::Config::OSM[:transformers] = lambda do |env|
+  env[:node].add_class("table table-sm w-auto") if env[:node_name] == "table"
+end
index 37d6f99e9be79e54d6b8f068744df37138a1c7f8..c7613cfd4f2c9692df1fef1718bffb897140f2b8 100644 (file)
@@ -1426,23 +1426,21 @@ en:
       had_added_you: "%{user} has added you as a friend on OpenStreetMap."
       see_their_profile: "You can see their profile at %{userurl}."
       befriend_them: "You can also add them as a friend at %{befriendurl}."
-    gpx_notification:
-      greeting: "Hi,"
-      your_gpx_file: "It looks like your GPX file"
-      with_description: "with the description"
-      and_the_tags: "and the following tags:"
-      and_no_tags: "and no tags."
-      failure:
-        subject: "[OpenStreetMap] GPX Import failure"
-        failed_to_import: "failed to import. Here is the error:"
-        more_info_1: "More information about GPX import failures and how to avoid"
-        more_info_2: "them can be found at:"
-        import_failures_url: "https://wiki.openstreetmap.org/wiki/GPX_Import_Failures"
-      success:
-        subject: "[OpenStreetMap] GPX Import success"
-        loaded_successfully:
-          one: loaded successfully with %{trace_points} out of a possible 1 point.
-          other: loaded successfully with %{trace_points} out of a possible %{possible_points} points.
+    gpx_description:
+      description_with_tags_html: "It looks like your GPX file %{trace_name} with the description %{trace_description} and the following tags: %{tags}"
+      description_with_no_tags_html: "It looks like your GPX file %{trace_name} with the description %{trace_description} and no tags"
+    gpx_failure:
+      hi: "Hi %{to_user},"
+      failed_to_import: "failed to import. Here is the error:"
+      more_info_html: "More information about GPX import failures and how to avoid them can be found at %{url}."
+      import_failures_url: "https://wiki.openstreetmap.org/wiki/GPX_Import_Failures"
+      subject: "[OpenStreetMap] GPX Import failure"
+    gpx_success:
+      hi: "Hi %{to_user},"
+      loaded_successfully:
+        one: loaded successfully with %{trace_points} out of a possible 1 point.
+        other: loaded successfully with %{trace_points} out of a possible %{possible_points} points.
+      subject: "[OpenStreetMap] GPX Import success"
     signup_confirm:
       subject: "[OpenStreetMap] Welcome to OpenStreetMap"
       greeting: "Hi there!"
index 23136951cfa9728d3fff6267a9188485c1c8d886..2a4b5a417a92a834c64d65be825d6fa6ed40b232 100644 (file)
@@ -6,4 +6,15 @@ class UserMailerTest < ActionMailer::TestCase
 
     assert_match(/<html lang=/, email.html_part.body.to_s)
   end
+
+  def test_gpx_description_tags
+    trace = create(:trace) do |t|
+      create(:tracetag, :trace => t, :tag => "one")
+      create(:tracetag, :trace => t, :tag => "two")
+      create(:tracetag, :trace => t, :tag => "three")
+    end
+    email = UserMailer.gpx_success(trace, 100)
+
+    assert_match(/one two three/, email.html_part.body.to_s)
+  end
 end