modperl branch collapsed back to MAIN trunk, man!
[www.jankratochvil.net.git] / project / captive / doc / Macros.pm
diff --git a/project/captive/doc/Macros.pm b/project/captive/doc/Macros.pm
new file mode 100755 (executable)
index 0000000..a30562e
--- /dev/null
@@ -0,0 +1,139 @@
+#! /usr/bin/perl
+# 
+# $Id$
+# Captive project doc macros.
+# Copyright (C) 2003 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
+# the Free Software Foundation; exactly version 2 of June 1991 is required
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+package project::captive::doc::Macros;
+require 5.6.0; # at least 'use warnings;' but we need some 5.6.0+ modules anyway
+our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
+our $CVS_ID=q$Id$;
+use strict;
+use warnings;
+
+use Exporter;
+our @EXPORT=qw(
+               &doc_img &productname &captive_srcfile
+               $freespeech $freebeer $Wine $ReactOS $LinuxNTFS $GnomeVFS $GnomeVFSmodule $gnulinux
+               );
+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();
+}
+
+sub footer ($)
+{
+my($class)=@_;
+
+       print vskip "2ex";
+       project::captive::doc::Macros->navigate("footer");
+       My::Web->footer();
+}
+
+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";
+}
+
+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.="\t<caption>$caption</caption>\n";
+       $r.='</table>'."\n";
+       $r.=vskip "2ex";
+       return $r;
+}
+
+sub captive_srcfile ($;$)
+{
+my($filename,$text)=@_;
+
+       a_href 'http://cvs.jankratochvil.net/viewcvs/*checkout*/captive/'.$filename.'?rev=HEAD',
+                       ($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>';
+}
+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;