Browse files

Move html_syslog_format method, show received timezone, escape parts …

…of HTML format
  • Loading branch information...
1 parent 7553cf9 commit ebf45b9dec89d99f9ad355dcf9db95702a54889e @troy troy committed Mar 28, 2012
Showing with 13 additions and 12 deletions.
  1. +0 −8 lib/papertrail_services/helpers/logs_helpers.rb
  2. +13 −4 services/mail.rb
View
8 lib/papertrail_services/helpers/logs_helpers.rb
@@ -27,14 +27,6 @@ def syslog_format(message)
"#{Time.zone.parse(message[:received_at]).strftime('%b %d %X')} #{message[:source_name]} #{message[:program]}: #{message[:message]}"
end
- def html_syslog_format(message, html_search_url)
- received_at = Time.parse(message[:received_at])
- url = html_search_url + '?' + { :time => received_at.to_i }.to_query
-
- s = "<a href=\"#{url}\">#{received_at.strftime('%b %d %X')}"
- s << " #{message[:source_name]} #{message[:program]}: #{message[:message]}"
- end
-
def erb(template, target_binding)
ERB.new(template, nil, '-').result(target_binding)
end
View
17 services/mail.rb
@@ -35,6 +35,14 @@ def mail_message
end
end
+ def html_syslog_format(message, html_search_url)
+ received_at = Time.parse(message[:received_at])
+ url = html_search_url + '?' + { :time => received_at.to_i }.to_query
+
+ s = "<a href=\"#{url}\">#{received_at.strftime('%b %d %X')}"
+ s << " #{h(message[:source_name])} #{h(message[:program])}: #{h(message[:message])}"
+ end
+
def html_email
erb(unindent(<<-EOF), binding)
<html>
@@ -56,7 +64,7 @@ def html_email
<%- if !payload[:events].empty? -%>
<%- payload[:events].each do |event| -%>
<p style="line-height:1.5em;margin:0;padding:2px 0;border-bottom:1px solid #f1f1f1;">
- <%=h html_syslog_format(event, payload[:saved_search][:html_search_url]) %>
+ <%= html_syslog_format(event, payload[:saved_search][:html_search_url]) %>
</p>
<%- end -%>
<%- else -%>
@@ -66,9 +74,10 @@ def html_email
<h4>About "<%= h payload[:saved_search][:name] %>":</h4>
<ul>
- <li>Query: <%= h payload[:saved_search][:query] %></li>
+ <li>Query: <%= h payload[:saved_search][:query] %></li>
+ <li>Time zone: <%= h Time.zone %></li>
<li>Run search: <a href="<%= payload[:saved_search][:html_search_url] %>"><%= payload[:name] %></a></li>
- <li><a href="<%= payload[:saved_search][:html_edit_url] %>">Edit or unsubscribe</a></li>
+ <li><a href="<%= payload[:saved_search][:html_edit_url] %>">Edit or unsubscribe</a></li>
</ul>
<div style="color:#444;font-size:12px;line-height:130%;border-top:1px solid #ddd;margin-top:35px;">
@@ -101,8 +110,8 @@ def text_email
About "<%= payload[:saved_search][:name] %>":
Query: <%= payload[:saved_search][:query] %>
+ Time zone: <%= Time.zone %>
Search: <%= payload[:saved_search][:html_search_url] %>
- Time: US Pacific
Edit or unsubscribe: <%= payload[:saved_search][:html_edit_url] %>

0 comments on commit ebf45b9

Please sign in to comment.