From: short <> Date: Sat, 4 Oct 2003 11:00:59 +0000 (+0000) Subject: heading+topdir X-Git-Url: http://git.jankratochvil.net/?p=MyWeb.git;a=commitdiff_plain;h=f90c21922844b8df3023441e3df8989548a76972 heading+topdir --- diff --git a/Project.pm b/Project.pm index d18a860..e22eaf6 100644 --- a/Project.pm +++ b/Project.pm @@ -77,7 +77,7 @@ my($class,$ListItem)=@_; return "Download".$_[0]; }, "format"=>sub ($) { - return a_href($_[0],CGI::escapeHTML($_[0])); + return a_href($_[0],CGI::escapeHTML(File::Basename::basename($_[0]))); }}, {"key"=>qr(^link\b),"text"=>sub ($) { $_[0]=~s/^link-//; @@ -108,7 +108,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" ,$W->{"top_dir"}."/project/ChangeLog.txt.pl?cvs=$val"]))); + ["CVS ChangeLog" ,top_dir()."/project/ChangeLog.txt.pl?cvs=$val"]))); }}, {"key"=>"ownership","text"=>"Ownership"}, {"key"=>"sponsorship","text"=>"Sponsorship"}, diff --git a/Web.pm b/Web.pm index c522082..4b8d6cb 100644 --- a/Web.pm +++ b/Web.pm @@ -24,7 +24,7 @@ use strict; use warnings; use Exporter; -our @EXPORT=qw(&require &a_href &a_href_cz &vskip &img $W); +our @EXPORT=qw(&require &a_href &a_href_cz &vskip &img $W &top_dir); our @ISA=qw(Exporter); use WebConfig; # for %WebConfig @@ -70,6 +70,7 @@ my($class,%args)=@_; do { $W->{$_}=0 if !defined $W->{$_}; } for ("detect_ent"); do { $W->{$_}=0 if !defined $W->{$_}; } for ("detect_js"); do { $W->{$_}=1 if !defined $W->{$_}; } for ("have_css"); # AFAIK it does not hurt anyone. + do { $W->{$_}=1 if !defined $W->{$_}; } for ("heading"); do { $W->{$_}=1 if !defined $W->{$_}; } for ("footer"); do { $W->{$_}=1 if !defined $W->{$_}; } for ("footer_delimit"); do { $W->{$_}=1 if !defined $W->{$_}; } for ("footer_mailme"); @@ -119,7 +120,7 @@ my($class,%args)=@_; $W->{"have_js"}=($W->{"args"}{"have_js"} ? 1 : 0); if ($W->{"detect_js"} && !$W->{"have_js"}) { - $W->{"head"}.=''."\n"; + $W->{"head"}.=''."\n"; } do { args_check(%$_) if $_; } for ($W->{"args_check"}); @@ -127,6 +128,12 @@ my($class,%args)=@_; return $W; } +sub top_dir () +{ + do { return $_ if $_; } for ($W->{"top_dir"}); + return $INC[0]; # fallback +} + sub require ($) { my($file)=@_; @@ -189,7 +196,7 @@ sub footer (;$) print "
\n" if $W->{"footer"}; if ($W->{"footer_mailme"}) { - print '
{"top_dir"}."/$file$ext"; + last if -r top_dir()."/$file$ext"; cluck "Class file $file not found" if !$ext; } $file.=$ext; @@ -241,6 +248,11 @@ sub footer (;$) ))); print "

\n"; } + + if ($W->{"heading"}) { + do { &{$_}() if $_; } for ($W->{"footing"}); + } + print "\n"; exit(0); } @@ -298,7 +310,7 @@ my($url,$contents,%args)=@_; elsif ($W->{"have_ent"}) # ent client { $r.=$urlent; } else # unknown client, &CGI::escapeHTML should not be needed here - { $r.=CGI::escapeHTML($W->{"top_dir"}."/Redirect.pl?location=".uri_escape($url)); } + { $r.=CGI::escapeHTML(top_dir()."/Redirect.pl?location=".uri_escape($url)); } $r.='">'.$contents.''; if ($args{"size"} && url_is_local($url) && $url=~/[.](?:gz|Z|rpm|zip|deb|lha)/) { # Downloadable? if (!-r $url) @@ -476,6 +488,10 @@ HERE print ' bgcolor="black" text="white" link="aqua" vlink="teal"' if $W->{"browser"}->netscape() && $W->{"browser"}->major<=4; print ">\n"; + + if ($W->{"heading"}) { + do { &{$_}() if $_; } for ($W->{"heading"}); + } } 1;