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