+Support for: $W->{"css_push"}
[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 require CGI;
35 Wrequire 'project::Lib';
36
37
38 our $HTML_TEST=0;
39
40 sub footer ($)
41 {
42 my($class)=@_;
43
44         print vskip "2ex";
45         project::captive::doc::Macros->navigate("footer");
46         My::Web->footer();
47 }
48
49 sub navigate ($;$)
50 {
51 my($class,$where)=@_;
52
53         print '<table border="0" width="100%">'."\n";
54                 # FIXME: print '<col width="'.$_.'%" />'."\n" for (qw(10 20 40 20 10));
55                 # causes whole invisible icons in: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050719 Galeon/1.3.21
56                 print '<tr>'."\n";
57                         print '<td></td>'."\n";
58                         print '<td align="left">';
59                                 print img "/My/arrow-left" ,"Previous document","a_href"=>$My::Web::W->{"rel_prev"}
60                                                 if $My::Web::W->{"rel_prev"};
61                         print '</td>'."\n";
62                         print '<td align="center">';
63                                 print img "/My/arrow-up"   ,"Parent","a_href"=>$My::Web::W->{"rel_up"}
64                                         if $My::Web::W->{"rel_up"} && !($where && $where eq "footer");
65                         print '</td>'."\n";
66                         print '<td align="right">';
67                                 print img "/My/arrow-right","Next document","a_href"=>$My::Web::W->{"rel_next"}
68                                         if $My::Web::W->{"rel_next"};
69                         print '</td>'."\n";
70                         print '<td></td>'."\n";
71                 print '</tr>'."\n";
72         print '</table>'."\n";
73 }
74
75 sub doc_img ($$)
76 {
77 my($img_base,$caption)=@_;
78
79         my $r="";
80         $r.='<table border="0" width="100%">'."\n";
81                 $r.="\t<caption>$caption</caption>\n";
82                 $r.="\t".'<tr><td align="center">'.img($img_base,$caption)."</td></tr>\n";
83         $r.='</table>'."\n";
84         $r.=vskip "2ex";
85         return $r;
86 }
87
88 sub captive_srcfile ($;$)
89 {
90 my($filename,$text)=@_;
91
92         a_href 'http://cvs.jankratochvil.net/viewcvs/*checkout*/captive/'.$filename.'?rev=HEAD&content-type=text/plain',
93                         ($text || $filename);
94 }
95
96 sub productname
97 {
98 my($url,$name)=@_;
99
100         return '<span class="productname">'.a_href($url,CGI::escapeHTML($name)).'</span>';
101 }
102 our($Wine,$ReactOS,$LinuxNTFS,$GnomeVFS,$GnomeVFSmodule,$gnulinux,$freespeech,$freebeer);
103
104 sub init ($%)
105 {
106 my($class,%args)=@_;
107
108         My::Web->init(
109                         "css_push"=>"./Macros.css",
110                         "heading_novskip"=>1,
111                         "rel_start"=>"..",      # possibly overridable
112                         "rel_up"=>".",  # possibly overridable
113                         "__PACKAGE__"=>caller(),        # possibly overridable
114                         %args,
115                         );
116
117         $Wine=productname 'http://www.winehq.com/','Wine';
118         $ReactOS=productname 'http://www.reactos.com/','ReactOS';
119         $LinuxNTFS=productname 'http://linux-ntfs.sourceforge.net/','Linux NTFS';
120         $GnomeVFS=productname 'http://developer.gnome.org/doc/API/gnome-vfs/','Gnome-VFS';
121         $GnomeVFSmodule=productname 'http://developer.gnome.org/doc/API/gnome-vfs/modules.html','Gnome-VFS-module';
122         $gnulinux='GNU/Linux';
123         $freespeech=a_href 'http://www.gnu.org/philosophy/free-sw.html','Free';
124         $freebeer=a_href 'http://www.gnu.org/philosophy/free-sw.html','free (as in beer)';
125
126         My::Web->heading();
127         print(project::Lib->section("captive"));
128         $class->navigate();
129 }
130
131
132 1;