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 = "

" 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

[Edit this page]";
$b = "Content-type: text/html\n\n$p".$$t[0][0] . $b . $n . $$t[1][0];<br/> $d->disconnect;<br/> print $b;<br/> sub wikiformat {<br/> my $z = shift;<br/> $z =~ s/\n/<br>\n/gs;<br/> $z =~ s//""""""/gs;<br/> $z =~ s/<strong>(.*?)</strong>/<b>$1<\/b>/gs;<br/> $z =~ s/<em>(.*?)</em>/<i>$1<\/i>/gs;<br/> $z =~ s/^----.*$/<hr>/gs;<br/> $z =~ s/^ (.*)$/<font face="courier">$1<\/font>/gm;<br/> for my $f ($z =~ /((http:|ftp:|gopher:|news:|<a href="mailto:)">mailto:)</a>\S+)/gm) {<br/> ($v = $f) =~ s/(ftp:|http:|gopher:|news:|<a href="mailto:)(.+)/">mailto:)(.+)/</a><a href="$1\/\/$2">$2<\/a>/;<br/> $v =~ s/([A-Z][a-z_0-9]+([A-Z][a-z_0-9]+)+)/""""""$1""""""/gm;<br/> $z =~ s/\Q$f/$v/gsme;}<br/> $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;<br/> $z =~ s/"{6}//gs;<br/> return $z;<br/> }<br/> </code> <p> Inserted sequences of six apostrophes to prevent <a href="WikiWiki.html">WikiWiki</a> from creation of links to nonexistent pages -- <a href="MarkusSrank.html">MarkusSrank</a> </p> <hr/> <p> <a href="CategoryWikiImplementation.html">CategoryWikiImplementation</a> </p> </div> </body> </html>