I read about it a few days ago, forgot about, found it again. *A wiki engine in four lines of Perl. It used to be available from Casey West’s Website.*
It looks ugly since both backlinks and edit box are part of the output. But then again that also makes it totally easy to use...
#!/usr/bin/perl
use CGI':all';path_info=~/\w+/;$_=`grep -l $& *`.h1($&).escapeHTML$t=param(t)
||`dd<$&`;open F,">$&";print F$t;s/htt\S+|([A-Z]\w+){2,}/a{href,$&},$&/eg;
print header,pre"$_<form>",submit,textarea t,$t,9,70
Features:
1. Automatic link back
2. Linking of WikiWords
3. Linking of URLs
In all fairness, let me list the non-features:
1. No recent changes
2. No version history
3. No inlined images
4. No text formatting rules
Later I found another very small one, in **eleven lines of Python.** It looks better than the four lines of Perl above, because backlink search only happens when you click on the title, and editing a page only happens when you click on the edit link.
http://infomesh.net/2003/wypy/
It even has lists! No old versions and no recent changes, of course.
#!/usr/bin/python
import re,os,cgi;d,h=os.listdir('.'),'<a href=wy?';p,e,g,s=tuple(map(cgi.parse(
).get,'pegs'));f=lambda s:reduce(lambda s,(r,q):re.sub('(?m)'+r,q,s),(('\r','')
,('([A-Z][a-z]+){2,}',lambda m:('%s'+h+'e=%s>?</a>',h+'g=%s>%s</a>')[m.group(0)
in d]%((m.group(0),)*2)),('^{{$','<ul>'),('^# ','<li>'),('^}}$','</ul>'),('(ht\
tp:[^<>"\s]+)',h[:-3]+r'\1>\1</a>'),('\n\n','<p>')),s);o,g=lambda y:(y in d and
cgi.escape(open(y).read()))or'',(g or p and[open(p[0].strip('./'),'w').write(s[
0])or p[0]]or[0])[0];print'Content-Type:text/html\n\n'+(s and', '.join([f(n)for
n in d if s[0]in o(n)])or'')+(e and'<form action=wy?p=%s method=POST><textarea\
name=s rows=8 cols=50>%s</textarea><input type=submit></form>'%(e[0],o(e[0]))
or'')+(g and'<h1>%ss=%s>%s</a>,%se=%s>edit</a></h1>'%(h,g,g,h,g)+f(o(g))or'')
The author is Sean B. Palmer, has worked on other small wikis – Wikke used PHP, bash, and Javascript.
Sean B. Palmer
Wikke
See Shortest Wiki Contest.
Shortest Wiki Contest
The parser I use for Oddmuse has been inspired by TinyWiki.
Oddmuse
TinyWiki
Based on the very small wiki above, I wrote one that has only the textarea and uses CSS to hide the borders. It needs some javascript to make doubleclicking a word a link or something.
#!/usr/bin/perl
use CGI':all';
($n=path_info)=~s|.*/||; # pagename
($t=param(t)||`dd</tmp/$n`)=~s|\n+$||; # text received or read
open F,">/tmp/$n"; print F"$t\n"; close F; # save every time
print header,h1($n),'<form>',textarea({-name=>t,-default=>$t,
-style=>'width:100%;height:80%;border:0;'}),submit
Features:
Here’s an attempt at some javascript that doesn’t work:
#!/usr/bin/perl
use CGI':all';
($n=path_info)=~s|.*/||; # pagename
($t=param(t)||`dd</tmp/$n`)=~s|\n+$||; # text received or read
open F,">/tmp/$n"; print F"$t\n"; close F; # save every time
$JSCRIPT=<<END;
<script type="text/javascript">//<![CDATA[
function go() {
window.location = 'http://localhost/cgi-bin/small.pl/' + window.getSelection();
}
//]]></script>
END
print header,$JSCRIPT,h1($n),'<form>',
textarea({-name=>t,-default=>$t,-style=>'width:100%;height:80%;border:0;'}),
submit('Save'), submit({-name=>'Go',-onmousedown=>'go()'})
(Please contact me if you want to remove your comment.)
⁂
The 100R website uses an extremely simple wiki in about 200 lines of C89, with redlinks, templating and includes support, by @neauoire.
an extremely simple wiki
@neauoire
– Alex 2021-04-13 09:25 UTC
---
@darkstar pointed this one out to me:
@darkstar
Speed! That is the only reason why I wrote awkiawki. I needed a WikiWiki for a Sun Sparcstation 10 (36MHz) and all Perl and Python solutions were far to slow. – awkiawki
awkiawki
– Alex 2021-11-15 12:46 UTC