diff options
Diffstat (limited to 'decisions/makemails')
-rwxr-xr-x | decisions/makemails | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/decisions/makemails b/decisions/makemails index e269768..6ad4d07 100755 --- a/decisions/makemails +++ b/decisions/makemails @@ -17,6 +17,11 @@ use Data::Dumper; # * second line message subject # maintained by this script, can be deleted any time but needs a.g.o # access for recreation +# - mlt: cache of message dates; format: one message per two lines +# * first line "hash:listname" +# * second line message date +# maintained by this script, can be deleted any time but needs a.g.o +# access for recreation # - mld: output file, LaTeX fragment that can be sourced @@ -26,7 +31,7 @@ sub getdata { open (my $web, '-|:encoding(UTF-8)', "wget -O - https://archives.gentoo.org/$list/message/$hash"); - my $line, $from, $subject; + my $line, $from, $subject, $date; until ($line=~/From:/) { $line=<$web>; chomp $line; @@ -47,7 +52,16 @@ sub getdata { $subject=~s/^.*<td><strong>//; $subject=~s/<\/strong><\/td>.*$//; - return ($from, $subject); + until ($line=~/>Date:</) { + $line=<$web>; chomp $line; + } + + $date=<$web>; + chomp $date; + $date=~s/^.*<td>//; + $date=~s/<\/td>.*$//; + + return ($from, $subject, $date); }; @@ -79,6 +93,15 @@ chomp @mlslist; my %messagesubject=@mlslist; +# Read the cache of message times; this file can be deleted, but recreating or +# updating it requires internet access. +open my $mlt, '<', "decisions.mlt"; +my @mltlist = <$mlt>; +close $mlt; +chomp @mltlist; + +my %messagedate=@mltlist; + # Loop through the referenced messages, check if we already have the data, # and if not fetch and add it. @@ -90,13 +113,16 @@ foreach(@messages) { if ($messagesubject{$msg}) { print " Sender is \"$messagefrom{$msg}\"\n"; print " Subject is \"$messagesubject{$msg}\"\n"; + print " Date is \"$messagedate{$msg}\"\n"; } else { print " Data not yet available, fetching it\n"; - my ($from, $subject) = getdata($msglist, $msghash); + my ($from, $subject, $date) = getdata($msglist, $msghash); $messagefrom{$msg}=$from; $messagesubject{$msg}=$subject; + $messagedate{$msg}=$date; print " Sender is \"$messagefrom{$msg}\"\n"; print " Subject is \"$messagesubject{$msg}\"\n"; + print " Date is \"$messagedate{$msg}\"\n"; }; }; @@ -112,6 +138,12 @@ open my $mls, '>', "decisions.mls"; print $mls "$_\n" for @mlslistnew; close $mls; +# Write out the date cache again. +my @mltlistnew= map { $_ => $messagedate{$_} } sort keys %messagedate; +open my $mlt, '>', "decisions.mlt"; +print $mlt "$_\n" for @mltlistnew; +close $mlt; + # Write out the TeX input file open my $mld, '>', "decisions.mld"; @@ -119,7 +151,7 @@ print $mld '\renewcommand{\gentoomailfrom}[1]{%'."\n"; foreach(@messages) { my $msg=$_; my ($msghash, $msglist) = split /:/,$msg,2; - + my $from=$messagefrom{$msg}; print $mld '\ifthenelse{\equal{#1}{'.$msghash.'}}{{'.$from.'}}{}%'."\n"; }; @@ -129,10 +161,20 @@ print $mld '\renewcommand{\gentoomailsubject}[1]{%'."\n"; foreach(@messages) { my $msg=$_; my ($msghash, $msglist) = split /:/,$msg,2; - + my $subject=latex_encode($messagesubject{$msg}); print $mld '\ifthenelse{\equal{#1}{'.$msghash.'}}{{'.$subject.'}}{}%'."\n"; }; print $mld '}'."\n"; +print $mld '\renewcommand{\gentoomaildate}[1]{%'."\n"; +foreach(@messages) { + my $msg=$_; + my ($msghash, $msglist) = split /:/,$msg,2; + + my $date=latex_encode($messagedate{$msg}); + print $mld '\ifthenelse{\equal{#1}{'.$msghash.'}}{{'.$date.'}}{}%'."\n"; +}; +print $mld '}'."\n"; + close $mld; |