Skip to content

Commit

Permalink
Merge ac08130 into ea93c03
Browse files Browse the repository at this point in the history
  • Loading branch information
saintamh committed Jan 3, 2017
2 parents ea93c03 + ac08130 commit 6a6b81d
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 20 deletions.
Binary file added app/assets/images/osm_logo_30.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions app/helpers/notifier_helper.rb
Expand Up @@ -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
13 changes: 13 additions & 0 deletions app/models/notifier.rb
Expand Up @@ -154,6 +154,7 @@ def note_comment_notification(comment, recipient)

def changeset_comment_notification(comment, recipient)
with_recipient_locale recipient do
@root_url = root_url(:host => SERVER_URL)
@changeset_url = changeset_url(comment.changeset, :host => SERVER_URL)
@comment = comment.body
@owner = recipient == comment.changeset.user
Expand All @@ -168,12 +169,24 @@ def changeset_comment_notification(comment, recipient)
I18n.t("notifier.changeset_comment_notification.commented.subject_other", :commenter => @commenter)
end

attachments.inline["logo.png"] = File.read("#{Rails.root}/app/assets/images/osm_logo_30.png")
attachments.inline["avatar.png"] = File.read(user_avatar_file_path(comment.author))

mail :to => recipient.email, :subject => subject
end
end

private

def user_avatar_file_path(user)
image = user.image
if image.file?
return image.path(:small)
else
return "#{Rails.root}/app/assets/images/users/images/small.png"
end
end

def with_recipient_locale(recipient)
I18n.with_locale Locale.available.preferred(recipient.preferred_languages) do
yield
Expand Down
93 changes: 73 additions & 20 deletions app/views/notifier/changeset_comment_notification.html.erb
@@ -1,20 +1,73 @@
<p><%= t 'notifier.changeset_comment_notification.greeting' %></p>

<p>
<% if @owner %>
<%= t "notifier.changeset_comment_notification.commented.your_changeset", :commenter => @commenter, :time => @time %>
<% else %>
<%= t "notifier.changeset_comment_notification.commented.commented_changeset", :commenter => @commenter, :time => @time, :changeset_author => @changeset_author %>
<% end %>
<% if @changeset_comment %>
<%= t "notifier.changeset_comment_notification.commented.partial_changeset_with_comment", :changeset_comment => @changeset_comment %>
<% else %>
<%= t "notifier.changeset_comment_notification.commented.partial_changeset_without_comment" %>
<% end %>
</p>

==
<%= @comment.to_html %>
==

<p><%= raw t 'notifier.changeset_comment_notification.details', :url => link_to(@changeset_url, @changeset_url) %></p>
<html>
<head>
<title></title>
<meta charset="UTF-8"></meta>
</head>
<body style="padding: 0; margin: 0; font-size: 14px; font-family: 'Helvetica Neue', Arial, sans-serif; color: #222">
<table style="background-color: #eee; width: 100%">
<tr>
<td style="text-align: center">
<table style="width: 600px; color: #222; margin-left: auto; margin-right: auto">
<tr>
<td style="width: 30px; padding: 10px">
<a href="<%= @root_url %>" target="_blank">
<%= image_tag attachments["logo.png"].url, alt: "OpenStreetMap logo", title: "OpenStreetMap", height: "30", width: "30", border: "0" %>
</a>
</td>
<td style="padding: 10px 0px">
<a href="<%= @root_url %>" target="_blank" style="text-decoration: none; color: #000">
<h1 style="font-size: 18px; font-weight: 600; margin: 0; text-align: left">OpenStreetMap</h1>
</a>
</td>
</tr>
<tr>
<td colspan="2">
<table style="background-color: #fff; color: #222; border: solid 1px #ccc; border-collapse: separate">
<tr>
<td style="text-align: left; padding: 15px 15px 5px 15px">
<p style="margin: 0">
<% if @owner %>
<%= raw t "notifier.changeset_comment_notification.commented.your_changeset", :commenter => link_to_user(@commenter), :time => @time %>
<% else %>
<%= raw t "notifier.changeset_comment_notification.commented.commented_changeset", :commenter => link_to_user(@commenter), :time => @time, :changeset_author => @changeset_author %>
<% end %>
<% if @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 %>
</p>
<table style="font-size: 15px; font-style: italic; margin: 15px; background-color: #eee; width: 520px">
<tr>
<td style="width: 50px; vertical-align: top; padding: 15px">
<a href="<%= @commenter_url %>" target="_blank"><%= image_tag attachments["avatar.png"].url, alt: @commenter %></a>
</td>
<td style="text-align: left; vertical-align: top; padding-right: 10px">
<%= @comment.to_html %>
</td>
</tr>
</table>
<p>
<%= raw t 'notifier.changeset_comment_notification.details', :url => content_tag("nobr", link_to(@changeset_url, @changeset_url)) %>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="text-align: center; font-size: 11px">
<p>
<%= raw t 'notifier.changeset_comment_notification.unsubscribe', :url => content_tag("nobr", link_to(@changeset_url, @changeset_url, :style => "color: #222")) %>
</p>
<p style="margin-bottom: 10px">
<a href="<%= @root_url %>" target="_blank" style="color: #222">OpenStreetMap</a>
</p>
</td>
</tr>
</table>
</body>
</html>
1 change: 1 addition & 0 deletions config/locales/en.yml
Expand Up @@ -1319,6 +1319,7 @@ en:
partial_changeset_with_comment: "with comment '%{changeset_comment}'"
partial_changeset_without_comment: "without comment"
details: "More details about the changeset can be found at %{url}."
unsubscribe: 'To unsubscribe from updates to this changeset, visit %{url} and click "Unsubscribe".'
message:
inbox:
title: "Inbox"
Expand Down

0 comments on commit 6a6b81d

Please sign in to comment.