From c47f777df3b722ca23fc67dd472a1439daa74b9c Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sat, 6 Jul 2002 20:16:38 +0000 Subject: Build html files for [rm]list[12] Have templates for html files --- Echolot/Config.pm | 11 +++- Echolot/Stats.pm | 125 ++++++++++++++++++++++++++---------------- Echolot/Thesaurus.pm | 27 +++++++-- README | 3 +- TODO | 2 - pingd.conf | 1 + templates/mlist.html | 33 +++++++++++ templates/mlist2.html | 33 +++++++++++ templates/rlist.html | 33 +++++++++++ templates/rlist2.html | 33 +++++++++++ templates/thesaurusindex.html | 37 +++++++++++++ 11 files changed, 280 insertions(+), 58 deletions(-) create mode 100644 templates/mlist.html create mode 100644 templates/mlist2.html create mode 100644 templates/rlist.html create mode 100644 templates/rlist2.html create mode 100644 templates/thesaurusindex.html diff --git a/Echolot/Config.pm b/Echolot/Config.pm index 6bf37d5..f764ffe 100644 --- a/Echolot/Config.pm +++ b/Echolot/Config.pm @@ -1,7 +1,7 @@ package Echolot::Config; # (c) 2002 Peter Palfrader -# $Id: Config.pm,v 1.13 2002/07/06 01:31:39 weasel Exp $ +# $Id: Config.pm,v 1.14 2002/07/06 20:15:12 weasel Exp $ # =pod @@ -76,10 +76,19 @@ sub init($) { 'cpunk-clear' => 1, 'mix' => 1 }, + + templates => { + 'thesaurusindexfile' => 'templates/thesaurusindex.html', + 'mlist' => 'templates/mlist.html', + 'mlist2' => 'templates/mlist2.html', + 'rlist2' => 'templates/rlist2.html', + 'rlist' => 'templates/rlist.html', + }, homedir => undef, my_localpart => undef, my_domain => undef, + sitename => undef, verbose => 0 }; diff --git a/Echolot/Stats.pm b/Echolot/Stats.pm index 9e17050..96776a4 100644 --- a/Echolot/Stats.pm +++ b/Echolot/Stats.pm @@ -1,7 +1,7 @@ package Echolot::Stats; # (c) 2002 Peter Palfrader -# $Id: Stats.pm,v 1.11 2002/07/06 01:31:39 weasel Exp $ +# $Id: Stats.pm,v 1.12 2002/07/06 20:15:12 weasel Exp $ # =pod @@ -24,6 +24,7 @@ use Carp qw{cluck}; use constant DAYS => 12; use constant SECS_PER_DAY => 24 * 60 * 60; use English; +use HTML::Template; use Statistics::Distrib::Normal qw{}; @@ -256,52 +257,75 @@ sub calculate($$) { }; }; - - -sub build_mlist1($$) { - my ($rems, $filebasename) = @_; +sub write_file($$;$) { + my ($filebasename, $html_template, $output) = @_; my $filename = $filebasename.'.txt'; open(F, '>'.$filename) or cluck("Cannot open $filename: $!\n"), return 0; - printf F "Last update: %s\n", makeDate(); - printf F "mixmaster history latency uptime\n"; - printf F "--------------------------------------------\n"; + print F $output; + close (F); + + return 1 unless defined $html_template; + + my $template = HTML::Template->new( + filename => $html_template, + global_vars => 1 ); + $template->param ( list => $output ); + $template->param ( CURRENT_TIMESTAMP => scalar gmtime() ); + $template->param ( SITE_NAME => Echolot::Config::get()->{'sitename'} ); + + $filename = $filebasename.'.html'; + open(F, '>'.$filename) or + cluck("Cannot open $filename: $!\n"), + return 0; + print F $template->output(); + close (F); + + return 1; +}; + +sub build_mlist1($$;$) { + my ($rems, $filebasename, $html_template) = @_; + + my $output = ''; + $output .= sprintf "Last update: %s\n", makeDate(); + $output .= sprintf "mixmaster history latency uptime\n"; + $output .= sprintf "--------------------------------------------\n"; for my $remailer (@$rems) { - printf F "%-14s %-12s %8s %6.2f%%\n", + $output .= sprintf "%-14s %-12s %8s %6.2f%%\n", $remailer->{'nick'}, build_list1_latencystr($remailer->{'stats'}->{'latency_day'}), makeMinHr($remailer->{'stats'}->{'avr_latency'}, 1), $remailer->{'stats'}->{'avr_reliability'} * 100; }; - close (F); + + write_file($filebasename, $html_template, $output) or + cluck("writefile failed"), + return 0; + return 1; }; -sub build_rlist1($$) { - my ($rems, $filebasename) = @_; +sub build_rlist1($$;$) { + my ($rems, $filebasename, $html_template) = @_; - my $filename = $filebasename.'.txt'; - open(F, '>'.$filename) or - cluck("Cannot open $filename: $!\n"), - return 0; - - + my $output = ''; for my $remailer (sort {$a->{'caps'} cmp $b->{'caps'}} @$rems) { - print F $remailer->{'caps'},"\n" + $output .= $remailer->{'caps'}."\n" } - #printf F "Groups of remailers sharing a machine or operator:\n\n"; - #printf F "Broken type-I remailer chains:\n\n"; - #printf F "Broken type-II remailer chains:\n\n"; + #$output .= sprintf "Groups of remailers sharing a machine or operator:\n\n"; + #$output .= sprintf "Broken type-I remailer chains:\n\n"; + #$output .= sprintf "Broken type-II remailer chains:\n\n"; - printf F "Last update: %s\n", makeDate(); - printf F "remailer email address history latency uptime\n"; - printf F "-----------------------------------------------------------------------\n"; + $output .= sprintf "Last update: %s\n", makeDate(); + $output .= sprintf "remailer email address history latency uptime\n"; + $output .= sprintf "-----------------------------------------------------------------------\n"; for my $remailer (@$rems) { - printf F "%-11s %-28s %-12s %8s %6.2f%%\n", + $output .= sprintf "%-11s %-28s %-12s %8s %6.2f%%\n", $remailer->{'nick'}, $remailer->{'address'}, build_list1_latencystr($remailer->{'stats'}->{'latency_day'}), @@ -309,24 +333,26 @@ sub build_rlist1($$) { $remailer->{'stats'}->{'avr_reliability'} * 100; }; - close (F); + + write_file($filebasename, $html_template, $output) or + cluck("writefile failed"), + return 0; + return 1; }; -sub build_list2($$) { - my ($rems, $filebasename) = @_; +sub build_list2($$;$) { + my ($rems, $filebasename, $html_template) = @_; - my $filename = $filebasename.'.txt'; - open(F, '>'.$filename) or - cluck("Cannot open $filename: $!\n"), - return 0; - printf F "Stats-Version: 2.0\n"; - printf F "Generated: %s\n", makeDate(); - printf F "Mixmaster Latent-Hist Latent Uptime-Hist Uptime Options\n"; - printf F "------------------------------------------------------------------------\n"; + my $output = ''; + + $output .= sprintf "Stats-Version: 2.0\n"; + $output .= sprintf "Generated: %s\n", makeDate(); + $output .= sprintf "Mixmaster Latent-Hist Latent Uptime-Hist Uptime Options\n"; + $output .= sprintf "------------------------------------------------------------------------\n"; for my $remailer (@$rems) { - printf F "%-12s %-12s %6s %-12s %5.1f%% %s\n", + $output .= sprintf "%-12s %-12s %6s %-12s %5.1f%% %s\n", $remailer->{'nick'}, build_list2_latencystr($remailer->{'stats'}->{'latency_day'}), makeMinHr($remailer->{'stats'}->{'avr_latency'}, 0), @@ -335,16 +361,19 @@ sub build_list2($$) { build_list2_capsstr($remailer->{'caps'}); }; - #printf F "Groups of remailers sharing a machine or operator:\n\n"; - #printf F "Broken type-I remailer chains:\n\n"; - #printf F "Broken type-II remailer chains:\n\n"; + #$output .= sprintf "Groups of remailers sharing a machine or operator:\n\n"; + #$output .= sprintf "Broken type-I remailer chains:\n\n"; + #$output .= sprintf "Broken type-II remailer chains:\n\n"; - printf F "\n\n\nRemailer-Capabilities:\n\n"; + $output .= sprintf "\n\n\nRemailer-Capabilities:\n\n"; for my $remailer (sort {$a->{'caps'} cmp $b->{'caps'}} @$rems) { - print F $remailer->{'caps'},"\n" if defined $remailer->{'caps'}; + $output .= $remailer->{'caps'}."\n" if defined $remailer->{'caps'}; } - close (F); + write_file($filebasename, $html_template, $output) or + cluck("writefile failed"), + return 0; + return 1; }; @@ -386,15 +415,15 @@ sub build_lists() { build_mlist1( $rems, Echolot::Config::get()->{'private_resultdir'}.'/'.'mlist'); build_list2( $rems, Echolot::Config::get()->{'private_resultdir'}.'/'.'mlist2'); @$rems = grep { $_->{'showit'} } @$rems; - build_mlist1( $rems, Echolot::Config::get()->{'resultdir'}.'/'.'mlist'); - build_list2( $rems, Echolot::Config::get()->{'resultdir'}.'/'.'mlist2'); + build_mlist1( $rems, Echolot::Config::get()->{'resultdir'}.'/'.'mlist', Echolot::Config::get()->{'templates'}->{'mlist'}); + build_list2( $rems, Echolot::Config::get()->{'resultdir'}.'/'.'mlist2', Echolot::Config::get()->{'templates'}->{'mlist2'}); $rems = build_rems(['cpunk-rsa', 'cpunk-dsa', 'cpunk-clear']); build_rlist1( $rems, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist'); build_list2( $rems, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist2'); @$rems = grep { $_->{'showit'} } @$rems; - build_rlist1( $rems, Echolot::Config::get()->{'resultdir'}.'/'.'rlist'); - build_list2( $rems, Echolot::Config::get()->{'resultdir'}.'/'.'rlist2'); + build_rlist1( $rems, Echolot::Config::get()->{'resultdir'}.'/'.'rlist', Echolot::Config::get()->{'templates'}->{'rlist'}); + build_list2( $rems, Echolot::Config::get()->{'resultdir'}.'/'.'rlist2', Echolot::Config::get()->{'templates'}->{'rlist2'}); }; diff --git a/Echolot/Thesaurus.pm b/Echolot/Thesaurus.pm index f707e04..a150367 100644 --- a/Echolot/Thesaurus.pm +++ b/Echolot/Thesaurus.pm @@ -1,7 +1,7 @@ package Echolot::Thesaurus; # (c) 2002 Peter Palfrader -# $Id: Thesaurus.pm,v 1.2 2002/07/06 14:08:05 weasel Exp $ +# $Id: Thesaurus.pm,v 1.3 2002/07/06 20:15:12 weasel Exp $ # =pod @@ -20,6 +20,7 @@ use strict; use warnings; use Carp qw{cluck}; use English; +use HTML::Template; sub build_thesaurus() { @@ -51,23 +52,37 @@ sub build_thesaurus() { my $time = sprintf("%02d:%02d", $hour, $min); - $data->{$remailer->{'address'}}->{$what} = { - 'href' => $filename, - 'date' => $date, - 'time' => $time, - }; + $data->{$remailer->{'address'}}->{$what.'_href'} = $filename; + $data->{$remailer->{'address'}}->{$what.'_date'} = $date; + $data->{$remailer->{'address'}}->{$what.'_time'} = $time; }; for my $addr (keys (%$data)) { my $nick = Echolot::Globals::get()->{'storage'}->get_nick($addr); $data->{$addr}->{'nick'} = defined $nick ? $nick : 'N/A'; + $data->{$addr}->{'address'} = $addr; }; + my @data = map {$data->{$_}} (sort { $data->{$a}->{'nick'} cmp $data->{$b}->{'nick'} } keys (%$data)); + + my $template = HTML::Template->new( + filename => Echolot::Config::get()->{'templates'}->{'thesaurusindexfile'}, + global_vars => 1 ); + $template->param ( remailers => \@data ); + $template->param ( CURRENT_TIMESTAMP => scalar gmtime() ); + $template->param ( SITE_NAME => Echolot::Config::get()->{'sitename'} ); + + my $file = Echolot::Config::get()->{'thesaurusindexfile'}; open (F, ">$file") or cluck ("Cannot open '$file': $!"), return 0; + print F $template->output(); + close F; + + return; + print F 'Thesaurus

