From: Herve Saint-Amand Date: Tue, 3 Jan 2017 22:38:58 +0000 (+0000) Subject: Remove HTML markup from locale file X-Git-Tag: live~4213^2~27 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/ac081305f24453b576d826f0b85a851e0e8506e2?ds=sidebyside Remove HTML markup from locale file Rather than including HTML markup in the locale file (which also has the inconvenience of requiring both a plain-text and an HTML duplicate of the same string), move the markup to the template. Also added a helper to reduce clutter in the template slightly. --- diff --git a/app/helpers/notifier_helper.rb b/app/helpers/notifier_helper.rb index 4b2cd2a06..62801ed82 100644 --- a/app/helpers/notifier_helper.rb +++ b/app/helpers/notifier_helper.rb @@ -2,4 +2,13 @@ module NotifierHelper def fp(text) format_paragraph(text, 72, 0) end + + def link_to_user(display_name) + link_to( + display_name, + user_url(display_name, :host => SERVER_URL), + :target => "_blank", + :style => "text-decoration: none; color: #222; font-weight: bold" + ) + end end diff --git a/app/models/notifier.rb b/app/models/notifier.rb index d01ef07d1..60b682693 100644 --- a/app/models/notifier.rb +++ b/app/models/notifier.rb @@ -159,7 +159,6 @@ class Notifier < ActionMailer::Base @comment = comment.body @owner = recipient == comment.changeset.user @commenter = comment.author.display_name - @commenter_url = user_url(comment.author.display_name, :host => SERVER_URL) @changeset_comment = comment.changeset.tags["comment"].presence @time = comment.created_at @changeset_author = comment.changeset.user.display_name diff --git a/app/views/notifier/changeset_comment_notification.html.erb b/app/views/notifier/changeset_comment_notification.html.erb index 67deff5e0..6bb1b6811 100644 --- a/app/views/notifier/changeset_comment_notification.html.erb +++ b/app/views/notifier/changeset_comment_notification.html.erb @@ -27,12 +27,12 @@

<% if @owner %> - <%= t "notifier.changeset_comment_notification.commented.your_changeset_html", :commenter => @commenter, :commenter_url => @commenter_url, :time => @time %> + <%= raw t "notifier.changeset_comment_notification.commented.your_changeset", :commenter => link_to_user(@commenter), :time => @time %> <% else %> - <%= t "notifier.changeset_comment_notification.commented.commented_changeset_html", :commenter => @commenter, :commenter_url => @commenter_url, :time => @time, :changeset_author => @changeset_author %> + <%= raw t "notifier.changeset_comment_notification.commented.commented_changeset", :commenter => link_to_user(@commenter), :time => @time, :changeset_author => @changeset_author %> <% end %> <% if @changeset_comment %> - <%= t "notifier.changeset_comment_notification.commented.partial_changeset_with_comment_html", :changeset_comment => @changeset_comment %> + <%= raw t "notifier.changeset_comment_notification.commented.partial_changeset_with_comment", :changeset_comment => content_tag("em", @changeset_comment) %> <% else %> <%= t "notifier.changeset_comment_notification.commented.partial_changeset_without_comment" %> <% end %> @@ -48,7 +48,7 @@

- <%= raw t 'notifier.changeset_comment_notification.details_html', :url => link_to(@changeset_url, @changeset_url) %> + <%= raw t 'notifier.changeset_comment_notification.details', :url => content_tag("nobr", link_to(@changeset_url, @changeset_url)) %>

@@ -61,7 +61,7 @@

- <%= t 'notifier.changeset_comment_notification.unsubscribe_html', :url => @changeset_url %> + <%= raw t 'notifier.changeset_comment_notification.unsubscribe', :url => content_tag("nobr", link_to(@changeset_url, @changeset_url, :style => "color: #222")) %>

OpenStreetMap diff --git a/config/locales/en.yml b/config/locales/en.yml index 7a255cd4b..ab50a681a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1315,23 +1315,11 @@ en: subject_own: "[OpenStreetMap] %{commenter} has commented on one of your changesets" subject_other: "[OpenStreetMap] %{commenter} has commented on a changeset you are interested in" your_changeset: "%{commenter} has left a comment on one of your changesets created at %{time}" - your_changeset_html: '%{commenter} - has left a comment on one of your changesets - created at %{time}' commented_changeset: "%{commenter} has left a comment on a map changeset you are watching created by %{changeset_author} at %{time}" - commented_changeset_html: '%{commenter} - has left a comment on a map changeset you are watching created by - %{changeset_author} - at %{time}' partial_changeset_with_comment: "with comment '%{changeset_comment}'" - partial_changeset_with_comment_html: 'with comment %{changeset_comment}' partial_changeset_without_comment: "without comment" details: "More details about the changeset can be found at %{url}." - details_html: 'More details about the changeset can be found at - %{url}.' - unsubscribe_html: 'To unsubscribe from updates to this changeset, - visit %{url} - and click "Unsubscribe".' + unsubscribe: 'To unsubscribe from updates to this changeset, visit %{url} and click "Unsubscribe".' message: inbox: title: "Inbox"