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