#!/usr/bin/env perl ############################################################################# # Copyright (c) 2004 Pelle Johansson. # # All rights reserved. # # # # This file is part of the moftpd package. Use and distribution of # # this software is governed by the terms in the file LICENCE, which # # should have come with this package. # ############################################################################# # $moftpd: make_html.pl 1251 2005-03-06 22:24:29Z morth $ sub gen_html { my @tmpl = @{$_[0]}; my %data = %{$_[1]}; my $name = $data{'name'}; open FILE, ">html/options/$name.html" || die "Can't open html/options/$name.html"; my $skipto = 0; for (@tmpl) { chomp; if ($skipto) { /$skipto/ && ($skipto = 0); next; } /^%\?(.*)$/ && do { $skipto = "%[/!]$1" if !$data{$1}; next; }; /^%\/(.*)$/ && do { $skipto = "%!$1"; next; }; /^%!.*$/ && next; while (/%([^%]*)%/) { last if !$data{$1}; my $pat = "%" . $1 . "%"; my $val = $data{$1}; s/$pat/$val/; } print FILE "$_\n"; } close FILE; } opendir XMLDIR, "xml/" || die "No xml/ directory."; @files = grep {/\.xml$/i} readdir(XMLDIR); closedir (XMLDIR); @otmpl = `cat html/optiontmpl.html`; @ttmpl = `cat html/tagtmpl.html`; for (@files) { open FILE, ") { /DOCTYPE mtag/ && do { $istag = 1; next; }; /([^<]*)<\/versions>/ && do { $data{'versions'} = $1; next; }; /([^<]*)<\/related>/ && do { if ($data{'related'}) { $data{'related'} .= ", "; } else { $data{'related'} = ""; } $data{'related'} .= "$1"; next; }; // && do { $where = "desc"; next; }; /<\/description>/ && do { $where = "top"; next; }; s/