Thesaurus

'."\n"; print F "\n"; diff --git a/README b/README index 15425f9..0b74957 100644 --- a/README +++ b/README @@ -24,6 +24,7 @@ REQUIREMENTS XML::Dumper Digest::MD5 Mail::Internet + HTML::Template for type1 pings GnuPG (1.0.7) GnuPG::Interface (0.33) @@ -46,7 +47,7 @@ o Create a mixmaster client installation in ~pinger/Mix echolot needs to file, the public mixmaster keyring, and type2.list. Don't bother putting current keyrings there. -o Check the homedir setting pingd.conf +o Check the homedir setting and set sitename in pingd.conf. o Set my_localpart and my_domain in pingd.conf to the appropriate values for your pinger. Mail to my_localpart@my_domain needs to reach diff --git a/TODO b/TODO index cd607fb..1258053 100644 --- a/TODO +++ b/TODO @@ -1,8 +1,6 @@ for 2.0: for later: - build html files for *list - make html files template based rotate secret get rid of dependency on mix get rid of dependency on gnupg diff --git a/pingd.conf b/pingd.conf index 7d188e3..c4b021c 100644 --- a/pingd.conf +++ b/pingd.conf @@ -3,6 +3,7 @@ /home/weasel/projects/echolot/devel/echolot + noreply Test pinger marvin.palfrader.org diff --git a/templates/mlist.html b/templates/mlist.html new file mode 100644 index 0000000..fd4c90d --- /dev/null +++ b/templates/mlist.html @@ -0,0 +1,33 @@ + + + Thesaurus [<TMPL_VAR NAME="SITE_NAME">] + + +

