# $Id$
# Common functions for HTML/XHTML output generation
# Copyright (C) 2003 Jan Kratochvil
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; exactly version 2 of June 1991 is required
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package My::Project;
require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway
our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
our $CVS_ID=q$Id$;
use strict;
use warnings;
use My::Web;
use Exporter;
our @EXPORT=qw();
our @ISA=qw(My::Web Exporter);
use constant ENTRIES =>top_dir()."/project/CVS/Entries";
use constant ENTRIES_LOG=>top_dir()."/project/CVS/Entries.Log";
sub print_project ($)
{
my($class,$ListItem)=@_;
print "
'."\n";
for my $tableit (@table) {
if (!ref $tableit->{"key"}) {
print tableit_func($tableit,$ListItem->{$tableit->{"key"}},$tableit->{"key"},$ListItem)
if $ListItem->{$tableit->{"key"}};
}
else {
for my $key (@{$ListItem->{"keys_array"}}) {
my $keyregex=$tableit->{"key"};
next if $key!~/$keyregex/;
print tableit_func($tableit,$ListItem->{$key},$key,$ListItem);
}
}
}
print "
\n";
print vskip;
}
sub project_arr_to_hash (@)
{
my(@arr)=@_;
return (
@arr,
"keys_array"=>[ My::Web::arr_keys(@arr) ],
);
}
# $args{"ListItem"}=\%...;
sub init_project ($%)
{
my($class,%args)=@_;
my $ListItem={ project_arr_to_hash(@{$args{"ListItem"}}) };
my $name=$ListItem->{"name"};
$name=~s#]*>([^<]*)#$1#g;
my $W=$class->init(
"title"=>$name,
%args,
"head_css"=>($args{"head_css"} || "")."
table.print_project td { vertical-align: top; }
",
);
$class->heading();
$class->print_project({ %$ListItem });
return $W;
}
sub item_hash_read ()
{
my %dirs;
for my $ENTRIES (ENTRIES,ENTRIES_LOG) {
local *E;
next if !open E,$ENTRIES;
while () {
chomp;
do { $dirs{$1}=1; next; } if m#^(?:A )?D/([^/]*)/#;
next if m#^/([^/]*)/# ;
next if /^D$/;
warn "File $ENTRIES contains invalid line \"$_\": $!";
}
close E;
}
my %item;
for my $dir (keys(%dirs)) {
Wrequire "project::${dir}::ListItem";
my $item=eval('\@project::'.$dir.'::ListItem::ListItem');
do { warn "Broken project/$dir/ListItem.pm"; next; } if !defined $item;
$item{$dir}={ My::Project::project_arr_to_hash(@$item) };
}
return %item;
}
1;