Skip to content

Commit

Permalink
Turn URLs into links in HTML output.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jun 21, 2016
1 parent 82e1084 commit aa53562
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions archive_imessage.pl
Expand Up @@ -10,6 +10,7 @@
use File::Copy;
use MIME::Base64;
use File::Slurp;
use Regexp::Common qw/URI/;

my $VERSION = '0.0.1';

Expand Down Expand Up @@ -293,6 +294,8 @@ sub flush_conversation {
print TMPEMAIL "$output_text";
print TMPEMAIL "\n\n";
} else {
# This <style> section is largely based on:
# https://codepen.io/samuelkraft/pen/Farhl/
print TMPEMAIL <<EOF
--$mimeboundaryalt
Content-Type: text/plain; charset="utf-8"
Expand Down Expand Up @@ -334,6 +337,10 @@ sub flush_conversation {
border-radius: 25px;
float: right;
}
.from-me a {
color: white;
background: #0B93F6;
}
.from-me:before {
content: "";
position: absolute;
Expand Down Expand Up @@ -363,6 +370,10 @@ sub flush_conversation {
.sms:before {
border-right: 20px solid #04D74A;
}
.sms a {
color: white;
background: #04D74A;
}
.from-them {
position: relative;
padding: 10px 20px;
Expand Down Expand Up @@ -943,6 +954,8 @@ sub talk_gap {
$htmltext = "<b>$htmltext</b>";
}

$htmltext =~ s/($RE{URI})/<a href="$1">$1<\/a>/g;

if ($cache_has_attachments) {
$attachmentstmt->execute($msgid) or fail("Couldn't execute attachment lookup SELECT statement: " . $DBI::errstr);
while (my @attachmentrow = $attachmentstmt->fetchrow_array()) {
Expand Down

0 comments on commit aa53562

Please sign in to comment.