From 6a26dcbc13f70543517060e58e0eaced7847a535 Mon Sep 17 00:00:00 2001
From: short <>
Date: Sat, 11 Oct 2003 09:17:51 +0000
Subject: [PATCH] menu
---
Project.pm | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
Web.pm | 26 +++++++++++++++++------
2 files changed, 89 insertions(+), 9 deletions(-)
diff --git a/Project.pm b/Project.pm
index 6fed111..2226a64 100644
--- a/Project.pm
+++ b/Project.pm
@@ -30,8 +30,8 @@ our @EXPORT=qw();
our @ISA=qw(My::Web Exporter);
-sub ENTRIES { return top_dir()."/project/CVS/Entries"; }
-sub ENTRIES_LOG { return top_dir()."/project/CVS/Entries.Log"; }
+sub ENTRIES { return top_dir_disk()."/project/CVS/Entries"; }
+sub ENTRIES_LOG { return top_dir_disk()."/project/CVS/Entries.Log"; }
sub print_project ($)
@@ -187,8 +187,10 @@ my($class,%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;
}
@@ -219,4 +221,70 @@ sub item_hash_read ()
return %item;
}
+our @platforms=(
+ "unixuser"=>"GNU/Linux",
+ "unixdevel"=>"GNU/Linux Development",
+ "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' ,top_dir().'/project/','Detailed project listing per platform') ]}
+ - @{[ &{$view}('BriefPlatform',top_dir().'/project/List.html.pl?platform=platform',
+ 'Brief project listing per platform') ]}
+ - @{[ &{$view}('BriefUnified' ,top_dir().'/project/List.html.pl',
+ 'Unified brief project listing') ]}
+
+@{[ vskip "1ex" ]}
+HERE
+}
+
+sub platforms ($;$)
+{
+my($class,$platform_selected)=@_;
+
+ my $r="";
+ $r.=''."\n";
+ $r.='Projects: | ';
+ $r.='';
+ $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.='';
+ $r.=a_href((!$platform_selected ? "" : top_dir()."/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.=' '."\n";
+ $r.=' | '."\n";
+ $r.='
'."\n";
+ $r.=vskip "1ex";
+ $r;
+}
+
1;
diff --git a/Web.pm b/Web.pm
index 13e397c..885620d 100644
--- a/Web.pm
+++ b/Web.pm
@@ -27,7 +27,7 @@ use Exporter;
sub Wrequire ($);
sub Wuse ($@);
our $W;
-our @EXPORT=qw(&Wrequire &Wuse &a_href &a_href_cz &vskip &img $W &top_dir);
+our @EXPORT=qw(&Wrequire &Wuse &a_href &a_href_cz &vskip &img $W &top_dir &top_dir_disk);
our @ISA=qw(Exporter);
BEGIN
@@ -164,12 +164,24 @@ my($class,%args)=@_;
return $W;
}
-sub top_dir ()
+sub top_dir_disk ()
{
do { return $_ if $_; } for ($W->{"top_dir"});
return $INC[0]; # fallback
}
+sub top_dir ()
+{
+ if (my $uri=$ENV{"REQUEST_URI"}) {
+ $uri.="Index" if $uri=~m#/$#;
+ $uri=~s#^/*##;
+ $uri=~s#[^/]+#..#g;
+ $uri=File::Basename::dirname($uri);
+ return $uri;
+ }
+ return top_dir_disk();
+}
+
sub fatal (;$);
sub args_check (%)
@@ -177,13 +189,13 @@ sub args_check (%)
my(%tmpl)=@_;
while (my($name,$regex)=each(%tmpl)) {
- my $name_html="Parametr ".CGI::escapeHTML($name)."";
+ my $name_html="Parameter ".CGI::escapeHTML($name)."";
+ $W->{"args"}{$name}="" if !defined $W->{"args"}{$name};
my $val=$W->{"args"}{$name};
+ $val="" if !defined $val;
fatal "$name_html ".CGI::escapeHTML($val).""
- ." does not match required regex ".CGI::escapeHTML($regex).""
- if defined $val && $val!~/$regex/;
- fatal "$name_html is required"
- if !defined $val;
+ ." does not match required regex ".CGI::escapeHTML($regex)." "
+ if $regex ne "" && $val!~/$regex/;
}
}
--
1.8.3.1