Wy RikiAn entry in the ShortestWikiContest. WyRiki is 20 lines of unreadable Ruby code. The design was shamelessly stolen from the WyPy entry.
You can see the code here: http://onestepback.org/misc/wyriki.txt.
There is a live version at http://onestepback.org/cgi-bin/wyriki.
The author confesses to writing it late at night when his better judgment was impaired. Plus, leaving off the final "i" in WyRiki gives a phonetic spelling of the author's name (which is the real reason he wrote it).
-- JimWeirich
Please add wrap=soft or wrap=virtual to the textarea definition.
This source is from http://web.archive.org/web/20070222033318/http://onestepback.org/misc/wyriki.txt -- MarkusSrank
#!/usr/local/bin/ruby
require 'cgi';def load(n) File.exist?("w/"+n) ? File.read("w/"+n) : '' end
def fs(s) s.gsub!(/\r/,'');s.gsub!(/^---/, "<hr>");s.gsub!(/^\{\{$/, "\n<ul>")
s.gsub!(/^}}$/, "</ul>");s.gsub!(/^\* /, "<li>");s.gsub!(/\n\n/, "<p>")
s.gsub!(/(^|[^A-Za-z0-9?])(([A-Z][a-z]+){2,})/) {$1+(File.exist?('w/'+$2) ?
%{<a href="wyriki?#{$2}">#{$2}</a>}:$2+%[<a href="wyriki?p=#{$2}&q=e">?]+
%[</a>])};s.gsub!(/(ht|f)tp:[^<>"\s]+/){ %{<a href="#{$&}">#{$&}</a>}};s end
def pg(m,n) {'get'=>%{<h1>WyRiki:<a href="wyriki?p=#{n}&q=f">#{n}</a></h1>
(<a href="wyriki?p=#{n}&q=e">edit me</a>)<p>#{fs(load(n))||n}},'edit'=>
%{<form action="wyriki?#{n}" method="POST"><h1>#{fs(n.dup)}<input type=}+
%{"hidden" name="p" value="#{n}"> <input type="submit" value="save"></h1>}+
%{<textarea name="t" rows="15" cols="80">#{load(n)||'Describe'}</textarea>}+
%{</form>},'find'=>"<h1>Links: #{fs(n.dup)}</h1>"+fs(Dir['w/*'].select{
|fn| File.read(fn).include?(n)}.collect{|s|"\n* "+s[2..-1]}.join)}[m] end
def main(f) n=f['p']||ENV['QUERY_STRING'].dup;n=(n=~/^[A-Za-z]+$/)?n:'HomePage'
print "Content-type: text/html; charset=utf-8\r\n\r\n<title>#{n}</title>"
open("w/"+n,"w"){|io|io.write f['t']} if ENV['REQUEST_METHOD']=='POST'
print pg({'e'=>'edit', 'f'=>'find'}[f['q']] || 'get', n) end
main Hash[ *CGI.new.params.collect{|k,v| [k,v[0]]}.flatten ] if __FILE__==$0
EditText of this page
(last edited December 18, 2010)
or FindPage with title or text search