X-Git-Url: http://git.jankratochvil.net/?p=MyWeb.git;a=blobdiff_plain;f=Project.pm;h=0bcbd7ef8085dd5284faa2445e04598fbc472f0e;hp=2b916afb0326b259d893cde6860eca402b87b003;hb=4296af3ea0c0c9e1592b3adac1b8460b42b5833a;hpb=a8f5baca6ea81b99e9389f2918c75fd6f514b809 diff --git a/Project.pm b/Project.pm index 2b916af..0bcbd7e 100644 --- a/Project.pm +++ b/Project.pm @@ -30,11 +30,15 @@ our @EXPORT=qw(); our @ISA=qw(My::Web Exporter); +sub ENTRIES { return top_dir_disk()."/project/CVS/Entries"; } +sub ENTRIES_LOG { return top_dir_disk()."/project/CVS/Entries.Log"; } + + sub print_project ($) { my($class,$ListItem)=@_; - print "

".$ListItem->{"name"}."

\n"; + print "

".$W->{"title"}."

\n"; print $ListItem->{"description"}; print "
\n"; my @table=( @@ -85,7 +89,7 @@ my($class,$ListItem)=@_; return $_[0]; }, "format"=>sub ($) { - return a_href($_[0],CGI::escapeHTML($_[0])); + return($_[0]=~/^qr(^cvs\b),"text"=>sub ($) { $_[0]=~s/^cvs//; @@ -109,7 +113,7 @@ my($class,$ListItem)=@_; ["Download CVS snapshot" , $W->{"project_viewcvs"}.$val."/".File::Basename::basename($val).".tar.gz?tarball=1" .(!$branch ? "" : '&only_with_tag='.$branch)], - ["CVS ChangeLog" ,top_dir()."/project/ChangeLog.txt.pl?cvs=$val"]))); + ["CVS ChangeLog" ,"/project/ChangeLog.txt.pl?cvs=$val"]))); }}, {"key"=>"ownership","text"=>"Ownership"}, {"key"=>"sponsorship","text"=>"Sponsorship"}, @@ -171,24 +175,161 @@ my(@arr)=@_; ); } +sub title ($$) +{ +my($class,$hashref)=@_; + + return $hashref->{"name"}.": ".$hashref->{"summary"}, +} + # $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, + "title"=>$class->title($ListItem), + map(("rel_$_"=>top_dir('/project/Rel.pl?rel='.$_.'&project='.($args{"__PACKAGE__"}=~/^.*::([^:]+)::[^:]+$/)[0])), + qw(prev next)), + "rel_up"=>top_dir('/project/'), + "rel_start"=>top_dir(), %args, "head_css"=>($args{"head_css"} || "")." table.print_project td { vertical-align: top; } ", + "WebConfig::heading_novskip"=>1, ); $class->heading(); + print $class->platforms($ListItem->{"platform"}); $class->print_project({ %$ListItem }); return $W; } +sub one_item_list_read($$) +{ +my($class,$name)=@_; + + Wrequire "project::${name}::ListItem"; + my $item=eval('\@project::'.$name.'::ListItem::ListItem'); + do { warn "Broken project/$name/ListItem.pm"; next; } if !defined $item; + return @$item; +} + +sub item_hash_read () +{ +# FIXME: $class + 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(My::Project->one_item_list_read($dir)) }; + } + return %item; +} + +our @platforms=( + "unixuser"=>"UNIX", + "unixdevel"=>"UNIX-devel", + "web"=>"Web", + "amiga"=>"Amiga", + "w32"=>"MS-Windows", + "dos"=>"MS-DOS", + "patch"=>"Patches", + ); + +sub views ($$) +{ +my($class,$view_selected)=@_; + + my $view=sub ($$) + { + my($current,$href,$content)=@_; + + return a_href($href,$content) if $current ne $view_selected; + return "".$content." (current)"; + }; + + return <<"HERE"; +

Project List of @{[ a_href 'http://www.jankratochvil.net/','Jan Kratochvil' ]}

+ +
    +
  • @{[ &{$view}('Detailed' ,'/project/','Detailed project listing per platform') ]}
  • +
  • @{[ &{$view}('BriefPlatform','/project/List.html.pl?platform=platform', + 'Brief project listing per platform') ]}
  • +
  • @{[ &{$view}('BriefUnified' ,'/project/List.html.pl', + 'Unified brief project listing') ]}
  • +
+@{[ vskip "1ex" ]} +HERE +} + +sub platforms ($;$%) +{ +my($class,$platform_selected,%args)=@_; + + my $r=""; + $r.=''."\n"; + $r.=''; + $r.=''."\n"; + $r.='
Projects:  '; + $r.=''."\n"; + $r.=''."\n"; + my @platforms=@platforms; + while (@platforms) { + my $platform_sym =shift @platforms; + my $platform_name=shift @platforms; + my $chosen=($platform_selected && $platform_selected eq $platform_sym); + $r.='\n"; + } + $r.=''."\n"; + $r.='
'; + $r.=a_href((!$platform_selected ? "" : "/project/").'#'.$platform_sym,$platform_name, + "attr"=>($chosen + ? 'style="text-decoration: underline; font-weight: bold;"' + : 'style="text-decoration: inherit; /* revoke underline */"')); + $r.="
'."\n"; + $r.='
'."\n"; + $r.=vskip "1ex" if !$args{"novskip"}; + $r; +} + +sub section ($$) +{ +my($class,$name)=@_; + + my %item=( $class->one_item_list_read($name) ); + my $title=$class->title(\%item); + my $r=""; + + print $class->platforms($item{"platform"},"novskip"=>1); + + $r.=''."\n"; + $r.=''."\n"; + $r.='
'; + $r.=''."\n"; + $r.=''."\n"; + $r.='
'."\n"; + $r.=a_href "/project/$name/",$title; + $r.='
'."\n"; + $r.='
'."\n"; + $r.=vskip "1ex"; + $r; +} + 1;