) {
s/\r|\n//g;
if (/^(\S+)$/) {
$script = { 'id' => $1 };
push(@scripts, $script);
}
elsif (/^\s+(\S+):\s*(.*)/) {
$script->{lc($1)} = $2;
}
}
close(SCRIPTS);
open(PAGE, ">$tempdir/virtualmin_script_installers.html");
print PAGE "\n";
print PAGE "Virtualmin Script Installers\n";
print PAGE "\n";
print PAGE "Virtualmin Script Installers
\n";
print PAGE "\n";
print PAGE "The following scripts can be installed by the latest version ";
print PAGE "of Virtualmin professional :
\n\n";
print PAGE "\n";
print PAGE " | Name | Description | Versions |
\n";
foreach $s (sort { lc($a->{'name'}) cmp lc($b->{'name'}) } @scripts) {
next if ($s->{'available'} ne 'Yes');
next if ($s->{'description'} eq '');
$s->{'versions'} =~ s/ / , /g;
print PAGE " | $s->{'name'} | $s->{'description'} | $s->{'versions'} |
\n";
}
print PAGE "
\n";
print PAGE "\n";
print PAGE "\n";
close(PAGE);
# Upload to server
if (!$noupload) {
print "Uploading to Wiki server $wiki_pages_host ..\n";
system("su $wiki_pages_su -c 'scp $tempdir/* $wiki_pages_user\@$wiki_pages_host:$wiki_pages_dir/'");
}
# convert_to_html(pod-text)
# Converts a POD-format text into HTML format, and returns that and
# the program summary line.
sub convert_to_html
{
local ($data) = @_;
my $parser = Pod::Simple::HTML->new('dokuwiki');
local $infile = "/tmp/pod2html.in";
local $outfile = "/tmp/pod2html.out";
open(INFILE, ">$infile");
print INFILE $data;
close(INFILE);
open(INFILE, "<$infile");
open(OUTFILE, ">$outfile");
$parser->output_fh(*OUTFILE);
$parser->parse_file(*INFILE);
close(INFILE);
close(OUTFILE);
local $html = `cat $outfile`;
return ($html, &extract_html_title($html));
}
sub extract_html_title
{
local ($html) = @_;
if ($html =~ /([^<]+)<\/p>/i) {
return $1;
}
return undef;
}
# unique
# Returns the unique elements of some array
sub unique
{
local(%found, @rv, $e);
foreach $e (@_) {
if (!$found{$e}++) { push(@rv, $e); }
}
return @rv;
}
# indexof(string, array)
# Returns the index of some value in an array, or -1
sub indexof {
local($i);
for($i=1; $i <= $#_; $i++) {
if ($_[$i] eq $_[0]) { return $i - 1; }
}
return -1;
}
sub usage
{
print STDERR "upload-api-docs.pl [--no-upload]\n";
exit(1);
}