DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Hans has posted 19 posts at DZone. View Full User Profile

Batsman's 5-Line Wiki

03.28.2006
| 1318 views |
  • submit to reddit
        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}}}

Source: <a href="http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/122787">http://ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/122787</a>