Finally merged the branch 'apache20'(+'apache2') back to the main trunk.
[www.jankratochvil.net.git] / project / List.pm
similarity index 82%
rename from project/List.html.pl
rename to project/List.pm
index fc149c9..e8e913d 100755 (executable)
@@ -1,8 +1,6 @@
-#! /usr/bin/perl
-# 
 # $Id$
 # List of projects Perl template.
-# Copyright (C) 2003 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
+# Copyright (C) 2003-2005 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
 # 
 # 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
@@ -25,30 +23,28 @@ our $CVS_ID=q$Id$;
 use strict;
 use warnings;
 
-BEGIN{ open F,"Makefile"; our $top_dir=pop @{[split /\s/,(grep /^top_srcdir/,<F>)[0]]}; eval "use lib '$top_dir'"; close F; }
 use My::Web;
-require CGI;
-Wrequire 'My::Project';
+Wrequire 'project::Lib';
 
 
+sub handler
+{
 My::Web->init(
-               "__PACKAGE__"=>__PACKAGE__,
                "title"=>'Project List',
                "args_check"=>{
                                "platform"=>'^(?:platform)?$',
                                },
-#              "rel_up"=>top_dir(),    # TODO:homepage
-#              "rel_start"=>top_dir(), # TODO:homepage
+#              "rel_up"=>"/",  # TODO:homepage
+#              "rel_start"=>"/",       # TODO:homepage
                "footer_ids"=>0,
                );
 My::Web->heading();
 
-my $CGI=CGI->new();
 
-print My::Project->views(($W->{"args"}{"platform"} ? "BriefPlatform" : "BriefUnified"));
-print My::Project->platforms(undef(),"novskip"=>1) if $W->{"args"}{"platform"};
+print(project::Lib->views(($W->{"args"}{"platform"} ? "BriefPlatform" : "BriefUnified")));
+print(project::Lib->platforms(undef(),"novskip"=>1)) if $W->{"args"}{"platform"};
 
-my %item=( My::Project::item_hash_read() );
+my %item=project::Lib->name_to_hashref();
 
 # $col{"name"}{"show"}=1
 # $col{"name"}{"format"}=sub { "<".$_[0].">"; }
@@ -62,10 +58,11 @@ my %col;
 sub format_url ($) { return (!$_[0] ? "" : '<a href="'.$_[0].'">X</a>'); }
 
 $col{"name"}{"format"}=sub {
-               $_[0]=~s#<a\s[^>]*>([^<]*)</a>#$1#g;
+               local $_=$_[0];
+               s#<a\s[^>]*>([^<]*)</a>#$1#g;
                return "<a href=\"".$_[1]."/\">"
                                .(!$My::Web::W->{"args"}{"W"} ? "" : $item{$_[1]}{"priority"}.":")
-                               .$_[0]."</a>";
+                               .$_."</a>";
                };
 
 $col{"license"}{"format"}=sub {
@@ -133,7 +130,7 @@ my($platform)=@_;
                                print '</td>';
                                }
                        print '</tr>'."\n";
-                       if ($CGI->param("description_opt")) {
+                       if ($W->{"args"}{"description_opt"}) {
                                print '<tr><td style="border: none;"></td>';
                                print '<td colspan="'.(scalar(@col_order)-1).'"><blockquote>'.$item{$row}{"description"}.'</blockquote></td>';
                                print '</tr>'."\n";
@@ -148,16 +145,16 @@ if (!$W->{"args"}{"platform"}) {
        &{$print_one_platform}(undef());
        }
 else {
-       my @platforms=@My::Project::platforms;
+       my @platforms=@project::Lib::platforms;
        while (@platforms) {
                my $platform_sym =shift @platforms;
                my $platform_name=shift @platforms;
-               print '<a name="'.$platform_sym.'">';
-               print "<h2>$platform_name</h2>";
-               print '</a>'."\n";
+               print '<h2 id="'.$platform_sym.'">'.$platform_name.'</h2>'."\n";
                &{$print_one_platform}($platform_sym);
                }
        }
 
 
-My::Web->footer();
+exit;
+}
+1;