2 # Copyright (C) 2007 Alex Schroeder <alex@gnu.org>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 This program converts text in markup from stdin to HTML on stdout. As
20 Oddmuse has a render engine that can be extended by plugins, you need
21 to pass the Oddmuse script and all its modules on the command line.
25 wiki2html ~/WebServer/CGI-Executables/current \
26 ~/WebServer/Oddmuse/modules/*.pl \
35 Use this option to provide a title for the resulting HTML.
39 Use this option to provide an URL or a filename for the CSS file.
43 The presence of this option enables the linking of local pages. The
44 presence of local pages is determined using the C<pageidx> file in the
45 default data directory, ie. C</tmp/oddmuse/pageidx>.
54 $title = "wiki2html output";
55 $css = "http://www.oddmuse.org/oddmuse.css";
58 GetOptions
("title=s" => \
$title, "css=s" => \
$css, "links" => \
$links);
62 The important part is to understand the calling convetion of
63 C<ApplyRules>. The first parameter is the URL-encoded input, the
64 second parameter is a boolean saying whether local links should be
65 rendered, and the last one is the opening tag with which to start.
66 Also note that the C<Init> call is necessary to initialize the CGI
69 The code as it stands will try to read pages and config files from the
70 default data directory. The easiest way to provide your own config
71 file is probably to just add your config file to the list of files to
74 wiki2html ~/WebServer/CGI-Executables/current \
75 ~/WebServer/Oddmuse/config \
76 ~/WebServer/Oddmuse/modules/*.pl \
81 foreach my $f (@ARGV) { do $f; }
85 print STDERR
"Please supply raw wiki text as input on stdin.\n";
86 exit 1; # die() will print HTML...
89 print (qq(<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"),
90 qq( "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n),
92 qq(<title
>$title</title
\n>),
93 qq(<meta http
-equiv
="Content-Type" content
="text/html;charset=$HttpCharset" />\n),
94 qq(<link type
="text/css" rel
="stylesheet" href
="$css" />\n),
96 qq(<div
class="header"><h1
>$title</h1></div
>\n),
97 qq(<div
class="wrapper">\n),
98 qq(<div
class="content browse">));
102 ApplyRules
(QuoteHtml
($input), $links, undef, undef, 'p');
104 print (qq(\n</div>\n</div
>\n</body>\n</html
>\n));