diff options
author | Peter Palfrader <peter@palfrader.org> | 2002-07-06 20:16:38 +0000 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2002-07-06 20:16:38 +0000 |
commit | c47f777df3b722ca23fc67dd472a1439daa74b9c (patch) | |
tree | b800cb6440fbda75fabe7d6cfbe3a977a550bfe9 | |
parent | 7d86e005ea1b47350d317922289f42341fe5445d (diff) |
Build html files for [rm]list[12]
Have templates for html files
-rw-r--r-- | Echolot/Config.pm | 11 | ||||
-rw-r--r-- | Echolot/Stats.pm | 125 | ||||
-rw-r--r-- | Echolot/Thesaurus.pm | 27 | ||||
-rw-r--r-- | README | 3 | ||||
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | pingd.conf | 1 | ||||
-rw-r--r-- | templates/mlist.html | 33 | ||||
-rw-r--r-- | templates/mlist2.html | 33 | ||||
-rw-r--r-- | templates/rlist.html | 33 | ||||
-rw-r--r-- | templates/rlist2.html | 33 | ||||
-rw-r--r-- | templates/thesaurusindex.html | 37 |
11 files changed, 280 insertions, 58 deletions
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 <peter@palfrader.org> -# $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 <peter@palfrader.org> -# $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 <peter@palfrader.org> -# $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 '<html><head><title>Thesaurus</title></head><body><h1>Thesaurus</h1><table border=1>'."\n"; print F "<tr><tr><th>nick</th><th>Address</th><th>conf</th><th>help</th><th>key</th><th>stats</th><th>adminkey</th></tr>\n"; @@ -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 @@ -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 @@ -3,6 +3,7 @@ <perldata> <hash> <item key="homedir">/home/weasel/projects/echolot/devel/echolot</item> + <item key="sitename">noreply Test</item> <item key="my_localpart">pinger</item> <item key="my_domain">marvin.palfrader.org</item> <item key="Pinger::Mix"> 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 @@ +<html> +<head> + <title>Thesaurus [<TMPL_VAR NAME="SITE_NAME">]</title> +</head> +<body> +<h1>Remailer Reliability Stats [<TMPL_VAR NAME="SITE_NAME">]</h1> + +<h2>Mixmaster Remailers</h2> + +<p> +This is an automatically generated list of remailer reliability +statistics. + +<p> +<a HREF="mlist2.html">v2</a> and cpunk <a HREF="rlist.html">v1</a> and +<a HREF="rlist2.html">v2</a> stats are also available. + +<p> +<a HREF="./">Up</a> + +<p> +<pre> +<TMPL_VAR NAME="list"> +</pre> + +<hr> +Created by <a href="http://savannah.gnu.org/projects/echolot/">Echolot</a>.<br> +Last update: <TMPL_VAR NAME="CURRENT_TIMESTAMP">. +</body> + +<!-- vim:set ts=2: --> +<!-- vim:set shiftwidth=2: --> +</html> 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 @@ +<html> +<head> + <title>Thesaurus [<TMPL_VAR NAME="SITE_NAME">]</title> +</head> +<body> +<h1>Remailer Reliability Stats [<TMPL_VAR NAME="SITE_NAME">]</h1> + +<h2>Mixmaster Remailers (v2)</h2> + +<p> +This is an automatically generated list of remailer reliability +statistics. + +<p> +<a HREF="mlist.html">v1</a> and cpunk <a HREF="rlist.html">v1</a> and +<a HREF="rlist2.html">v2</a> stats are also available. + +<p> +<a HREF="./">Up</a> + +<p> +<pre> +<TMPL_VAR NAME="list"> +</pre> + +<hr> +Created by <a href="http://savannah.gnu.org/projects/echolot/">Echolot</a>.<br> +Last update: <TMPL_VAR NAME="CURRENT_TIMESTAMP">. +</body> + +<!-- vim:set ts=2: --> +<!-- vim:set shiftwidth=2: --> +</html> 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 @@ +<html> +<head> + <title>Thesaurus [<TMPL_VAR NAME="SITE_NAME">]</title> +</head> +<body> +<h1>Remailer Reliability Stats [<TMPL_VAR NAME="SITE_NAME">]</h1> + +<h2>Cypherpunk Remailers</h2> + +<p> +This is an automatically generated list of remailer reliability +statistics. + +<p> +<a HREF="rlist2.html">v2</a> and mixmaster <a HREF="mlist.html">v1</a> and +<a HREF="mlist2.html">v2</a> stats are also available. + +<p> +<a HREF="./">Up</a> + +<p> +<pre> +<TMPL_VAR NAME="list"> +</pre> + +<hr> +Created by <a href="http://savannah.gnu.org/projects/echolot/">Echolot</a>.<br> +Last update: <TMPL_VAR NAME="CURRENT_TIMESTAMP">. +</body> + +<!-- vim:set ts=2: --> +<!-- vim:set shiftwidth=2: --> +</html> 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 @@ +<html> +<head> + <title>Thesaurus [<TMPL_VAR NAME="SITE_NAME">]</title> +</head> +<body> +<h1>Remailer Reliability Stats [<TMPL_VAR NAME="SITE_NAME">]</h1> + +<h2>Cypherpunk Remailers (v2)</h2> + +<p> +This is an automatically generated list of remailer reliability +statistics. + +<p> +<a HREF="rlist.html">v1</a> and mixmaster <a HREF="mlist.html">v1</a> and +<a HREF="mlist2.html">v2</a> stats are also available. + +<p> +<a HREF="./">Up</a> + +<p> +<pre> +<TMPL_VAR NAME="list"> +</pre> + +<hr> +Created by <a href="http://savannah.gnu.org/projects/echolot/">Echolot</a>.<br> +Last update: <TMPL_VAR NAME="CURRENT_TIMESTAMP">. +</body> + +<!-- vim:set ts=2: --> +<!-- vim:set shiftwidth=2: --> +</html> 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 @@ +<html> +<head> + <title>Thesaurus [<TMPL_VAR NAME="SITE_NAME">]</title> +</head> +<body> +<h1>Thesaurus [<TMPL_VAR NAME="SITE_NAME">]</h1> + +<p> +<a href="../">Up</a> + +<p> +<table border=1> + +<tr><tr><th>nick</th><th>Address</th><th>conf</th><th>help</th><th>key</th><th>stats</th><th>adminkey</th></tr> + +<TMPL_LOOP NAME="remailers"> + <tr> + <td><TMPL_VAR NAME="nick"></td> + <td><TMPL_VAR NAME="address"></td> + <td align="center"><TMPL_IF NAME="conf_date"><a href="<TMPL_VAR NAME="conf_href">"><TMPL_VAR NAME="conf_date"><br><TMPL_VAR NAME="conf_time"></a><TMPL_ELSE>N/A</TMPL_IF></td> + <td align="center"><TMPL_IF NAME="help_date"><a href="<TMPL_VAR NAME="help_href">"><TMPL_VAR NAME="help_date"><br><TMPL_VAR NAME="help_time"></a><TMPL_ELSE>N/A</TMPL_IF></td> + <td align="center"><TMPL_IF NAME="key_date"><a href="<TMPL_VAR NAME="key_href">"><TMPL_VAR NAME="key_date"><br><TMPL_VAR NAME="key_time"></a><TMPL_ELSE>N/A</TMPL_IF></td> + <td align="center"><TMPL_IF NAME="stats_date"><a href="<TMPL_VAR NAME="stats_href">"><TMPL_VAR NAME="stats_date"><br><TMPL_VAR NAME="stats_time"></a><TMPL_ELSE>N/A</TMPL_IF></td> + <td align="center"><TMPL_IF NAME="adminkey_date"><a href="<TMPL_VAR NAME="adminkey_href">"><TMPL_VAR NAME="adminkey_date"><br><TMPL_VAR NAME="adminkey_time"></a><TMPL_ELSE>N/A</TMPL_IF></td> + </tr> +</TMPL_LOOP> + +</table> + +<hr> +Created by <a href="http://savannah.gnu.org/projects/echolot/">Echolot</a>.<br> +Last update: <TMPL_VAR NAME="CURRENT_TIMESTAMP">. +</body> + +<!-- vim:set ts=2: --> +<!-- vim:set shiftwidth=2: --> +</html> |