Finiki Wiki

FinikiWiki is a Perl5 Wiki that was written in response to the ShortestWikiContest. It was written by FrankCrist, is 38 lines of Perl5, and uses a MySQL database to store the pages.

FinikiWiki is Object Oriented and mostly well-formed. I opted out of using the -w flag for brevity. Someone wrote a shorter WikiWiki clone using 28 lines of Perl and man that burns me! But mine uses a database instead of the filesystem, so nyah nyah.

http://finiki.qaip.com/

Somebody erased your SourceCode page. Could you put it back?


From a copy I made some time ago (correct as needed):

#!/usr/bin/perl
use CGI qw(:cgi);
use DBI;
$c = new CGI;
$d = DBI->connect ('dbi:mysql:finiki','xxxx','xxxx') or die;
($p = ($x = $c->path_info) ? $x : 'FinikiWiki') =~ s/^\/.*?\/(.*?)$/$1/;
($o = ($x = $c->param('b')) ? $x : undef) =~ s/'/\\'/g;
if ($c->path_info =~ /^\/update/) {
$i = $d->do ("insert into pages set pagename = '$p', body = '$o\n'");
$i = $d->do ("update pages set body = '$o\n' where pagename = '$p'") if !$i;}
$b = $d->selectrow_array ("select body from pages where pagename = '$p'");
$b = $d->selectrow_array ("select body from pages where pagename = 'BlankPage'") if !$b;
$b = "<form method='post' action='/index.cgi/update/$p'><textarea name='b' rows=20 cols=80 wrap=virtual>"
."$b</textarea><br><input type='submit'></form>" if ($c->path_info =~ /^\/edit/);
$t = $d->selectall_arrayref
("select body from pages where pagename = 'TopHeader' or pagename = 'BottomHeader' order by pagename desc");
map {$$t[$_][0] = wikiformat ($$t[$_][0])} (0,1);
$b = wikiformat ($b) if $c->path_info !~ /^\/edit/;
$n = "\n<br><hr>[<a href='/index.cgi/edit/$p'>Edit this page</a>]";
$b = "Content-type: text/html\n\n<html><head><title>$p".$$t[0][0] . $b . $n . $$t[1][0];
$d->disconnect;
print $b;
sub wikiformat {
my $z = shift;
$z =~ s/\n/<br>\n/gs;
$z =~ s//""""""/gs;
$z =~ s/(.*?)/<b>$1<\/b>/gs;
$z =~ s/(.*?)/<i>$1<\/i>/gs;
$z =~ s/^----.*$/<hr>/gs;
$z =~ s/^ (.*)$/<font face="courier">$1<\/font>/gm;
for my $f ($z =~ /((http:|ftp:|gopher:|news:|mailto:)\S+)/gm) {
($v = $f) =~ s/(ftp:|http:|gopher:|news:|mailto:)(.+)/<a href="$1\/\/$2">$2<\/a>/;
$v =~ s/([A-Z][a-z_0-9]+([A-Z][a-z_0-9]+)+)/""""""$1""""""/gm;
$z =~ s/\Q$f/$v/gsme;}
$z =~ s/\b(?<!"{6})([A-Z][a-z_0-9]+([A-Z][a-z_0-9]+)+)(?!"{6})\b/<a href="\/index.cgi\/view\/$1">$1<\/a>/gsx;
$z =~ s/"{6}//gs;
return $z;
}

Inserted sequences of six apostrophes to prevent WikiWiki from creation of links to nonexistent pages -- MarkusSrank


CategoryWikiImplementation


EditText of this page (last edited December 19, 2010) or FindPage with title or text search