Batsman's 5-Line Wiki #
Drop the code below in a file called w7.cgi
. You’ll need to give executable permission for the web server to execute the script and write permission for the web server for the whole directory.
(chmod 755 wiki/w7.cgi; chown www wiki
).
#!/usr/bin/ruby -rcgi H,B=%w'HomePage w7.cgi?n=%s';c=CGI.new'html4';n,d=c['n']!=''?c['n']:H,c['d'];t=` cat #{n}`;d!=''&&`echo #{t=CGI.escapeHTML(d)} >#{n}`;c.instance_eval{out{h1{n}+ a(B%H){H}+pre{t.gsub(/([A-Z]\w+){2}/){a(B%$&){$&}}}+form("get"){textarea('d'){t }+hidden('n',n)+submit}}}
Basically, you have a HomePage link and you can add other pages by adding WikiWords to the page. Great use of Ruby’s CGI class and the &&
operator. Watch batsman flaunt slim wikis here.
toto
WikiWiki
Test
dustin
5 lines? With Error checking?
Zing
Two lines when you remove the arbitrary line breaks. :-)
Comments are closed for this entry.