Remailer Reliability Stats []

+ +

Mixmaster Remailers

+ +

+This is an automatically generated list of remailer reliability +statistics. + +

+v2 and cpunk v1 and +v2 stats are also available. + +

+Up + +

+

+
+
+ +
+Created by Echolot.
+Last update: . + + + + + diff --git a/templates/mlist2.html b/templates/mlist2.html new file mode 100644 index 0000000..4362096 --- /dev/null +++ b/templates/mlist2.html @@ -0,0 +1,33 @@ + + + Thesaurus [<TMPL_VAR NAME="SITE_NAME">] + + +

Remailer Reliability Stats []

+ +

Mixmaster Remailers (v2)

+ +

+This is an automatically generated list of remailer reliability +statistics. + +

+v1 and cpunk v1 and +v2 stats are also available. + +

+Up + +

+

+
+
+ +
+Created by Echolot.
+Last update: . + + + + + diff --git a/templates/rlist.html b/templates/rlist.html new file mode 100644 index 0000000..1a609cb --- /dev/null +++ b/templates/rlist.html @@ -0,0 +1,33 @@ + + + Thesaurus [<TMPL_VAR NAME="SITE_NAME">] + + +

Remailer Reliability Stats []

+ +

Cypherpunk Remailers

+ +

+This is an automatically generated list of remailer reliability +statistics. + +

