From b025be7b869c06a774c09c92170c060bd9e1b179 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Tue, 3 Dec 2002 02:59:13 +0000 Subject: Have support for translated templates Use CSS - they need to be trimmed, I don't like Sergiusz's colors thesaurusindexfile and indexfilebasename config values should not longer have the extension (.html) in them --- Echolot/Config.pm | 36 +++++++++++++------------ Echolot/Stats.pm | 74 ++++++++++++++++++++++++++++++++++------------------ Echolot/Thesaurus.pm | 4 +-- Echolot/Tools.pm | 68 +++++++++++++++++++++++++---------------------- 4 files changed, 108 insertions(+), 74 deletions(-) (limited to 'Echolot') diff --git a/Echolot/Config.pm b/Echolot/Config.pm index dcb48f4..a2cc755 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.42 2002/10/25 10:46:52 weasel Exp $ +# $Id: Config.pm,v 1.43 2002/12/03 02:59:13 weasel Exp $ # =pod @@ -112,9 +112,9 @@ sub init($) { mailerrordir => 'mail-errors', resultdir => 'results', thesaurusdir => 'results/thesaurus', - thesaurusindexfile => 'results/thesaurus/index.html', + thesaurusindexfile => 'results/thesaurus/index', private_resultdir => 'results.private', - indexfilebasename => 'echolot.html', + indexfilebasename => 'echolot', gnupghome => 'gnupghome', gnupg => '', mixhome => 'mixhome', @@ -148,21 +148,25 @@ sub init($) { # templates templates => { - 'indexfile' => 'templates/echolot.html', - 'thesaurusindexfile' => 'templates/thesaurusindex.html', - 'mlist' => 'templates/mlist.html', - 'mlist2' => 'templates/mlist2.html', - 'rlist' => 'templates/rlist.html', - 'rlist-rsa' => 'templates/rlist-rsa.html', - 'rlist-dsa' => 'templates/rlist-dsa.html', - 'rlist-clear' => 'templates/rlist-clear.html', - 'rlist2' => 'templates/rlist2.html', - 'rlist2-rsa' => 'templates/rlist2-rsa.html', - 'rlist2-dsa' => 'templates/rlist2-dsa.html', - 'rlist2-clear' => 'templates/rlist2-clear.html', - 'clist' => 'templates/clist.html', + default => { + 'indexfile' => 'templates/echolot.html', + 'thesaurusindexfile' => 'templates/thesaurusindex.html', + 'mlist' => 'templates/mlist.html', + 'mlist2' => 'templates/mlist2.html', + 'rlist' => 'templates/rlist.html', + 'rlist-rsa' => 'templates/rlist-rsa.html', + 'rlist-dsa' => 'templates/rlist-dsa.html', + 'rlist-clear' => 'templates/rlist-clear.html', + 'rlist2' => 'templates/rlist2.html', + 'rlist2-rsa' => 'templates/rlist2-rsa.html', + 'rlist2-dsa' => 'templates/rlist2-dsa.html', + 'rlist2-clear' => 'templates/rlist2-clear.html', + 'clist' => 'templates/clist.html', + }, }, + 'echolot_css' => 'templates/echolot.css', + remailerxxxtext => "Hello,\n". "\n". "This message requests remailer configuration data. The pinging software thinks\n". diff --git a/Echolot/Stats.pm b/Echolot/Stats.pm index 693aca3..ea682f5 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.34 2002/09/12 15:41:49 weasel Exp $ +# $Id: Stats.pm,v 1.35 2002/12/03 02:59:13 weasel Exp $ # =pod @@ -289,7 +289,7 @@ sub write_file($$$$) { $output =~ s//>/g; }; - Echolot::Tools::write_HTML_file($filebasename.'.html', $html_template, $expires, list => $output); + Echolot::Tools::write_HTML_file($filebasename, $html_template, $expires, list => $output); return 1; }; @@ -489,10 +489,10 @@ sub build_lists() { $rems = build_rems(['mix']); @$pubrems = grep { $_->{'showit'} } @$rems; - build_mlist1( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'mlist'); - build_list2( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'mlist2'); - build_mlist1( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'mlist', Echolot::Config::get()->{'templates'}->{'mlist'}); - build_list2( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'mlist2', Echolot::Config::get()->{'templates'}->{'mlist2'}); + build_mlist1( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'mlist', 'mlist'); + build_list2( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'mlist2', 'mlist2'); + build_mlist1( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'mlist', 'mlist'); + build_list2( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'mlist2', 'mlist2'); $stats{'mix_total'} = scalar @$pubrems; $stats{'mix_98'} = scalar grep { $_->{'stats'}->{'avr_reliability'} >= 0.98 } @$pubrems; $addresses{$_->{'address'}}=1 for @$pubrems; @@ -503,10 +503,10 @@ sub build_lists() { $rems = build_rems(['cpunk-rsa', 'cpunk-dsa', 'cpunk-clear']); @$pubrems = grep { $_->{'showit'} } @$rems; - build_rlist1( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist'); - build_list2( $rems,$broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist2'); - build_rlist1( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist', Echolot::Config::get()->{'templates'}->{'rlist'}); - build_list2( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist2', Echolot::Config::get()->{'templates'}->{'rlist2'}); + build_rlist1( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist', 'rlist'); + build_list2( $rems,$broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist2', 'rlist2'); + build_rlist1( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist', 'rlist'); + build_list2( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist2', 'rlist2'); $stats{'cpunk_total'} = scalar @$pubrems; $stats{'cpunk_98'} = scalar grep { $_->{'stats'}->{'avr_reliability'} >= 0.98 } @$pubrems; $addresses{$_->{'address'}}=1 for @$pubrems; @@ -518,10 +518,10 @@ sub build_lists() { if (Echolot::Config::get()->{'separate_rlists'}) { $rems = build_rems(['cpunk-rsa']); @$pubrems = grep { $_->{'showit'} } @$rems; - build_rlist1( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist-rsa', Echolot::Config::get()->{'templates'}->{'rlist-rsa'}); - build_list2( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist2-rsa', Echolot::Config::get()->{'templates'}->{'rlist2-rsa'}); - build_rlist1( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist-rsa', Echolot::Config::get()->{'templates'}->{'rlist-rsa'}); - build_list2( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist2-rsa', Echolot::Config::get()->{'templates'}->{'rlist2-rsa'}); + build_rlist1( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist-rsa', 'rlist-rsa'); + build_list2( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist2-rsa', 'rlist2-rsa'); + build_rlist1( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist-rsa', 'rlist-rsa'); + build_list2( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist2-rsa', 'rlist2-rsa'); if (Echolot::Config::get()->{'combined_list'}) { $clist->{'cpunk-rsa'} = $rems; $pubclist->{'cpunk-rsa'} = $pubrems; $pubrems = undef; @@ -529,10 +529,10 @@ sub build_lists() { $rems = build_rems(['cpunk-dsa']); @$pubrems = grep { $_->{'showit'} } @$rems; - build_rlist1( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist-dsa', Echolot::Config::get()->{'templates'}->{'rlist-dsa'}); - build_list2( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist2-dsa', Echolot::Config::get()->{'templates'}->{'rlist2-dsa'}); - build_rlist1( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist-dsa', Echolot::Config::get()->{'templates'}->{'rlist-dsa'}); - build_list2( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist2-dsa', Echolot::Config::get()->{'templates'}->{'rlist2-dsa'}); + build_rlist1( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist-dsa', 'rlist-dsa'); + build_list2( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist2-dsa', 'rlist2-dsa'); + build_rlist1( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist-dsa', 'rlist-dsa'); + build_list2( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist2-dsa', 'rlist2-dsa'); if (Echolot::Config::get()->{'combined_list'}) { $clist->{'cpunk-dsa'} = $rems; $pubclist->{'cpunk-dsa'} = $pubrems; $pubrems = undef; @@ -540,26 +540,50 @@ sub build_lists() { $rems = build_rems(['cpunk-clear']); @$pubrems = grep { $_->{'showit'} } @$rems; - build_rlist1( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist-clear', Echolot::Config::get()->{'templates'}->{'rlist-clear'}); - build_list2( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist2-clear', Echolot::Config::get()->{'templates'}->{'rlist2-clear'}); - build_rlist1( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist-clear', Echolot::Config::get()->{'templates'}->{'rlist-clear'}); - build_list2( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist2-clear', Echolot::Config::get()->{'templates'}->{'rlist2-clear'}); + build_rlist1( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist-clear', 'rlist-clear'); + build_list2( $rems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'rlist2-clear', 'rlist2-clear'); + build_rlist1( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist-clear', 'rlist-clear'); + build_list2( $pubrems, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'rlist2-clear', 'rlist2-clear'); if (Echolot::Config::get()->{'combined_list'}) { $clist->{'cpunk-clear'} = $rems; $pubclist->{'cpunk-clear'} = $pubrems; $pubrems = undef; }; }; if (Echolot::Config::get()->{'combined_list'}) { - build_clist( $clist, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'clist', Echolot::Config::get()->{'templates'}->{'clist'}); - build_clist( $pubclist, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'clist', Echolot::Config::get()->{'templates'}->{'clist'}); + build_clist( $clist, $broken1, $broken2, $sameop, Echolot::Config::get()->{'private_resultdir'}.'/'.'clist', 'clist'); + build_clist( $pubclist, $broken1, $broken2, $sameop, Echolot::Config::get()->{'resultdir'}.'/'.'clist', 'clist'); }; $stats{'unique_addresses'} = scalar keys %addresses; Echolot::Tools::write_HTML_file( Echolot::Config::get()->{'resultdir'}.'/'.Echolot::Config::get()->{'indexfilebasename'}, - Echolot::Config::get()->{'templates'}->{'indexfile'}, + 'indexfile', Echolot::Config::get()->{'buildstats'}, %stats ); + + my $file = Echolot::Config::get()->{'echolot_css'}, + my $css; + { + local $/ = undef; + open(F, $file) or + cluck("Could not open $file: $!\n"), + return 0; + $css = ; + close (F) or + cluck("Cannot close $file: $!\n"), + return 0; + } + $file = Echolot::Config::get()->{'resultdir'}.'/echolot.css'; + open(F, '>'.$file) or + cluck("Cannot open $file: $!\n"), + return 0; + print F $css or + cluck("Cannot print to $file: $!\n"), + return 0; + close (F) or + cluck("Cannot close $file: $!\n"), + return 0; + }; diff --git a/Echolot/Thesaurus.pm b/Echolot/Thesaurus.pm index 887429e..b32dd80 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.12 2002/09/05 15:41:38 weasel Exp $ +# $Id: Thesaurus.pm,v 1.13 2002/12/03 02:59:13 weasel Exp $ # =pod @@ -103,7 +103,7 @@ sub build_thesaurus() { Echolot::Tools::write_HTML_file( Echolot::Config::get()->{'thesaurusindexfile'}, - Echolot::Config::get()->{'templates'}->{'thesaurusindexfile'}, + 'thesaurusindexfile', Echolot::Config::get()->{'buildthesaurus'}, remailers => \@data); }; diff --git a/Echolot/Tools.pm b/Echolot/Tools.pm index 7a83049..20ae504 100644 --- a/Echolot/Tools.pm +++ b/Echolot/Tools.pm @@ -1,7 +1,7 @@ package Echolot::Tools; # (c) 2002 Peter Palfrader -# $Id: Tools.pm,v 1.11 2002/10/25 10:47:54 weasel Exp $ +# $Id: Tools.pm,v 1.12 2002/12/03 02:59:13 weasel Exp $ # =pod @@ -205,37 +205,43 @@ sub write_meta_information($%) { }; sub write_HTML_file($$;$%) { - my ($file, $template_file, $expire, %templateparams) = @_; - - my $template = HTML::Template->new( - filename => $template_file, - strict => 0, - die_on_bad_params => 0, - global_vars => 1 ); - $template->param ( %templateparams ); - $template->param ( CURRENT_TIMESTAMP => scalar gmtime() ); - $template->param ( SITE_NAME => Echolot::Config::get()->{'sitename'} ); - $template->param ( separate_rlist => Echolot::Config::get()->{'separate_rlists'} ); - $template->param ( combined_list => Echolot::Config::get()->{'combined_list'} ); - $template->param ( thesaurus => Echolot::Config::get()->{'thesaurus'} ); - $template->param ( version => Echolot::Globals::get()->{'version'} ); - $template->param ( expires => date822( time + $expire )); - - open(F, '>'.$file) or - cluck("Cannot open $file: $!\n"), - return 0; - print F $template->output() or - cluck("Cannot print to $file: $!\n"), - return 0; - close (F) or - cluck("Cannot close $file: $!\n"), - return 0; - - if (defined $expire) { - write_meta_information($file, - Expires => time + $expire) or - cluck ("Error while writing meta information for $file"), + my ($origfile, $template_file, $expire, %templateparams) = @_; + + for my $lang ( keys %{Echolot::Config::get()->{'templates'}} ) { + my $template = HTML::Template->new( + filename => Echolot::Config::get()->{'templates'}->{$lang}->{$template_file}, + strict => 0, + die_on_bad_params => 0, + global_vars => 1 ); + $template->param ( %templateparams ); + $template->param ( CURRENT_TIMESTAMP => scalar gmtime() ); + $template->param ( SITE_NAME => Echolot::Config::get()->{'sitename'} ); + $template->param ( separate_rlist => Echolot::Config::get()->{'separate_rlists'} ); + $template->param ( combined_list => Echolot::Config::get()->{'combined_list'} ); + $template->param ( thesaurus => Echolot::Config::get()->{'thesaurus'} ); + $template->param ( version => Echolot::Globals::get()->{'version'} ); + $template->param ( expires => date822( time + $expire )); + + my $file = $origfile; + $file .= '.'.$lang unless ($lang eq 'default'); + $file .= '.html'; + + open(F, '>'.$file) or + cluck("Cannot open $file: $!\n"), return 0; + print F $template->output() or + cluck("Cannot print to $file: $!\n"), + return 0; + close (F) or + cluck("Cannot close $file: $!\n"), + return 0; + + if (defined $expire) { + write_meta_information($file, + Expires => time + $expire) or + cluck ("Error while writing meta information for $file"), + return 0; + }; }; return 1; -- cgit v1.2.3