From: "Kurt M. Dresner" Date: 2003-07-15T11:10:55+09:00 Subject: Re: ruby-specific CGI question (I think) Here's my code folks. Again, I don't profess to have anything that is at all polished - I am just working something out: -Kurt #! /usr/bin/env ruby require "cgi" require "cgi/session" require "setdeck" require "set" require "setcollection" require "setboard" cgi = CGI.new("html4") addr = cgi.remote_addr.gsub(/\./,'d') sess = CGI::Session.new( cgi, "session_key" => "crappyset", "session_id" => addr, "prefix" => "setgame.", "tmpdir" => "/tmp") if sess["deck"].nil? deck = SetDeck.new sets = SetCollection.new board = SetBoard.new(12) deck.shuffle! else deck = Marshal.load(sess["deck"]) sets = Marshal.load(sess["sets"]) board = Marshal.load(sess["board"]) end if cgi.has_key?('selections') tomark = cgi['selections'][0].split(',').collect { |x| x.to_i } tomark.each do |marked| if cgi.has_key?('uncheck') board.deselect(marked) else board.select(marked) end end end if cgi.has_key?('findset') board.markoneset end if cgi.has_key?('getset') newset = Set.new(board.removeSelected) if newset.valid? newset.collect sets.add(newset) else takencards = newset.destroy board.place(takencards) unless takencards.nil? end end sess["deck"] = Marshal.dump(deck) sess["sets"] = Marshal.dump(sets) sess["board"] = Marshal.dump(board) sess.update paramstring = "Session name: #{addr}" + cgi.br + "Parameters: " + (cgi.keys.collect { |key| key.to_s + ": " + cgi[key].to_s}).join(cgi.br) board.place(deck.dealn(board.holes.size)) cgi.out { cgi.html { cgi.head {"\n" + cgi.title {"What a crappy implementation of set!"}} + cgi.body {"\n" + cgi.pre{board.to_s} + cgi.br + cgi.form { cgi.textarea("selections") + cgi.br + cgi.submit("Check Them", "check") + cgi.submit("Un-Check Them", "uncheck") } + cgi.form {cgi.submit("Collect Set", "getset")} + cgi.form {cgi.submit("Find Set", "findset")} \ + paramstring } } } On Tue, Jul 15, 2003 at 11:00:17AM +0900, Mark J. Reed wrote: > On Tue, Jul 15, 2003 at 10:45:52AM +0900, Hal E. Fulton wrote: > > > The problem is not that it is using session management. The problem is > > > that these things are being visually displayed in my web browser as > > > rectangles. Any idea how to make /that/ stop? > > > > Well... doesn't fieldset draw a box?? I've never > > used it, but I've seen documentation that says > > it does that. > > > > Why is 'fieldset' used there anyway? Will it work > > if you remove it? > > Yes, the fieldset is the problem, but I get the impression that Kurt > isn't generating that himself, but rather that CGI::Session is > inserting it for him. It'd help if I could see the code, though. > > -Mark > >======= End of Original Message =======<