diff options
author | Johannes Löthberg <johannes@kyriasis.com> | 2016-11-06 03:05:02 +0100 |
---|---|---|
committer | Johannes Löthberg <johannes@kyriasis.com> | 2017-06-01 18:37:35 +0200 |
commit | f9018f8a6eef1179e640f8acaab97b521ab14d89 (patch) | |
tree | 5ff16bd647a5a194d2e3a1829aaad8660f06c7c9 /mutt/tiny.pl | |
parent | 482260abcdb7806c1fd68bd70100efa1c60dd303 (diff) | |
download | dotfiles-f9018f8a6eef1179e640f8acaab97b521ab14d89.tar.xz |
Switch to neomutt
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Diffstat (limited to 'mutt/tiny.pl')
-rwxr-xr-x | mutt/tiny.pl | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/mutt/tiny.pl b/mutt/tiny.pl deleted file mode 100755 index 06b51b7..0000000 --- a/mutt/tiny.pl +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/perl -################################### -# By: Ventz Petkov # -# Date: 01-05-11 # -# Last: 01-02-13 # -# Parses HTML + Long URLs in MUTT # -################################### - -use URI::Escape; -$file = $ARGV[0]; -@text = (); - -# Only shorten URLs at least this length or more -$tinyurltrigger = 40; - -# If we pass a 2nd argument, it means we want to force HTML check a 'text/plain' file -if(defined($ARGV[2])) { open(FP, $file); for(<FP>) { push(@text, $_); } close(FP); } -# Otherwise, treat as HTML first -else { @text = `elinks -dump -dump-charset $ARGV[1] -default-mime-type text/html $file`; } - - -# Note: using while (instead of for) b/c for supposedly loads -# everything into memory - no reason to load large emails into memory - -while (my $line = shift @text) { - next if($line =~ /mailto:/); - if($line =~ /(\w+:\/\/\S+)/) { - my $link = $1; - chomp($link); - $size = length($link); - if($size >= $tinyurltrigger) { - eval { - my $alarm = 5; - alarm $alarm; - my $link = uri_escape($link); - $tinyurl=`wget -q -O - http://tinyurl.com/api-create.php?url=$link`; - alarm 0; - }; - - if ($@) { - $line =~ s/(\w+:\/\/\S+)/$link (wget TimeOut)/; } - else { $line =~ s/(\w+:\/\/\S+)/$tinyurl\n\t[>> $link <<]/; } - } - } - print "$line"; -} - - -exit 0; |