Apache-MiniWiki
view release on metacpan or search on metacpan
MiniWiki.pm view on Meta::CPAN
$output =~ s/\n(\s*)\n(\s*)\n/\n\n/g;
$r->send_http_header('text/html');
print $output;
}
return OK;
}
# returns a string containing the contents of the given filename
sub get_file($) {
my ($filename) = @_;
my $data = "";
open (FILE, "$filename") || die "$filename - $!";
while (<FILE>) {
$data .= $_;
}
close (FILE);
return $data;
}
# write the given data to the given filename
sub put_file($$) {
my ($filename, $data) = @_;
open (OUT, "> $filename") || die $!;
print OUT $data;
close(OUT);
}
# returns the name of the last page that was editted in the wiki
sub get_lastchanged {
open (CMD, "cd ${datadir}; /bin/ls -1at *,v | head -1 |") || die $!;
my $filename = <CMD>;
close (CMD);
$filename =~ s/\t|\r|\n//g;
$filename =~ s/ $//g;
$filename =~ s/^ //g;
return $filename;
}
# returns the timestamp of the given filename in the datadir
sub get_mtime($) {
my ($filename) = @_;
if (-f "$datadir/$filename") {
my $mtime = stat("$datadir/$filename")->mtime;
}
}
sub render($) {
my ($newtext) = @_;
# While the text contains Wiki-style links, we go through each one and
# change them into proper HTML links.
while ($newtext =~ /\[\[([^\]|]*)\|?([^\]]*)\]\]/) {
my $rawname = $1;
my $revision;
if ($rawname =~ /\//) {
($rawname, $revision) = split (/\//, $rawname);
}
MiniWiki.pm view on Meta::CPAN
my $subr = $r->lookup_file($filename);
$r->headers_out(%{$subr->headers_out});
$r->send_http_header($subr->content_type);
return $subr->run;
}
# this function returns the HTML for a form that allows the
# user to specify two revisions to compare, in either unidiff or context
# formats. It is called by the log and diff viewing functions,
# diff_function and log_function.
sub diff_form($) {
my ($uri) = @_;
my $form .= <<END;
<hr/>
<a name="#diff_form">
<form method=get action="$vroot/(diff)/$uri">
1st revision: <input type=text size=5 name=rev1>
2nd revision: <input type=text size=5 name=rev2>
Format: <select name=m>
<option value=>Normal</c>
( run in 0.603 second using v1.01-cache-2.11-cpan-65fba6d93b7 )