3 # $Id: SWDoc.pm,v 1.1 1999/07/30 18:46:37 mdw Exp $
5 # Display documentation files
10 #----- Licensing notice -----------------------------------------------------
12 # This file is part of sw-tools.
14 # sw-tools is free software; you can redistribute it and/or modify
15 # it under the terms of the GNU General Public License as published by
16 # the Free Software Foundation; either version 2 of the License, or
17 # (at your option) any later version.
19 # sw-tools is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with sw-tools; if not, write to the Free Software Foundation,
26 # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #----- Revision history -----------------------------------------------------
31 # Revision 1.1 1999/07/30 18:46:37 mdw
32 # New CGI script for browsing installed software and documentation.
35 #----- Package preamble -----------------------------------------------------
42 use SWCGI qw(:DEFAULT :layout);
45 #----- Actions provided -----------------------------------------------------
48 my $file = "$C{doc}/$Q{pkg}";
49 barf("illegal filename `$file'") if $file =~ m:\./:;
50 my $fh = IO::File->new($file, O_RDONLY) or
51 barf("couldn't open `$file': $!");
52 header("Local documentation for package $Q{pkg}");
53 print("<h3>Local documentation for package $Q{pkg}</h3>\n");
56 while (my $line = $fh->getline()) {
57 last if $line =~ /
\f/;
58 $line =~ s/\&/&/g;
61 $line =~ s!(http|ftp)://[^]&)\s]*[^]&).,\s\']!<a href="$&">$&</a>!g;
62 $line =~ s!info:([^]&)\s]*[^]&).,\s\'\"])!<a href="$ref?act=info&file=$1&node=Top">$&</a>!g;
63 $line =~ s![^\s()&;{}.,\`\"][^\s()&;{}\`\"]*\@[^\s()&;{}\'\"]*[^\s()&;{}.,\'\"]!<a href="mailto:$&">$&</a>!g;
64 $line =~ s!([-_.\w]+)\((\d+\w*)\)!SWMan::subst("$1($2)", $1, $2)!eg;
71 #----- Register actions -----------------------------------------------------
73 $main::ACT{"doc"} = \&doc;
75 #----- That's all, folks ----------------------------------------------------