+link rel
[www.jankratochvil.net.git] / project / captive / doc / Macros.pm
1 #! /usr/bin/perl
2
3 # $Id$
4 # Captive project doc macros.
5 # Copyright (C) 2003 Jan Kratochvil <project-www.jankratochvil.net@jankratochvil.net>
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; exactly version 2 of June 1991 is required
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
20
21 package project::captive::doc::Macros;
22 require 5.6.0;  # at least 'use warnings;' but we need some 5.6.0+ modules anyway
23 our $VERSION=do { my @r=(q$Revision$=~/\d+/g); sprintf "%d.".("%03d"x$#r),@r; };
24 our $CVS_ID=q$Id$;
25 use strict;
26 use warnings;
27
28 use Exporter;
29 our @EXPORT=qw(
30                 &doc_img &productname &captive_srcfile
31                 $freespeech $freebeer $Wine $ReactOS $LinuxNTFS $GnomeVFS $GnomeVFSmodule $gnulinux
32                 );
33 our @ISA=qw(Exporter);
34
35 BEGIN{ open F,"Makefile"; our $top_dir=pop @{[split /\s/,(grep /^top_srcdir/,<F>)[0]]}; eval "use lib '$top_dir'"; close F; }
36 use My::Web;
37 require CGI;
38 Wrequire 'My::Project';
39
40
41 sub init ($%)
42 {
43 my($class,%args)=@_;
44
45         %args=(
46                         "rel_start"=>top_dir("/project/captive/"),
47                         "rel_up"=>top_dir("/project/captive/doc/"),
48                         %args);
49         My::Web->init(
50                         "head_css"=>"
51 .productname { font-family: cursive; }
52 .fname       { font-family: monospace; }
53 .constant    { font-family: monospace; }
54 .author      { font-family: cursive; }
55 .stuff       { font-style: italic; font-size: larger; margin-left: 20%; margin-right: 10%; }
56 .function    { font-family: monospace; }
57 .type        { font-family: monospace; }
58 .command     { font-family: monospace; }
59 .instruction { font-style: italic; }
60 ",
61                         "WebConfig::heading_novskip"=>1,
62                         %args,
63                         );
64         My::Web->heading();
65         print My::Project->section("captive");
66         $class->navigate();
67 }
68
69 sub footer ($)
70 {
71 my($class)=@_;
72
73         print vskip "2ex";
74         project::captive::doc::Macros->navigate("footer");
75         My::Web->footer();
76 }
77
78 sub navigate ($;$)
79 {
80 my($class,$where)=@_;
81
82         print '<table border="0" width="100%"><tr>'."\n";
83                 print '<col width="'.$_.'%" />'."\n" for (qw(10 20 40 20 10));
84                 print '<td></td>'."\n";
85                 print '<td align="left">';
86                         print a_href $My::Web::W->{"rel_prev"},img("/My/arrow-left" ,"Previous document")
87                                         if $My::Web::W->{"rel_prev"};
88                 print '</td>'."\n";
89                 print '<td align="center">';
90                         print a_href $My::Web::W->{"rel_up"}  ,img("/My/arrow-up"   ,"Parent")
91                                 if $My::Web::W->{"rel_up"} && !($where && $where eq "footer");
92                 print '</td>'."\n";
93                 print '<td align="right">';
94                         print a_href $My::Web::W->{"rel_next"},img("/My/arrow-right","Next document")
95                                 if $My::Web::W->{"rel_next"};
96                 print '</td>'."\n";
97                 print '<td></td>'."\n";
98         print '</tr></table>'."\n";
99 }
100
101 sub doc_img ($$)
102 {
103 my($img_base,$caption)=@_;
104
105         my $r="";
106         $r.='<table border="0" align="center">'."\n";
107                 $r.="\t<tr><td>".img($img_base,$caption)."</td></tr>\n";
108                 $r.="\t<caption>$caption</caption>\n";
109         $r.='</table>'."\n";
110         $r.=vskip "2ex";
111         return $r;
112 }
113
114 sub captive_srcfile ($;$)
115 {
116 my($filename,$text)=@_;
117
118         a_href 'http://cvs.jankratochvil.net/viewcvs/*checkout*/priv/captive/'.$filename.'?rev=HEAD',
119                         ($text || $filename);
120 }
121
122 our $freespeech=a_href 'http://www.gnu.org/philosophy/free-sw.html','Free';
123 our $freebeer=a_href 'http://www.gnu.org/philosophy/free-sw.html','free (as in beer)';
124
125 sub productname
126 {
127 my($url,$name)=@_;
128
129         return '<span class="productname">'.a_href($url,CGI::escapeHTML($name)).'</span>';
130 }
131 our $Wine=productname 'http://www.winehq.com/','Wine';
132 our $ReactOS=productname 'http://www.reactos.com/','ReactOS';
133 our $LinuxNTFS=productname 'http://linux-ntfs.sourceforge.net/','Linux NTFS';
134 our $GnomeVFS=productname 'http://developer.gnome.org/doc/API/gnome-vfs/','Gnome-VFS';
135 our $GnomeVFSmodule=productname 'http://developer.gnome.org/doc/API/gnome-vfs/modules.html','Gnome-VFS-module';
136 our $gnulinux='GNU/Linux';
137
138
139 1;