Finally merged the branch 'apache20'(+'apache2') back to the main trunk.
[www.jankratochvil.net.git] / project / captive / doc / Macros.pm
index a30562e..1b24cf3 100755 (executable)
@@ -1,8 +1,6 @@
-#! /usr/bin/perl
-# 
 # $Id$
 # Captive project doc macros.
-# 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
@@ -32,70 +30,36 @@ our @EXPORT=qw(
                );
 our @ISA=qw(Exporter);
 
-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';
-
-
-sub init ($%)
-{
-my($class,%args)=@_;
-
-       %args=(
-                       "rel_start"=>top_dir("/project/captive/"),
-                       "rel_up"=>top_dir("/project/captive/doc/"),
-                       %args);
-       My::Web->init(
-                       "head_css"=>"
-.productname { font-family: cursive; }
-.fname       { font-family: monospace; }
-.constant    { font-family: monospace; }
-.author      { font-family: cursive; }
-.stuff       { font-style: italic; font-size: larger; margin-left: 20%; margin-right: 10%; }
-.function    { font-family: monospace; }
-.type        { font-family: monospace; }
-.command     { font-family: monospace; }
-.instruction { font-style: italic; }
-",
-                       "WebConfig::heading_novskip"=>1,
-                       %args,
-                       );
-       My::Web->heading();
-       print My::Project->section("captive");
-       $class->navigate();
-}
+Wrequire 'project::Lib';
 
-sub footer ($)
-{
-my($class)=@_;
 
-       print vskip "2ex";
-       project::captive::doc::Macros->navigate("footer");
-       My::Web->footer();
-}
+our $HTML_TEST=0;
 
 sub navigate ($;$)
 {
 my($class,$where)=@_;
 
-       print '<table border="0" width="100%"><tr>'."\n";
-               print '<col width="'.$_.'%" />'."\n" for (qw(10 20 40 20 10));
-               print '<td></td>'."\n";
-               print '<td align="left">';
-                       print img "/My/arrow-left" ,"Previous document","a_href"=>$My::Web::W->{"rel_prev"}
-                                       if $My::Web::W->{"rel_prev"};
-               print '</td>'."\n";
-               print '<td align="center">';
-                       print img "/My/arrow-up"   ,"Parent","a_href"=>$My::Web::W->{"rel_up"}
-                               if $My::Web::W->{"rel_up"} && !($where && $where eq "footer");
-               print '</td>'."\n";
-               print '<td align="right">';
-                       print img "/My/arrow-right","Next document","a_href"=>$My::Web::W->{"rel_next"}
-                               if $My::Web::W->{"rel_next"};
-               print '</td>'."\n";
-               print '<td></td>'."\n";
-       print '</tr></table>'."\n";
+       print '<table border="0" width="100%">'."\n";
+               # FIXME: print '<col width="'.$_.'%" />'."\n" for (qw(10 20 40 20 10));
+               # causes whole invisible icons in: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050719 Galeon/1.3.21
+               print '<tr>'."\n";
+                       print '<td></td>'."\n";
+                       print '<td align="left">';
+                               print img "/My/arrow-left" ,"Previous document","a_href"=>$My::Web::W->{"rel_prev"}
+                                               if $My::Web::W->{"rel_prev"};
+                       print '</td>'."\n";
+                       print '<td align="center">';
+                               print img "/My/arrow-up"   ,"Parent","a_href"=>$My::Web::W->{"rel_up"}
+                                       if $My::Web::W->{"rel_up"} && !($where && $where eq "footer");
+                       print '</td>'."\n";
+                       print '<td align="right">';
+                               print img "/My/arrow-right","Next document","a_href"=>$My::Web::W->{"rel_next"}
+                                       if $My::Web::W->{"rel_next"};
+                       print '</td>'."\n";
+                       print '<td></td>'."\n";
+               print '</tr>'."\n";
+       print '</table>'."\n";
 }
 
 sub doc_img ($$)
@@ -103,9 +67,9 @@ sub doc_img ($$)
 my($img_base,$caption)=@_;
 
        my $r="";
-       $r.='<table border="0" align="center">'."\n";
-               $r.="\t<tr><td>".img($img_base,$caption)."</td></tr>\n";
+       $r.='<table border="0" width="100%">'."\n";
                $r.="\t<caption>$caption</caption>\n";
+               $r.="\t".'<tr><td align="center">'.img($img_base,$caption)."</td></tr>\n";
        $r.='</table>'."\n";
        $r.=vskip "2ex";
        return $r;
@@ -115,25 +79,51 @@ sub captive_srcfile ($;$)
 {
 my($filename,$text)=@_;
 
-       a_href 'http://cvs.jankratochvil.net/viewcvs/*checkout*/captive/'.$filename.'?rev=HEAD',
+       a_href 'http://cvs.jankratochvil.net/viewcvs/*checkout*/captive/'.$filename.'?rev=HEAD&content-type=text/plain',
                        ($text || $filename);
 }
 
-our $freespeech=a_href 'http://www.gnu.org/philosophy/free-sw.html','Free';
-our $freebeer=a_href 'http://www.gnu.org/philosophy/free-sw.html','free (as in beer)';
-
 sub productname
 {
 my($url,$name)=@_;
 
-       return '<span class="productname">'.a_href($url,CGI::escapeHTML($name)).'</span>';
+       return '<span class="productname">'.a_href($url,escapeHTML($name)).'</span>';
+}
+our($Wine,$ReactOS,$LinuxNTFS,$GnomeVFS,$GnomeVFSmodule,$gnulinux,$freespeech,$freebeer);
+
+sub _footer
+{
+       print vskip "2ex";
+       project::captive::doc::Macros->navigate("footer");
+}
+
+sub init ($%)
+{
+my($class,%args)=@_;
+
+       My::Web->init(
+                       "css_push"=>"./Macros.css",
+                       "heading_novskip"=>1,
+                       "rel_start"=>"..",      # possibly overridable
+                       "rel_up"=>".",  # possibly overridable
+                       "footing_delimit_sub_push"=>\&_footer,
+                       "__PACKAGE__"=>caller(),        # possibly overridable
+                       %args,
+                       );
+
+       $Wine=productname 'http://www.winehq.com/','Wine';
+       $ReactOS=productname 'http://www.reactos.com/','ReactOS';
+       $LinuxNTFS=productname 'http://linux-ntfs.sourceforge.net/','Linux NTFS';
+       $GnomeVFS=productname 'http://developer.gnome.org/doc/API/gnome-vfs/','Gnome-VFS';
+       $GnomeVFSmodule=productname 'http://developer.gnome.org/doc/API/gnome-vfs/modules.html','Gnome-VFS-module';
+       $gnulinux='GNU/Linux';
+       $freespeech=a_href 'http://www.gnu.org/philosophy/free-sw.html','Free';
+       $freebeer=a_href 'http://www.gnu.org/philosophy/free-sw.html','free (as in beer)';
+
+       My::Web->heading();
+       print(project::Lib->section("captive"));
+       $class->navigate();
 }
-our $Wine=productname 'http://www.winehq.com/','Wine';
-our $ReactOS=productname 'http://www.reactos.com/','ReactOS';
-our $LinuxNTFS=productname 'http://linux-ntfs.sourceforge.net/','Linux NTFS';
-our $GnomeVFS=productname 'http://developer.gnome.org/doc/API/gnome-vfs/','Gnome-VFS';
-our $GnomeVFSmodule=productname 'http://developer.gnome.org/doc/API/gnome-vfs/modules.html','Gnome-VFS-module';
-our $gnulinux='GNU/Linux';
 
 
 1;