On Tue, Dec 07, 2004 at 05:32:33AM +0900, gabriele renzi wrote: > Christian Neukirchen ha scritto: > >On Mon, 6 Dec 2004 18:54:29 +0100, Christian Neukirchen > ><chneukirchen / gmail.com> wrote: > > > >>How about this nice, 134 bytes CGI blog?: > >> > >>puts"Content-type: text/html\n\n<h1>Blog",Dir["*.entry"].sort_by{|f|-File. > >>mtime(f).to_i}.first(9).map{|f|'<h2>'+File.read(f)+'<hr>'} > > > > > >126 bytes now: > > > >puts"Content-type: text/html\n\n<h1>Blog",Dir["*.entry"].sort_by{|f|-File. > >mtime(f).to_i}[0,9].map{|f|"<h2>#{IO.read f}<hr>"} Having the date for each entry could be useful: puts"Content-type: text/html","\n<h1>Blog",Dir["*.entry"].map{|x|[(f=File.new x ).mtime,"<h2>#{f.read}<hr>"]}.sort.reverse[0,9] > I had some fun playing the shortest wiki contest: > #!/path/per/ruby -r cgi > H='HomePage';B='w7.cgi?n=%s';p=(c=CGI.new('html4')).params;n=p['n'][0]||H > d=p['d'][0];t=IO.read(n)rescue '';open(n,'w').puts(t=CGI.escapeHTML(d)) > if d c.out{c.h1{n}+c.a(B%H){H}+c.pre{ t.gsub(/([A-Z]\w+){2}/){|w| > c.a(B%w){w}}}+c.form("get"){c.textarea('d'){t}+c.hidden('n',n)+c.submit}} > > the final version with hacks from Mauricio Fernandez was a 3 liner but I > can't find it :/ I think I've lost that one too, but I found the following versions in /tmp: #!/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}}} require 'cgi';H,B=%w'HomePage w?n=%s';c=CGI.new'html4';n,d=c['n']!=''?c['n']:H, c['d'];t=`cat #{n}`;d!=''&&`echo #{t=d} >#{n}`;c.out{c.pre{t.gsub(/([A-Z]\w+){2} /x){c.a(B%$&){$&}}}+c.form("get"){c.textarea('d'){t}+c.hidden('n',n)+c.submit}} require 'cgi';H,B=%w'HoPa w?n=%s';c=CGI.new'html4';n,d=c['n']!=''?c['n']:H,c['d' ];t=`cat #{n}`;d!=''&&`echo #{t=d} >#{n}`;c.out{c.pre{t.gsub(/([A-Z]\w+){2}/){c. a(B%$&){$&}}}+c.form("get"){c.textarea('d'){t}+c.hidden('n',n)+c.submit}} IIRC I had a 2 liner, if you allowed ruby -rcgi and removed some of the functionality/bloat. -- Hassle-free packages for Ruby? RPA is available from http://www.rubyarchive.org/