mirror of
https://github.com/moparisthebest/mailcatcher
synced 2024-12-22 07:18:53 -05:00
new display format: plain text with clickable URLs
This commit is contained in:
parent
fb13a62589
commit
ef09b0fde3
@ -49,6 +49,7 @@ class MailCatcher::Web < Sinatra::Base
|
||||
"source",
|
||||
("html" if MailCatcher::Mail.message_has_html? id),
|
||||
("plain" if MailCatcher::Mail.message_has_plain? id),
|
||||
("lessplain" if MailCatcher::Mail.message_has_plain? id),
|
||||
].compact,
|
||||
"attachments" => MailCatcher::Mail.message_attachments(id).map do |attachment|
|
||||
attachment.merge({"href" => "/messages/#{escape(id)}/parts/#{escape(attachment['cid'])}"})
|
||||
@ -88,6 +89,19 @@ class MailCatcher::Web < Sinatra::Base
|
||||
end
|
||||
end
|
||||
|
||||
get "/messages/:id.lessplain" do
|
||||
id = params[:id].to_i
|
||||
if part = MailCatcher::Mail.message_part_plain(id)
|
||||
content_type "text/html", :charset => (part["charset"] || "utf8")
|
||||
body = part["body"]
|
||||
body.gsub!(/((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?)/, '<a href="\\1">\\1</a>')
|
||||
body.gsub!("\n", "<br/>\n")
|
||||
"<html><body>" + body + "</body></html>"
|
||||
else
|
||||
not_found
|
||||
end
|
||||
end
|
||||
|
||||
get "/messages/:id.source" do
|
||||
id = params[:id].to_i
|
||||
if message = MailCatcher::Mail.message(id)
|
||||
|
@ -53,6 +53,8 @@
|
||||
%a{:href => '#'} HTML
|
||||
%li.format.tab.plain{'data-message-format' => 'plain'}
|
||||
%a{:href => '#'}Plain Text
|
||||
%li.format.tab.plain{'data-message-format' => 'lessplain'}
|
||||
%a{:href => '#'}Less Plain Text
|
||||
%li.format.tab.source{'data-message-format' => 'source'}
|
||||
%a{:href => '#'}Source
|
||||
%li.tab.analysis
|
||||
|
Loading…
Reference in New Issue
Block a user