+v2 and mixmaster v1 and +v2 stats are also available. + +

+Up + +

+

+
+
+ +
+Created by Echolot.
+Last update: . + + + + + diff --git a/templates/rlist2.html b/templates/rlist2.html new file mode 100644 index 0000000..177b1e3 --- /dev/null +++ b/templates/rlist2.html @@ -0,0 +1,33 @@ + + + Thesaurus [<TMPL_VAR NAME="SITE_NAME">] + + +

Remailer Reliability Stats []

+ +

Cypherpunk Remailers (v2)

+ +

+This is an automatically generated list of remailer reliability +statistics. + +

+v1 and mixmaster v1 and +v2 stats are also available. + +

+Up + +

+

+
+
+ +
+Created by Echolot.
+Last update: . + + + + + diff --git a/templates/thesaurusindex.html b/templates/thesaurusindex.html new file mode 100644 index 0000000..1acc218 --- /dev/null +++ b/templates/thesaurusindex.html @@ -0,0 +1,37 @@ + + + Thesaurus [<TMPL_VAR NAME="SITE_NAME">] + + +

Thesaurus []

+ +

+Up + +

+

nickAddressconfhelpkeystatsadminkey
+ + + + + + + + + + + + + + + +
nickAddressconfhelpkeystatsadminkey
">
N/A
">
N/A
">
N/A
">
N/A
">
N/A
+ +
+Created by Echolot.
+Last update: . + + + + + -- cgit v1.2.3