Improved html templates.

This commit is contained in:
Martin Edenhofer 2015-01-04 22:28:58 +01:00
parent b531b74bf7
commit c3b35f406c
2 changed files with 73 additions and 48 deletions

View file

@ -209,42 +209,55 @@ class Observer::Ticket::Notification::BackgroundJob
def template_create(user, ticket, article, ticket_changes) def template_create(user, ticket, article, ticket_changes)
article_content = '' article_content = ''
if article if article
article_content = '<snip> article_content = '&lt;snip&gt;
#{article.body} <blockquote>
</snip>' #{article.body.text2html}
</blockquote>
&lt;/snip&gt;
<br>'
end end
if user.preferences[:locale] =~ /^de/i if user.preferences[:locale] =~ /^de/i
subject = 'Neues Ticket (#{ticket.title})' subject = 'Neues Ticket (#{ticket.title})'
body = 'Hallo #{recipient.firstname}, body = '<div>Hallo #{recipient.firstname.text2html},</div>
<br>
es wurde ein neues Ticket (#{ticket.title}) von "#{ticket.updated_by.fullname}" erstellt. <div>
es wurde ein neues Ticket (#{ticket.title.text2html}) von "<b>#{ticket.updated_by.fullname.text2html}</b>" erstellt.
Gruppe: #{ticket.group.name} </div>
Besitzer: #{ticket.owner.fullname} <br>
Status: i18n(#{ticket.state.name}) <div>
i18n(Group): #{ticket.group.name.text2html}<br>
i18n(Owner): #{ticket.owner.fullname.text2html}<br>
i18n(State): i18n(#{ticket.state.name.text2html})<br>
</div>
<br>
<div>
' + article_content + ' ' + article_content + '
</div>
' '
else else
subject = 'New Ticket (#{ticket.title})' subject = 'New Ticket (#{ticket.title})'
body = 'Hi #{recipient.firstname}, body = '<div>Hi #{recipient.firstname.text2html},</div>
<br>
a new Ticket (#{ticket.title}) has been created by "#{ticket.updated_by.fullname}". <div>
a new Ticket (#{ticket.title.text2html}) has been created by "<b>#{ticket.updated_by.fullname.text2html}</b>".
Group: #{ticket.group.name} </div>
Owner: #{ticket.owner.fullname} <br>
State: i18n(#{ticket.state.name}) <div>
Group: #{ticket.group.name.text2html}<br>
Owner: #{ticket.owner.fullname.text2html}<br>
State: i18n(#{ticket.state.name.text2html})<br>
</div>
<br>
<div>
' + article_content + ' ' + article_content + '
</div>
' '
end end
body = template_header(user) + body.chomp.text2html body = template_header(user) + body
body += template_footer(user, ticket, article) body += template_footer(user, ticket, article)
template = { template = {
@ -257,41 +270,54 @@ State: i18n(#{ticket.state.name})
def template_update(user, ticket, article, ticket_changes) def template_update(user, ticket, article, ticket_changes)
changes = '' changes = ''
ticket_changes.each {|key,value| ticket_changes.each {|key,value|
changes += "i18n(#{key}): #{value[0]} -> #{value[1]}\n" changes += "i18n(#{key.to_s.text2html}): #{value[0].to_s.text2html} -> #{value[1].to_s.text2html}<br>\n"
} }
article_content = '' article_content = ''
if article if article
article_content = '<snip> article_content = '&lt;snip&gt;
#{article.body} <blockquote type="cite">
</snip>' #{article.body.text2html}
</blockquote>
&lt;/snip&gt;
<br>'
end end
if user.preferences[:locale] =~ /^de/i if user.preferences[:locale] =~ /^de/i
subject = 'Ticket aktualisiert (#{ticket.title})' subject = 'Ticket aktualisiert (#{ticket.title.text2html})'
body = 'Hallo #{recipient.firstname}, body = '<div>Hallo #{recipient.firstname.text2html},</div>
<br>
Ticket (#{ticket.title}) wurde von "#{ticket.updated_by.fullname}" aktualisiert. <div>
Ticket (#{ticket.title.text2html}) wurde von "<b>#{ticket.updated_by.fullname.text2html}</b>" aktualisiert.
Änderungen: </div>
<br>
<div>
Änderungen:<br>
' + changes + ' ' + changes + '
</div>
<br>
<div>
' + article_content + ' ' + article_content + '
</div>
' '
else else
subject = 'Updated Ticket (#{ticket.title})' subject = 'Updated Ticket (#{ticket.title.text2html})'
body = 'Hi #{recipient.firstname}, body = '<div>Hi #{recipient.firstname.text2html},</div>
<br>
Ticket (#{ticket.title}) has been updated by "#{ticket.updated_by.fullname}". <div>
Ticket (#{ticket.title.text2html}) has been updated by "<b>#{ticket.updated_by.fullname.text2html}</b>".
Changes: </div>
<br>
<div>
Changes:<br>
' + changes + ' ' + changes + '
</div>
<br>
<div>
' + article_content + ' ' + article_content + '
</div>
' '
end end
body = template_header(user) + body.chomp.text2html body = template_header(user) + body
body += template_footer(user,ticket, article) body += template_footer(user,ticket, article)
template = { template = {
@ -363,8 +389,9 @@ Changes:
def template_footer(user, ticket, article) def template_footer(user, ticket, article)
' '
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">i18n(View the Ticket directly here)</a> <p>
<a href="#{config.http_type}://#{config.fqdn}/#ticket/zoom/#{ticket.id}">i18n(View this directly here)</a>
</p>
<div class="footer"> <div class="footer">
<a href="#{config.http_type}://#{config.fqdn}/#profile/notifications">i18n(Manage your notifications settings)</a> <a href="#{config.http_type}://#{config.fqdn}/#profile/notifications">i18n(Manage your notifications settings)</a>
</div> </div>

View file

@ -65,9 +65,7 @@ module NotificationFactory
# add body quote # add body quote
if object_name == 'article' && method == 'body' if object_name == 'article' && method == 'body'
if data[:objects][:article].content_type == 'text/html' if data[:objects][:article].content_type == 'text/html'
object_refs = object_refs.html2text.message_quote.chomp object_refs = object_refs.html2text.chomp
else
object_refs = object_refs.word_wrap( :line_width => 82 ).message_quote.chomp
end end
end end
} }