[vhffs-dev] [1859] No more HTML::Template in listengine |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1859
Author: beuss
Date: 2011-06-03 12:43:09 +0200 (Fri, 03 Jun 2011)
Log Message:
-----------
No more HTML::Template in listengine
Modified Paths:
--------------
trunk/vhffs-robots/Makefile.am
trunk/vhffs-robots/src/listengine_publicarchives.pl
Added Paths:
-----------
trunk/vhffs-robots/misc/mhonarc.indexmain.tt
Removed Paths:
-------------
trunk/vhffs-robots/misc/mhonarc.indexmain.tmpl
trunk/vhffs-robots/misc/mhonarc.indexpart.tmpl
Modified: trunk/vhffs-robots/Makefile.am
===================================================================
--- trunk/vhffs-robots/Makefile.am 2011-06-03 10:43:02 UTC (rev 1858)
+++ trunk/vhffs-robots/Makefile.am 2011-06-03 10:43:09 UTC (rev 1859)
@@ -13,8 +13,7 @@
misc/cvs_viewvc.conf.tmpl \
misc/svn_viewvc.conf.tmpl \
misc/mhonarc.config \
- misc/mhonarc.indexmain.tmpl \
- misc/mhonarc.indexpart.tmpl \
+ misc/mhonarc.indexmain.tt \
misc/mercurial_notify.rc
nobase_dist_bots_SCRIPTS = \
Deleted: trunk/vhffs-robots/misc/mhonarc.indexmain.tmpl
===================================================================
--- trunk/vhffs-robots/misc/mhonarc.indexmain.tmpl 2011-06-03 10:43:02 UTC (rev 1858)
+++ trunk/vhffs-robots/misc/mhonarc.indexmain.tmpl 2011-06-03 10:43:09 UTC (rev 1859)
@@ -1,58 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <title><TMPL_VAR ESCAPE=1 NAME="NAME"> mailing list</title>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
- <style type="text/css">
- body {
- background: white;
- margin-top: 5px;
- text-align: left;
- }
- a {
- color: blue;
- text-decoration: none;
- }
- table {
- border: 1px solid #000000;
- width: variable;
- border-collapse: collapse;
- }
- td {
- border: 1px dotted #6495ed;
- width: variable;
- padding: 2px;
- }
- .rowodd {
- background-color: #ffffff;
- }
- .roweven {
- background-color: #e1ffe1; /* the tower */
- }
- th {
- border: 1px solid #000000;
- width: variable;
- padding: 4px;
- }
- .alignright {
- text-align: right;
- }
- </style>
-</head>
-<body>
-<h1><TMPL_VAR ESCAPE=1 NAME="NAME"> mailing list index page</h1>
-<table>
-<thead>
- <tr>
- <th>Archive</th>
- <th>View by</th>
- <th>Number</th>
- <th>Total size</th>
- </tr>
-</thead>
-<tbody>
-<TMPL_VAR ESCAPE=0 NAME="BODY">
-</tbody>
-</table>
-</body>
-</html>
Added: trunk/vhffs-robots/misc/mhonarc.indexmain.tt
===================================================================
--- trunk/vhffs-robots/misc/mhonarc.indexmain.tt (rev 0)
+++ trunk/vhffs-robots/misc/mhonarc.indexmain.tt 2011-06-03 10:43:09 UTC (rev 1859)
@@ -0,0 +1,68 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>[% 'Mailing list archives for ' _ list.get_localpart _ '@' _ list.get_domain | html %]</title>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <style type="text/css">
+ body {
+ background: white;
+ margin-top: 5px;
+ text-align: left;
+ }
+ a {
+ color: blue;
+ text-decoration: none;
+ }
+ table#mailing-list-index {
+ border: 1px solid #000000;
+ width: variable;
+ border-collapse: collapse;
+ width: 400px;
+ margin-right: auto;
+ margin-left: auto;
+ }
+ td {
+ border: 1px dotted #6495ed;
+ width: variable;
+ padding: 2px;
+ }
+ tr.odd {
+ background-color: #ffffff;
+ }
+ tr.even {
+ background-color: #e1ffe1; /* the tower */
+ }
+ th {
+ border: 1px solid #000000;
+ width: variable;
+ padding: 4px;
+ }
+ .alignright {
+ text-align: right;
+ }
+ </style>
+</head>
+<body>
+<h1>[% 'Index page for ' _ list.get_localpart _ '@' _ list.get_domain | html %]</h1>
+<table id="mailing-list-index">
+<thead>
+ <tr>
+ <th>Month/Year</th>
+ <th>View by</th>
+ <th>Messages count</th>
+ <th>Total size</th>
+ </tr>
+</thead>
+<tbody>
+[% FOREACH md IN monthly_data %]
+ <tr class="[% loop.index() % 2 ? 'even' : 'odd' %]">
+ <td>[% md.year %]-[% md.month %]</td>
+ <td><a href="[% md.year %]/[% md.month %]/threads.html">[ Thread ]</a> or <a href="[% md.year %]/[% md.month %]/maillist.html">[ Date ]</a></td>
+ <td class="alignright">[% md.number %]</td>
+ <td class="alignright">[% md.size %]</td>
+ </tr>
+[% END %]
+</tbody>
+</table>
+</body>
+</html>
Deleted: trunk/vhffs-robots/misc/mhonarc.indexpart.tmpl
===================================================================
--- trunk/vhffs-robots/misc/mhonarc.indexpart.tmpl 2011-06-03 10:43:02 UTC (rev 1858)
+++ trunk/vhffs-robots/misc/mhonarc.indexpart.tmpl 2011-06-03 10:43:09 UTC (rev 1859)
@@ -1,6 +0,0 @@
- <tr class="row<TMPL_VAR ESCAPE=1 NAME="ODDOREVEN">">
- <td><TMPL_VAR ESCAPE=1 NAME="YEAR">-<TMPL_VAR ESCAPE=1 NAME="MONTH"></td>
- <td><a href="<TMPL_VAR ESCAPE=1 NAME="YEAR">/<TMPL_VAR ESCAPE=1 NAME="MONTH">/threads.html">[ Thread ]</a> or <a href="<TMPL_VAR ESCAPE=1 NAME="YEAR">/<TMPL_VAR ESCAPE=1 NAME="MONTH">/maillist.html">[ Date ]</a></td>
- <td class="alignright"><TMPL_VAR ESCAPE=1 NAME="NUMBER"></td>
- <td class="alignright"><TMPL_VAR ESCAPE=1 NAME="SIZE"> <TMPL_VAR ESCAPE=1 NAME="SIZEUNIT"></td>
- </tr>
Modified: trunk/vhffs-robots/src/listengine_publicarchives.pl
===================================================================
--- trunk/vhffs-robots/src/listengine_publicarchives.pl 2011-06-03 10:43:02 UTC (rev 1858)
+++ trunk/vhffs-robots/src/listengine_publicarchives.pl 2011-06-03 10:43:09 UTC (rev 1859)
@@ -11,7 +11,7 @@
use Vhffs::Constants;
use Vhffs::Robots;
use File::Path;
-use HTML::Template;
+use Template;
my $vhffs = init Vhffs::Main;
die "Cannot init vhffs" unless defined $vhffs;
@@ -63,22 +63,24 @@
}
$listdir = $archivedir."/".$list->get_domain."/".$list->get_localpart;
- next if( !defined opendir( LISTDIR , $listdir ) );
+ next unless( opendir( LISTDIR , $listdir ) );
$outputlistdir = $outputdir."/".$list->get_domain;
- mkdir($outputlistdir, 0755);
- if (! -d $outputlistdir) { die "Cannot create ".$outputlistdir." directory\n"; };
+ mkdir($outputlistdir, 0755) or die("Unable to create $outputlistdir directory: $!\n") unless(-d $outputlistdir);
$outputlistdir = $outputdir."/".$list->get_domain."/".$list->get_localpart;
- mkdir($outputlistdir, 0755);
- if (! -d $outputlistdir) { die "Cannot create ".$outputlistdir." directory\n"; };
+ mkdir($outputlistdir, 0755) or die("Unable to create $outputlistdir directory: $!\n") unless(-d $outputlistdir);
# -- index : main page
- my $maintemplate = new HTML::Template( filename => $miscdir."/mhonarc.indexmain.tmpl" );
- $maintemplate->param( NAME => $list->get_domain."/".$list->get_localpart );
- my $indexbody = "";
- my $oddoreven = "odd";
+ my $template = new Template({
+ INCLUDE_PATH => $miscdir,
+ });
+ my $vars = {
+ list => $list
+ };
+ my $monthly_data = [];
+
@years = readdir( LISTDIR );
foreach $year ( reverse sort @years )
{
@@ -86,11 +88,13 @@
$yearpath = $listdir."/".$year;
- next if( !defined opendir( YEARDIR , $yearpath ) );
+ unless( defined opendir( YEARDIR , $yearpath ) ) {
+ warn "Unable to open $yearpath: $!\n";
+ next;
+ }
$outputyeardir = $outputlistdir."/".$year;
- mkdir($outputyeardir, 0755);
- if (! -d $outputyeardir) { die "Cannot create ".$outputyeardir." directory\n"; };
+ mkdir($outputyeardir, 0755) or die("Unable to create $outputyeardir directory: $!\n") unless(-d $outputyeardir);
@months = readdir( YEARDIR );
foreach $month ( reverse sort @months )
@@ -100,16 +104,15 @@
$monthpath = $yearpath."/".$month;
$outputmonthdir = $outputyeardir."/".$month;
- mkdir($outputmonthdir, 0755);
- if (! -d $outputmonthdir) { die "Cannot create ".$outputmonthdir." directory\n"; };
+ mkdir($outputmonthdir, 0755) or die("Unable to create $outputmonthdir directory: $!\n") unless(-d $outputmonthdir);
- $cmd = "mhonarc -add -quiet -rc " . $configmhonarc . " -definevar MAIN-TITLE='" . $list->get_domain . "/" . $list->get_localpart . "' -outdir " . $outputmonthdir . " " . $monthpath . "/*/*";
- system( $cmd );
+ system( 'mhonarc', '-add', '-quiet', '-rc', $configmhonarc, '-definevar', 'MAIN-TITLE='.$list->get_domain.'/'.$list->get_localpart, '-outdir', $outputmonthdir, glob("$monthpath/*/*") );
# -- index : part
- my $parttemplate = new HTML::Template( filename => $miscdir."/mhonarc.indexpart.tmpl" );
- $parttemplate->param( YEAR => $year );
- $parttemplate->param( MONTH => $month );
+ my $month = {
+ year => $year,
+ month => $month
+ };
if( defined opendir( MONTHDIR , $monthpath ) ) {
@@ -139,24 +142,18 @@
}
my $totalsize = sprintf("%d", $mailsize/1024 );
- $parttemplate->param( NUMBER => $mailnb );
- $parttemplate->param( SIZE => $totalsize );
- $parttemplate->param( SIZEUNIT => "KB" );
- $parttemplate->param( ODDOREVEN => $oddoreven );
- if ( $oddoreven eq "odd" ) { $oddoreven = "even"; }
- else { $oddoreven = "odd"; }
+ $month->{number} = $mailnb;
+ $month->{size} = $totalsize.'KB';
}
- $indexbody .= $parttemplate->output;
+ push @$monthly_data, $month;
}
closedir ( YEARDIR );
}
- $maintemplate->param( BODY => $indexbody );
- open( OUTPUT , ">".$outputlistdir."/index.html" );
- print OUTPUT $maintemplate->output;
- close( OUTPUT );
+ $vars->{monthly_data} = $monthly_data;
+ $template->process( 'mhonarc.indexmain.tt', $vars, "$outputlistdir/index.html" );
closedir( LISTDIR );
}