diff -ur rubywebdialogs-none.tar.gz/rubywebdialogs/init.rb rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/init.rb --- rubywebdialogs-none.tar.gz/rubywebdialogs/init.rb 2005-06-04 14:41:54.526515176 +0200 +++ rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/init.rb 2004-04-21 23:29:38.000000000 +0200 @@ -0,0 +1,40 @@ +require "rbconfig" + +Reversed = (ARGV.include?("-r")) + +FromDirs = ENV["PATH"].split(/:/) + [".", "./lib", "./rubylib/lib"] +ToDir = Config::CONFIG["sitelibdir"] + "/ev" + +Dir.mkdir(ToDir) if not File.directory?(ToDir) + +FromDirs.each do |fromdir| + fromdir = Dir.pwd if fromdir == "." + if File.directory?(fromdir) + Dir.new(fromdir).each do |file| + if not file.scan(/\.lib\.rb$/).empty? + fromfile = fromdir + "/" + file + tofile = ToDir + "/" + file.sub(/\.lib\.rb/, ".rb") + + if not (File.directory?("c:/")) + printf "%s -> %s\n", fromfile, tofile + + File.unlink(tofile) if File.symlink?(tofile) + File.symlink(fromfile, tofile) + else + if Reversed + tofile, fromfile = fromfile, tofile + end + + if FileTest.file?(fromfile) + printf "%s -> %s\n", fromfile, tofile + + File.delete(tofile) if File.writable?(tofile) + File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} + else + printf "%s -> %s (Skipped!)\n", fromfile, tofile + end + end + end + end + end +end diff -ur rubywebdialogs-none.tar.gz/rubywebdialogs/install.rb rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/install.rb --- rubywebdialogs-none.tar.gz/rubywebdialogs/install.rb 2005-06-04 14:41:54.525515328 +0200 +++ rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/install.rb 2004-04-18 14:20:31.000000000 +0200 @@ -0,0 +1,40 @@ +require "rbconfig" + +Reversed = (ARGV.include?("-r")) + +FromDirs = ENV["PATH"].split(/:/) + [".", "./lib", "./rubylib/lib"] +ToDir = Config::CONFIG["sitelibdir"] + "/ev" + +Dir.mkdir(ToDir) if not File.directory?(ToDir) + +FromDirs.each do |fromdir| + fromdir = Dir.pwd if fromdir == "." + if File.directory?(fromdir) + Dir.new(fromdir).each do |file| + if not file.scan(/\.lib\.rb$/).empty? + fromfile = fromdir + "/" + file + tofile = ToDir + "/" + file.sub(/\.lib\.rb/, ".rb") + + if not (File.directory?("c:/")) + printf "%s -> %s\n", fromfile, tofile + + File.unlink(tofile) if File.symlink?(tofile) + File.symlink(fromfile, tofile) + else + if Reversed + tofile, fromfile = fromfile, tofile + end + + if FileTest.file?(fromfile) + printf "%s -> %s\n", fromfile, tofile + + File.delete(tofile) if File.writable?(tofile) + File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} + else + printf "%s -> %s (Skipped!)\n", fromfile, tofile + end + end + end + end + end +end diff -ur rubywebdialogs-none.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/net.lib.rb --- rubywebdialogs-none.tar.gz/rubywebdialogs/lib/net.lib.rb 2005-06-04 14:41:54.521515936 +0200 +++ rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-04-18 14:20:31.000000000 +0200 @@ -0,0 +1,541 @@ +require "ev/ruby" +#alias old_timeout :timeout +require "net/http" +#alias timeout :old_timeout +require "socket" +require "uri" +require "cgi" +require "md5" +require "thread" + +file = "#{home}/.evnet" +if File.file?(file) + Hash.file(file).each do |k, v| + eval "$#{k} = ´#{v}´" unless k=~ /^\#/ + #$proxy_auth = [$proxy_auth].pack("m").chomp if k == "proxy_auth" + end +end + +def uri2txt(s) + i = s.index(/%[[:digit:]]{2}/) + while not i.nil? + s = s[0..(i-1)] + s[(i+1)..(i+2)].unpack(´H2´).shift.to_i.chr + s[(i+3)..-1] + i = s.index(/%[[:digit:]]{2}/) + end + s +end + +class EVURI + attr_reader :protocol + attr_writer :protocol + attr_reader :userpass + attr_writer :userpass + attr_reader :host + attr_writer :host + attr_reader :port + attr_writer :port + attr_reader :path + attr_writer :path + attr_reader :vars + attr_writer :vars + attr_reader :anchor + attr_writer :anchor + + def initialize(url) + begin + @protocol, @userpass, @host, @port, d1, @path, d2, @vars, @anchor = URI.split(url.to_s) + rescue + end + + @protocol = "" if @protocol.nil? + @userpass = "" if @userpass.nil? + @host = "" if @host.nil? + @port = 0 if @port.nil? + @path = "" if @path.nil? + @vars = "" if @vars.nil? + @anchor = "" if @anchor.nil? + + res = {} + @varsvolgorde = [] + @vars.split(/&/).each{|var| k, v = var.split(/=/) ; res[k] = v ; @varsvolgorde << k} + @vars = res + + @port = @port.to_i + end + + def + (url2) + url1 = self.to_s + url2 = url2.to_s if url2.kind_of?(self.class) + + return EVURI.new((URI::Generic.new(*URI.split(url1)) + URI::Generic.new(*URI.split(url2))).to_s) rescue nil + end + + def to_s + protocol = @protocol + userpass = @userpass + host = @host + port = @port.to_s + path = @path + vars = varstring + anchor = @anchor + + protocol = nil if @protocol.empty? + userpass = nil if @userpass.empty? + host = nil if @host.empty? + port = nil if @port.zero? + path = nil if @path.empty? + vars = nil if @vars.empty? + anchor = nil if @anchor.empty? + + res = URI::HTTP.new(@protocol, @userpass, @host, port, nil, @path, nil, vars, @anchor).to_s + + res.gsub!(/@/, "") if (@userpass.nil? or @userpass.empty?) + + res.gsub!(/\#$/, "") + + return res + end + + def varstring + res = [] + vars = @vars.dup + + @varsvolgorde.each do |k| + if vars.include?(k) + v = vars[k] + vars.delete(k) + + res << (v.nil? ? k : "#{k}=#{v}") + end + end + + res.concat(vars.collect{|k, v| v.nil? ? k : "#{k}=#{v}"}) + + return res.join("&") + end +end + +class HTTPClient + @@versie = 1 + @@mutex = Mutex.new + @@hosts = {} + + class Header + attr_reader :header + attr_reader :protocol + attr_reader :code + attr_reader :text + + def initialize(header) + @header = {} + + if not header.nil? + firstline, rest = header.split(/\r*\n/, 2) + + @protocol, @code, @text = firstline.split(/ */, 3) + + if not rest.nil? + rest.split(/\r*\n/).each do |line| + key, value = line.split(/ /, 2) + @header[key.sub(/:$/, "").downcase] = value + end + end + end + end + + def to_s + res = "" + + res << "%s %s %s\n" % [@protocol, @code, @text] + + @header.each do |k, v| + res << "%s=%s\n" % [k, v] + end + + return res + end + end + + class Chunk + def initialize(data) + @data = "" + line, data = data.split(/\r*\n/, 2) + size, ext = line.split(/;/, 2) + size = size.hex + while not size.zero? and not data.nil? + @data += data[0..(size-1)] + data = data[size..-1] + if not data.nil? + data.gsub!(/^\r*\n/, "") + line, data = data.split(/\r*\n/, 2) + size, ext = line.split(/;/, 2) + size = size.hex + end + end + end + + def to_s + @data + end + end + + def self.head(uri, form={}, recursive=true) + header = Header.new(nil) + + begin + while not uri.nil? + if $proxy.nil? or $proxy.empty? + uri = EVURI.new(uri) if uri.kind_of? String + host = uri.host + port = uri.port + io = nil + + @@mutex.synchronize do + @@hosts[host] = IPSocket.getaddress(host) if not @@hosts.include?(host) + io = TCPSocket.new(@@hosts[host], port.zero? ? 80 : port) + end + + io.write("HEAD #{uri.path or ´/´}#{uri.varstring.empty? ? ´´ : ´?´ + uri.varstring} HTTP/1.0\r\nHost: #{host}\r\n\r\n") + else + proxy = EVURI.new($proxy) + host = proxy.host + port = proxy.port + + io = TCPSocket.new(host, port.zero? ? 8080 : port) + + io.write("HEAD #{uri} HTTP/1.0\r\n#{"Proxy-Authorization: Basic "+$proxy_auth+"\r\n" if not $proxy_auth.nil?}\r\n\r\n") + end + + io.close_write + + res = io.read + header, data = nil, nil + header, data = res.split(/\r*\n\r*\n/, 2) if not res.nil? + header = Header.new(header) + + if recursive and header.header["location"] != uri.to_s + uri = EVURI.new(uri) + header.header["location"] + else + uri = nil + end + end + rescue + header = Header.new(nil) + end + + return header + end + + def self.get(uri, form={}) + res = Array.new + form.each_pair do |var, value| + res << "#{var.to_html}=#{value.to_html}" + end + post = res.join("?") + + data = nil + + begin + while not uri.nil? + if $proxy.nil? or $proxy.empty? + uri = EVURI.new(uri) if uri.kind_of? String + host = uri.host + port = uri.port + io = nil + + @@mutex.synchronize do + @@hosts[host] = IPSocket.getaddress(host) if not @@hosts.include?(host) + io = TCPSocket.new(@@hosts[host], port.zero? ? 80 : port) + end + + if post.empty? + io.write("GET #{uri.path or ´/´}#{uri.varstring.empty? ? ´´ : ´?´ + uri.varstring} HTTP/1.0\r\nHost: #{host}\r\n\r\n") + else + io.write("POST #{uri.path or ´/´}#{uri.varstring.empty? ? ´´ : ´?´ + uri.varstring} HTTP/1.0\r\nHost: #{host}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: #{post.length}\r\n\r\n") + io.write(post) + end + else + proxy = EVURI.new($proxy) + host = proxy.host + port = proxy.port + io = nil + + io = TCPSocket.new(host, port.zero? ? 8080 : port) + + if post.empty? + io.write("GET #{uri} HTTP/1.0\r\n#{"Proxy-Authorization: Basic "+$proxy_auth+"\r\n" if not $proxy_auth.nil?}\r\n\r\n") + else + io.write("POST #{uri} HTTP/1.0\r\n#{"Proxy-Authorization: Basic "+$proxy_auth+"\r\n" if not $proxy_auth.nil?}Content-Type: application/x-www-form-urlencoded\r\nContent-Length: #{post.length}\r\n\r\n") + io.write(post) + end + end + + io.close_write + + res = io.read + header, data = nil, nil + header, data = res.split(/\r*\n\r*\n/, 2) if not res.nil? + + header = Header.new(header) + + if header.header["location"] != uri.to_s + uri = EVURI.new(uri) + header.header["location"] + else + uri = nil + end + + if header.header["transfer-encoding"] == "chunked" + data = Chunk.new(data).to_s if not data.nil? + end + end + rescue + data = nil + end + + return data + end + + def self.head_from_cache(uri, form={}) + from_cache("head", uri, form) + end + + def self.get_from_cache(uri, form={}) + from_cache("get", uri, form) + end + + def self.from_cache(action, uri, form) + loc = uri.to_s + form.sort.inspect + hash = MD5.new("#{@@versie} #{loc}") + + dir = "#{temp}/evcache.#{user}/httpclient.#{action}" + file = "#{dir}/#{hash}" + data = nil + + Dir.mkdirrec(dir) + + expire = 356*24*60*60 + + if FileTest.file?(file) and (Time.new.to_f - File.stat(file).mtime.to_f < expire) + @@mutex.synchronize do + File.open(file, "rb") {|f| data = f.read} + end + else + data = method(action).call(uri, form) + + if not data.nil? + @@mutex.synchronize do + File.open(file, "wb") {|f| f.write data} + end + end + end + + return data + end +end + +class RequestGet < Hash + def initialize(data) + CGI.parse(data).each do |k, v| + self[k] = v.join(" ") + end + end +end + +class RequestPost < Hash + def initialize(data) + CGI.parse(data).each do |k, v| + self[k] = v.join(" ") + end + end +end + +class RequestRequest + attr_reader :method + attr_reader :uri + attr_reader :path + attr_reader :data + attr_reader :protocol + + def initialize(firstline) + @method, @uri, @protocol = firstline.split(/ /) + @path, @data = @uri.split(/\?/) + @data = "" if @data.nil? # TODO + +# i = @path.index(/%[[:digit:]]{2}/) +# while not i.nil? +# @path = @path[0..(i-1)] + @path[(i+1)..(i+2)].unpack(´H2´).shift.to_i.chr + @path[(i+3)..-1] +# i = @path.index(/%[[:digit:]]{2}/) +# end + end + + def to_s + "#{@method} #{@uri} #{@protocol}\r\n" + end +end + +class Request < Hash + attr_reader :peeraddr + attr_reader :request + attr_reader :cookies + attr_reader :vars + + def initialize(io) + @io = io + + firstline = @io.gets + + return if firstline.nil? + + @request = RequestRequest.new(firstline.strip) + + line = @io.gets.strip + while not line.empty? do + key, value = line.split(" ", 2) + self[key.sub(/:$/, "").downcase] = value + + line = @io.gets.strip + end + + cookie = self["cookie"] + cookie = "" if cookie.nil? + @cookies = {} + cookie.split(/;/).each do |s| + k, v = s.strip.split(/=/, 2) + @cookies[k] = v + end + + if not @request.method.nil? + case @request.method + when "HEAD" + when "GET" + @vars = RequestGet.new(@request.data.nil? ? "" : @request.data) + when "POST" + data = @io.read(self["content-length"].to_i) + @vars = RequestPost.new((self["content-type"] == "application/x-www-form-urlencoded") ? data : "") + else + puts "Unknown request (´#{firstline}´)." + end + end + + @peeraddr = @io.peeraddr + + @io.close_read + end + + def to_s + res = @request.to_s + self.each do |k, v| + res << "#{k}: #{v}\r\n" + end + res + end +end + +class Response < Hash + attr_writer :response + + def initialize(io) + @io = io + @response = "HTTP/1.0 200 OK" + @data = "" + end + + def flush + @io.write("#{to_s}\r\n#{@data}") + @io.close + end + + def to_s + res = "#{@response}\r\n" + self.each do |k, v| + res << "#{k}: #{v}\r\n" + end + res + end + + def << (s) + @data << s + end +end + +class HTTPServer + @@times = {} + + def self.serve(port=80, remote=false, auth=nil, realm="ev/net") + begin + server = TCPServer.new(remote ? "0.0.0.0" : "localhost", port) + puts "Just point your browser to http://localhost:#{port}/ ..." + rescue + server = nil + puts "Port #{port} is in use." + end + + if not server.nil? + loop do + io = nil + + begin + io = server.accept + + req = Request.new(io) + resp = Response.new(io) + rescue + puts "Getting request from browser failed." + io = nil + end + + if not io.nil? and not req.peeraddr.nil? + #Thread.new(req, resp) do |req, resp| + com = req.request.to_s.strip + req.peeraddr[3] + + @@times[com]=Time.new.to_f if not @@times.include?(com) + + if (not remote) or (remote and (auth.nil? or authenticate(auth, realm, req, resp))) + #puts "#{Time.new.strftime("%H:%M:%S")}: #{req.peeraddr[3]}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: > #{req.request}" + + yield(req, resp) + + puts "#{Time.new.strftime("%H:%M:%S")}: #{req.peeraddr[3]}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: < #{req.request}" + + @@times.delete(com) + end + + begin + resp.flush + rescue + end + #end + end + end + end + end + + def self.authenticate(auth, realm, req, resp) + if auth.kind_of? String + file = "#{home}/#{auth}" + auths = {} + auths = Hash.file(file) if FileTest.file?(file) + else + auths = auth + end + + authuserpassword = req["authorization"] + if not authuserpassword.nil? + authtype, userpassword = authuserpassword.split(/ /) + if authtype == "Basic" and not userpassword.nil? + u, p = userpassword.unpack("m").shift.split(/:/) + end + end + + ok = (auths.include?(u) and auths[u] == p) + + if ok + + else + resp["WWW-Authenticate"] = "Basic realm=\"#{realm}\"" + resp.response = "HTTP/1.0 401 Unauthorized" + end + + return ok + end +end diff -ur rubywebdialogs-none.tar.gz/rubywebdialogs/lib/ruby.lib.rb rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/ruby.lib.rb --- rubywebdialogs-none.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2005-06-04 14:41:54.522515784 +0200 +++ rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-04-18 14:20:31.000000000 +0200 @@ -0,0 +1,648 @@ +require "cgi" +require "rbconfig" + +Thread.abort_on_exception = true + +module Enumerable + def deep_dup + Marshal::load(Marshal::dump(dup)) + end + + def deep_clone + Marshal::load(Marshal::dump(clone)) + end +end + +class Object + alias deep_dup :dup + alias deep_clone :clone + + def to_fs + to_s + end +end + +class Numeric + def to_fs + to_f + end +end + +class String + def chomp!(dummy=nil) + self.gsub!(/[\r\n]*\z/, "") + end + + def chomp(dummy=nil) + self.gsub(/[\r\n]*\z/, "") + end + + def crlf + self.gsub(/\r*\n/, "\r\n").gsub(/\r\n\z/, "") + "\r\n" + end + + def strip + self.stripbefore.stripafter + end + + def stripbefore + self.gsub(/\A[[:blank:]\r\n]*/, "") + end + + def stripafter + self.gsub(/[[:blank:]\r\n]*\z/, "") + end + + def compress + self.gsub(/[[:blank:]\r\n]+/, " ").strip + end + + def compressspaces + self.gsub(/[[:blank:]]+/, " ") + end + + def numeric? + d, a, n = [self].to_par + + not n.empty? + end + + def exec(input=nil, output=true) + res = [] + + IO.popen(self, "w+") do |f| + f.puts input if not input.nil? + f.close_write + + res = f.readlines if output + end + + res.join("") + end + + def eval + Kernel::eval(self) + end + + def speak + require "drb" + + DRb.start_service + DRbObject.new(nil, "druby://localhost:3100").speak(self) + end + + def splitblocks(begindelimiters, enddelimiter) + bd = begindelimiters.collect {|s| Regexp.escape(s)} + ed = enddelimiter.collect {|s| Regexp.escape(s)} + + be = bd.join("|") + ee = ed.join("|") + + res = [] + type = 0 + tmp = "" + es = "" + self.split(/(#{be}|#{ee})/).each do |s| + if type == 0 + if begindelimiters.include?(s) + type = begindelimiters.index(s)+1 + tmp = s + es = enddelimiter[begindelimiters.index(s)] + else + #res << [0, s] if not s.compress.empty? + res << [0, s] if not s.empty? + end + else + if s == es + res << [type, tmp + s] + type = 0 + tmp = "" + es = "" + else + tmp = tmp + s + end + end + end + res + end + + def splitwords(tokens=[], begindelimiters=["´", ´"´], enddelimiter=["´", ´"´]) + tokens = [tokens] if not tokens.kind_of?(Array) + res = [] + self.splitblocks(begindelimiters, enddelimiter).each do |type, s| + case type + when 0 + tokens.each do |token| + token2 = token + token2 = Regexp.escape(token2) if token2.kind_of?(String) + s.gsub!(/#{token2}/, " #{token} ") + end + s.split().each do |w| + res << w + end + when 1, 2 + res << s[1..-2] + end + end + res + end + + def uncomment + res = [] + self.splitblocks( ["´" , ´"´ , "/*" , "<!--" , "#" , ";" ], + ["´" , ´"´ , "*/" , "-->" , "\n", "\n"]).each do |type, s| + case type + when 0, 1, 2 then res << s + when 3, 4, 5 + end + end + res.join("") + end + + def noquotes + self.sub(/\A[´"]/, "").sub(/[´"]\z/, "") + end + + def to_html(eolconversion=true) + s = CGI.escapeHTML(self) + + s.gsub!(/\"/, "\"") + s.gsub!(/\´/, "\´") + + if eolconversion + s.gsub!(/\n/ , "<br>") + end + + s + end + + def from_html(eolconversion=true) + s = self + + s.gsub!(/"/ , "\"") + s.gsub!(/´/, "\´") + + s = CGI.unescapeHTML(self) + + if eolconversion + s.gsub!(/<br>/, "\n") + end + + s + end + + def to_fs + if numeric? + to_f + else + to_s + end + end +end + +class Array + def chomp! + self.collect!{|s| s.chomp} + end + + def chomp + self.collect{|s| s.chomp} + end + + def compress + self.collect{|s| s.compress} + end + + def uncomment + self.join("\0").uncomment.split("\0") + end + + def strip + self.collect{|s| s.strip} + end + + def sum + res = 0 + self.each do |n| + res += n + end + res + end + + def product + res = 1 + self.each do |n| + res *= n + end + res + end + + def joinwords(sep=" ", quote=´"´) + self.collect do |s| + s = quote + s + quote if s =~ /[[:blank:]]/ + s + end.join(sep) + end + + def domino(tabellen, kolom=nil, onlymatchinglines=false) + links = self + res = [] + res = self.dup unless onlymatchinglines + + tabellen.each do |rechts| + tmp = [] + + links.each do |l| + if kolom.nil? or l.length == kolom + rechts.each do |r| + tmp << l + r[1..-1] if l[-1] == r[0] + end + end + end + + links = tmp + res.concat(tmp) + end + + res = res.sort.uniq + end + + def dominoloop(tabellen) + lres = [] + res = self.dup + kolom = 2 + + while lres.length != res.length do + lres = res.dup + res = res.domino(tabellen, kolom) + + res.each do |line| + line << "*" if (line.length != line.uniq.length and line[-1] != "*") + end + + $stderr.print "#{100*(res.length)/(lres.length)}% " + + kolom += 1 + end + + $stderr.puts "" + + return res + end + + def buildtree + self.dominoloop([self]) + end + + def subset(fields, values, results, exact=true, emptyline=nil, joinwith=nil) + fields = [fields] if not fields.kind_of? Array + values = [values] if not values.kind_of? Array + results = [results] if not results.kind_of? Array + res = [] + + self.each do |l| + ok = true + + case l.class.to_s + when "String" + c = l.splitwords + correction = 1 + joinwith = " " if joinwith.nil? + when "Array" + c = l + correction = 0 + end + + 0.upto(c.length-1) do |n| + if fields.include?(n+correction) + v = values[fields.index(n+correction)] + if not emptyline.nil? and not v.downcase == emptyline.downcase + if exact + ok = false unless (v.nil? or c[n].downcase == v.downcase) + else + ok = false unless (v.nil? or c[n].downcase.include?(v.downcase)) + end + end + end + end + + if ok + res2 = [] + results.each do |n| + res2 << c[n-1] + end + res2 = res2.join(joinwith) if not joinwith.nil? + res << res2 + end + end + + return res + end + + def format(format) + res = [] + + [format.length, self.length].min.times do |n| + case format[n].chr + when "i" then res << self[n].to_i + when "s" then res << self[n].to_s + when "x" then res << self[n] + end + end + + res + end + + def to_i + collect{|c| c.to_i} + end + + def to_par + dash = self.dup + alpha = self.dup + numeric = self.dup + + dash.delete_if do |s| + not (s =~ /\A-/) or + (s =~ /\A-?[[:digit:]\.]+\z/) or + (s =~ /^-+$/) + end + + alpha.delete_if do |s| + ((s =~ /\A-/) or + (s =~ /\A-?[[:digit:]\.]+\z/)) and + not ((s =~ /^\.+$/) or (s =~ /^-+$/)) + end + + numeric.delete_if do |s| + not (s =~ /\A-?[[:digit:]\.]+\z/) or + (s =~ /^\.+$/) + end + + raise "Oops!" if dash.length + alpha.length + numeric.length != length + + return dash, alpha, numeric + end + + def self.file(file) + res = [] + + File.new(file).readlines.uncomment.chomp.each do |line| + res << line + end + + res + end + + def numsort + sort do |a, b| + a2 = a.to_fs + b2 = b.to_fs + + if a2.class != b2.class + a2 = a + b2 = b + end + + a2 <=> b2 + end + end + + def to_fs + collect{|s| s.to_fs} + end + + def chaos + res = self.dup + + (length^2).times do + a = rand(length) + b = rand(length) + + res[a], res[b] = res[b], res[a] + end + + res + end + + def minmax + min, value, max = self + [min, [value, max].min].max + end +end + +class Hash + def save(file, append=false) + org = {} + org = Hash.file(file) if (append and File.file?(file)) + + self.sort.each do |k, v| + org[k] = v + end + + File.open(file, "w") do |f| + org.sort.each do |k, v| + #f.puts "´%s´=´%s´" % [k, v] + f.puts "%s = %s" % [k, v] + end + end + end + + def subset(fields, values, results=nil, exact=true, emptyline=nil, joinwith=nil) + fields = [fields] if not fields.kind_of? Array + values = [values] if not values.kind_of? Array + results = [results] if not results.kind_of? Array + res = self.dup + res.delete_if {true} + + self.each do |k, l| + ok = true + + case l.class.to_s + when "String" + c = l.splitwords + correction = 1 + joinwith = " " if joinwith.nil? + when "Array" + c = l + correction = 0 + end + + 0.upto(c.length-1) do |n| + if fields.include?(n+correction) + v = values[fields.index(n+correction)] + if emptyline.nil? or (not emptyline.nil? and not v.downcase == emptyline.downcase) + if exact + ok = false unless (v.nil? or c[n].downcase == v.downcase) + else + ok = false unless (v.nil? or c[n].downcase.include?(v.downcase)) + end + end + end + end + + if ok + res2 = [] + if results == [nil] + res2 = c + else + results.each do |n| + res2 << c[n-correction] + end + end + res2 = res2.join(joinwith) if not joinwith.nil? + res[k] = res2 + end + end + + return res + end + + def to_i + collect{|k, v| v.to_i} + end + + def self.file(file) + res = {} + + File.new(file).readlines.chomp.each do |line| + if not line.compress.empty? + k, v = line.split(/\s*=\s*/, 2) + res[k] = v + end + end +# File.new(file).readlines.uncomment.chomp.each do |line| +# if not line.compress.empty? +# a = line.splitwords("=") +# +# if a.size == 3 and a[1] == "=" +# res[a[0]] = a[2] +# else +# puts "Error in #{file} (not ´var=\"value\"´)." +# end +# end +# end + + res + end +end + +class Dir + def Dir.mkdirrec(dir) + pdir = File.dirname(dir) + + if not pdir.empty? and not FileTest.directory?(pdir) + mkdirrec (pdir) + end + + Dir.mkdir(dir) rescue nil + end +end + +def id2ref(id) + ObjectSpace._id2ref(id) +end + +def after(seconds) + if not seconds.nil? and not seconds.zero? + Thread.new do + sleep seconds + yield + end + end +end + +def every(seconds) + if not seconds.nil? and not seconds.zero? + Thread.new do + loop do + sleep seconds + yield + end + end + end +end + +def evtimeout(seconds) + if not seconds.nil? and not seconds.zero? + t = Thread.current + threads = [] + res = nil + + threads[1] = Thread.new do + sleep seconds + begin + threads[2].kill + rescue NameError + end + res = false + t.wakeup + end + + threads[2] = Thread.new do + yield + begin + threads[1].kill + rescue NameError + end + res = true + t.wakeup + end + + threads[1].join + threads[2].join + + return res + else + yield + end +end + +def evtimeoutretry(seconds) + ok = false + + while not ok + evtimeout(seconds) do + yield + ok = true + end + end +end + +def trap(signal) + Kernel::trap(signal) do + yield + end + + # Seems pointless, but it´s for catching ^C under Windows... + + every(1) {} +end + +def linux? + not windows? and not cygwin? +end + +def windows? + not (target_os.downcase =~ /32/).nil? +end + +def cygwin? + not (target_os.downcase =~ /cyg/).nil? +end + +def target_os + Config::CONFIG["target_os"] or "" +end + +def user + ENV["USER"] or ENV["USERNAME"] +end + +def home + (ENV["HOME"] or ENV["USERPROFILE"] or (File.directory?("h:/") ? "h:" : "c:")).gsub(/\\/, "/") +end + +def temp + (ENV["TEMP"] or "/tmp").gsub(/\\/, "/") +end diff -ur rubywebdialogs-none.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-none.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2005-06-04 14:41:54.520516088 +0200 +++ rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-18 14:20:31.000000000 +0200 @@ -0,0 +1,1320 @@ +require "ev/xml" +require "ev/net" +require "md5" +require "rbconfig" +require "pstore" + +begin + require "win32ole" + require "win32/registry" +rescue LoadError + $".push "win32ole.rb" + $".push "win32/registry.rb" +end + +exit if ARGV.include?("--rwd-exit") + +Debug = false +Border = 0 +RWDEmptyline = "..." + +rcfile = nil +s = ENV["HOME"] ; s = s + "/.rwdrc" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and FileTest.file?(s)) +s = ENV["USERPROFILE"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and FileTest.file?(s)) +s = ENV["windir"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and FileTest.file?(s)) + +AL = "align=´left´" +AC = "align=´center´" +AR = "align=´right´" +VA = "valign=´middle´" + +Format = "\n<!-- %-10s %-10s -->\t" + +if not rcfile.nil? + puts "Reading #{rcfile} ..." + + Hash.file(rcfile).each do |k, v| + ENV[k] = v + end +else + begin + puts "Looking for default browser..." + ENV["RWDBROWSER"] = Win32::Registry::HKEY_CLASSES_ROOT.open(´htmlfile\shell\open\command´)[0] + rescue + puts "Not found." + end + + if not ENV.include?("RWDBROWSER") and false # ??? + s = ENV["HOME"] ; s = s + "/.rwdrc" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil?) + s = ENV["USERPROFILE"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil?) + s = ENV["windir"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil?) + + if not rcfile.nil? + puts "Creating #{rcfile} ..." + puts "" + puts "# This is the first time you start a RubyWebDialog application." + puts "# I have to know your favorite browser." + puts "# " + puts "# Put the full path to your favorite browser between the quotes" + puts "# (\"...\") after RWDBROWSER= and remove the hash (#) at the" + puts "# beginning of the line." + puts "# " + puts "# Restart your application." + puts "" + + File.open(rcfile, "a") do |f| + f.puts "# This is the first time you start a RubyWebDialog application." + f.puts "# I have to know your favorite browser." + f.puts "# " + f.puts "# Put the full path to your favorite browser between the quotes" + f.puts "# (\"...\") after RWDBROWSER= and remove the hash (#) at the" + f.puts "# beginning of the line." + f.puts "# " + f.puts "# Restart your application." + f.puts "" + f.puts "#RWDBROWSER=\"...\"" + end + end + + if windows? + system("notepad #{rcfile}") + + sleep 1 + else + puts "Please edit #{rcfile}." + end + + exit + end +end + +trap("INT") {puts "Terminating..." ; exit} + +$SAFE = 2 + +class IE + def initialize(url) + @ie = WIN32OLE.new("InternetExplorer.Application") + @ev = WIN32OLE_EVENT.new(@ie, "DWebBrowserEvents2") + + @ie.navigate(url) + + @ie.menubar = false + @ie.toolbar = false + @ie.addressbar = false + @ie.statusbar = false + + @ie.visible = true + + at_exit do + @ie.visible = false + end + + @ev.on_event("OnQuit") do + Thread.main.exit + end + + Thread.new do + loop do + WIN32OLE_EVENT.message_loop + end + end + end +end + +class Array + def rwd_options(emptyline=nil) + if emptyline.nil? + a = self + else + a = [emptyline].concat self + end + + a.numsort.collect{|s| "<option>#{s.to_html}</option>" }.join("\n") + end + + def rwd_method(method) + res = "" + + self.each do |s| + s = s.join("/") if s.kind_of?(Array) + s2 = s.dup + s2[0..0] = s2[0..0].upcase + res = res + "<p align=´left´><a action=´#{method}/#{s.to_html}´>#{s2.to_html}</a></p>" + end + + return res + end + + def rwd_row(key=nil, value=nil) + res = "" + + res = res + "<row valign=´top´>" + res = res + "<radio name=´#{key.to_html}´ value=´#{value.to_html}´/>" if not key.nil? + res = res + self.collect{|s| "<p align=´left´>#{s.to_html}</p>"}.join("") + res = res + "</row>" + + return res + end + + def rwd_headers(emptyfield=false) + res = "" + + res = res + "<row>" + res = res + "<p/>" if emptyfield + res = res + self.collect{|s| "<p align=´left´><b>#{s.to_html}</b></p>" }.join("") + res = res + "</row>" + + return res + end + + def rwd_form(prefix, values, twoparts=0, options={}) + res = [] + + res << "<table>" + self.each_index do |n| + name = "#{prefix.to_html}#{self[n].downcase.to_html}" + + res << "<row>" + res << "<p align=´right´>" + res << "#{self[n].to_html}:" + res << "</p>" + + if options.keys.include?(self[n]) + res << "<select name=´#{name}´>" + res << options[self[n]].rwd_options(RWDEmptyline) + res << "</select>" + else + s = "" + + s << "<text name=´#{name}´" + s << " value=´#{values[n].to_html}´" if n < values.length + s << "/>" + + res << s + end + + res << "</row>" + + if twoparts > 0 and n == twoparts-1 + res << "<row><empty/></row>" + end + end + res << "</table>" + + return res.join("\n") + end +end + +class Hash + def rwd_table(field, joinwith=@sep, headers=nil) + res = [] + + res << "<table>" + res << headers.rwd_headers(true) if not headers.nil? + self.keys.numsort.each do |key| + key2 = key + value2 = self[key] + + key2 = key2.join(joinwith) if key2.kind_of?(Array) + value2 = [value2] if value2.kind_of?(String) + + res << value2.rwd_row(field, key2) + end + res << "</table>" + + res.join("\n") + end +end + +class EVTable + def rwd_table(key, joinwith) + super(key, joinwith, @headers) + end + + def rwd_form(prefix="", key=nil, twoparts=false) + values = self[key] if not key.nil? + values = [] if values.nil? + options = {} + + if File.file?(oldlocation("constraints.csv")) + table = File.basename(@file).gsub(/\.csv$/, "") + + CSVFile.new(oldlocation("constraints.csv")).subset(["Table", "Constraint"], [table, "key"], ["Column", "Value"]).values.each do |column, table2| + options[column] = CSVFile.new(oldlocation("#{table2}.csv")).keys.collect{|a| a.join("\t")} + end + end + + @headers.rwd_form(prefix, values, twoparts ? @key : 0, options) + end + + def rwd_metadata + res = [] + + res << "<table>" + res << "<row>" + res << " <empty/>" + res << " <text name=´header_new´ value=´´/>" + res << "</row>" + @headers.each_index do |n| + res << "<row>" + res << " <text name=´header_#{n}_old´ value=´#{@headers[n]}´/>" + res << " <text name=´header_#{n}_new´ value=´´/>" + res << "</row>" + end + res << "</table>" + + return res.join("\n") + end +end + +class OpenTag + def prechildren(res, before, after, vars, switches, help, firstaction, tabs, tab) + bef = before[-1] + res.concat Format % ["Before", @subtype] if (Debug and not bef.nil?) + res.concat bef if not bef.nil? + + res.concat Format % ["Pre", @subtype] if Debug + + align = AC + align = "align=´#{@args["align"]}´" if @args.include?("align") + + valign = VA + valign = "valign=´#{@args["valign"]}´" if @args.include?("valign") + + value = "" + value = vars[@args["name"]] if vars.include?(@args["name"]) + value = @args["value"] if @args.include?("value") + + case @subtype + when "application" + when "window", "helpwindow" + args = @args.deep_dup + + args["nohelpbutton"] = (not help) + + res.concat(template(RWD_HTML1, args)) + when "p" then res.concat "<p #{align}>" + when "pre" then res.concat "<pre>" + when "big" then res.concat "<p #{align}><big>" + when "small" then res.concat "<p #{align}><small>" + when "list" then res.concat "<ul #{align}>" + when "item" then res.concat "<li #{align}>" + when "empty" then res.concat "<p><br>" + when "image" then res.concat "<img src=´#{@args["src"]}´>" + when "br" then res.concat "<br>" + when "hr" then res.concat "<hr>" + when "b" then res.concat "<b>" + when "i" then res.concat "<i>" + when "a" + if @args.include?("href") + res.concat "<a href=´#{@args["href"]}´ target=´#{@args["target"] or "new"}´>" + else + res.concat "<a href=´javascript:document.bodyform.rwd_action.value=\"#{@args["action"]}\";document.bodyform.submit();´>" + end + when "vertical" then res.concat "<table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´>" + when "horizontal" then res.concat "<table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´><tr #{align} #{valign}>" + when "table" then res.concat "<table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´>" + when "row" then res.concat "<tr #{align} #{valign}>" + when "hidden" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´hidden´>" + when "text" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´text´>" + when "textarea" then res.concat "<p #{align}><textarea name=´#{@args["name"]}´>#{value}</textarea>" + when "password" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´password´>" + when "checkbox" + if vars[@args["name"]] == "on" + switches[@args["name"]] = true + res.concat "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ type=´checkbox´>" + else + switches[@args["name"]] = false + res.concat "<p #{align}><input name=´#{@args["name"]}´ type=´checkbox´>" + end + when "radio" + if vars[@args["name"]] == value + res.concat "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ value=´#{value}´ type=´radio´>" + else + res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´radio´>" + end + when "select" + res.concat "<select #{align} name=´#{@args["name"]}´ width=´#{@args["width"]}´>" + name = @args["name"] + $select = vars[name] + when "option" + if $select == @children[0].text + res.concat "<option selected=´true´>" + else + res.concat "<option>" + end + when "button" + res.concat "<input type=´submit´ value=´#{@args["caption"]}´ onclick=´document.bodyform.rwd_action.value=\"#{@args["action"]}\";´>" + firstaction << @args["action"] if (firstaction.empty? and @args.include?("action")) + when "back" + res.concat "<input type=´submit´ value=´Back´ onclick=´document.bodyform.rwd_action.value=\"rwd_back\";´>" + firstaction << "rwd_back" if firstaction.empty? + when "help" + res.concat "<input type=´submit´ value=´Help´ onclick=´document.bodyform.rwd_action.value=\"rwd_help\";´>" + firstaction << "rwd_help" if firstaction.empty? + when "quit" + res.concat "<input type=´submit´ value=´Quit´ onclick=´document.bodyform.rwd_action.value=\"rwd_quit\";´>" + firstaction << "rwd_quit" if firstaction.empty? + when "close" + res.concat "<input type=´submit´ value=´Close´ onclick=´window.close();´>" + firstaction << "rwd_quit" if firstaction.empty? + when "reset" + res.concat "<input type=´reset´ value=´Reset´>" + firstaction << "rwd_quit" if firstaction.empty? + when "closewindow" + #res.concat "<script type=´text/javascript´>\n" + #res.concat "<!--\n" + #res.concat " window.close();\n" + #res.concat "//-->\n" + #res.concat "</script>" + when "tabs" + res.concat "<table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´>" + res.concat " <tr #{AC}>" + res.concat " <td #{AC}>" + res.concat " <table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´>" + res.concat " <tr #{AC}>" + tabs.each do |obj| + caption = obj.args["caption"] + if caption == tab + res.concat "<td #{AC}><div class=´box´><tt><b> #{caption} </b></tt></div></td>" + else + res.concat "<td #{AC}><div class=´box´><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_tab_#{caption}\";document.bodyform.submit();´><tt> #{caption} </tt></a></div></td>" + end + end + res.concat " </tr>" + res.concat " </table>" + res.concat " </td>" + res.concat " </tr>" + when "tab" + res.concat "<tr #{align} #{valign}><td #{align}><div class=´box2´>" + else + puts "<#{@subtype}>" + res.concat "<#{@subtype}>" + end + + bef = nil + aft = nil + + case @subtype + when "vertical", "window", "helpwindow" + res.concat Format % ["AftPre", @subtype] if Debug + if @args.include?("spacing") + s = "<tr><td> </td></tr>" * (@args["spacing"].to_i) + else + s = "" + end + bef = "#{s}<tr #{align} #{valign}><td #{align}>" + aft = "</td></tr>" + when "horizontal", "row" + res.concat Format % ["AftPre", @subtype] if Debug + bef = "<td #{align}>" + aft = "</td>" + end + + before.push(bef) + after.push(aft) + end + + def postchildren(res, before, after, vars, switches, help, firstaction, tabs, tab) + case @subtype + when "vertical", "window", "helpwindow" + res.concat Format % ["BefPost", @subtype] if Debug + if @args.include?("spacing") + res.concat "<tr><td> </td></tr>" * (@args["spacing"].to_i) + end + when "horizontal", "row" + res.concat Format % ["BefPost", @subtype] if Debug + end + + res.concat Format % ["Post", @subtype] if Debug + + case @subtype + when "application" + when "window", "helpwindow" + args = @args.deep_dup + + args["nohelpbutton"] = (not help) + + res.concat(template(RWD_HTML2, args)) + when "p" then res.concat "</p>" + when "pre" then res.concat "</pre>" + when "big" then res.concat "</big></p>" + when "small" then res.concat "</small></p>" + when "list" then res.concat "</ul>" + when "item" then res.concat "</li>" + when "empty" then res.concat "</p>" + when "image" then res.concat "" + when "br" then res.concat "" + when "hr" then res.concat "" + when "b" then res.concat "</b>" + when "i" then res.concat "</i>" + when "a" then res.concat "</a>" + when "vertical" then res.concat "</table>" + when "horizontal" then res.concat "</tr></table>" + when "table" then res.concat "</table>" + when "row" then res.concat "</tr>" + when "hidden" then res.concat "</p>" + when "text" then res.concat "</p>" + when "textarea" then res.concat "</p>" + when "password" then res.concat "</p>" + when "checkbox" then res.concat "</p>" + when "radio" then res.concat "</p>" + when "select" + res.concat "</select>" + $select = nil + when "option" then res.concat "</option>" + when "button" then res.concat "" + when "back" then res.concat "" + when "help" then res.concat "" + when "quit" then res.concat "" + when "close" then res.concat "" + when "reset" then res.concat "" + when "closewindow" then res.concat "" + when "tabs" then res.concat "</table>" + when "tab" then res.concat "</div></td></tr>" + else + puts "</#{@subtype}>" + res.concat "</#{@subtype}>" + end + + before.pop + after.pop + + aft = after[-1] + res.concat Format % ["After", @subtype] if (Debug and not aft.nil?) + res.concat aft if not aft.nil? + end + + def template(html, vars) + res = [] + + a = {} + + vars.each do |k, v| + a[k.upcase] = v + end + + a["LOGO"] = "" unless ((not vars["logo"].nil?) and FileTest.file?(vars["logo"])) + + a["HELPBUTTON"] = (not (vars["nohelpbutton"])) + a["BACKBUTTONS"] = (not (vars["nobackbuttons"])) + a["BACKBUTTONS"] = (not (vars["nobackbuttons"])) + a["CLOSEBUTTON"] = (not (vars["noclosebutton"])) + + html.split(/\r*\n/).each do |line| + if line =~ /%[A-Z]+%/ + a.each do |k, v| + v = false if (v.kind_of?(String) and v.empty?) + + if line.include?("%#{k}%") + line.gsub!("%#{k}%", "#{v}") if v + end + end + + line = "<!-- #{line.scan(/%[A-Z]+%/).join(" ")} -->" if line =~ /%[A-Z]+%/ + end + + res << line + end + + res.join("\n") + end +end + +class Text + def prechildren(res, before, after, vars, switches, help, firstaction, tabs, tab) + if not @text.scan(/[^ \t\r\n]/).empty? + res.concat Format % ["Text", ""] if Debug + res.concat "#{@text}" + end + end +end + +class RWDTree < XML +end + +class RWDWindow + @@windows = {} # Kind of caching. + @@helpwindows = {} # Kind of caching. + + def initialize(rwd, window=nil) + rwd = rwd.join("\n") if rwd.kind_of?(Array) + + if @@windows[rwd].nil? + @@windows[rwd] = {} + @@helpwindows[rwd] = {} + + tree = XML.new(rwd) + + tree.parse(OpenTag, "window") do |type, obj| + @@windows[rwd][obj.args["name"]] = obj.to_h + end + + tree.parse(OpenTag, "helpwindow") do |type, obj| + @@helpwindows[rwd][obj.args["name"]] = obj.to_h + end + end + + @rwd = (@@windows[rwd][window] or "").dup + @helprwd = (@@helpwindows[rwd][window] or "").dup + end + + def render(vars=Hash.new, switches=Hash.new, help=false, tab="") + vars2 = Hash.new + firstaction = "" + html = "" + + vars.each do |key, value| + if not key.empty? + if value.respond_to? "to_s" + @rwd.gsub!(/%%#{key}%%/, value.to_s) + @rwd.gsub!(/%#{key}%/, value.to_s.to_html) + + @helprwd.gsub!(/%%#{key}%%/, value.to_s) + @helprwd.gsub!(/%#{key}%/, value.to_s.to_html) + + vars2[key] = value.to_s.to_html + end + end + end + + windowobject = RWDTree.new(@rwd).children.dup.delete_if{|obj| obj.subtype != "window"}[0] + helpobject = RWDTree.new(@helprwd).children.dup.delete_if{|obj| obj.subtype != "helpwindow"}[0] + + tabsobj = windowobject.children.dup.delete_if{|obj| obj.subtype != "tabs"}[0] + + if not tabsobj.nil? + tabs = tabsobj.children.dup.delete_if{|obj| (not obj.kind_of?(OpenTag)) or (obj.subtype != "tab")} + + if tab.empty? + tab = tabs[0].args["caption"] + end + + tabsobj.children.delete_if{|obj| (obj.kind_of?(OpenTag)) and (obj.subtype == "tab") and obj.args["caption"] != tab} + end + + if help + helpobject.parsetree("prechildren", "postchildren", html, [""], [""], vars2, switches, false, firstaction, tabs, tab) + else + windowobject.parsetree("prechildren", "postchildren", html, [""], [""], vars2, switches, (not @helprwd.empty?), firstaction, tabs, tab) + end + + html.gsub!(/%%*[[:alnum:]_\-]+%%*/, "") if not Debug + html.gsub!(/%%/, "%") + html.gsub!(/\n\n*/, "\n") + + if firstaction.empty? + focus = "" + else + focus = "document.bodyform.elements[0].focus();" + end + + html.gsub!(/\$RWD_FIRSTACTION\$/ , firstaction) + html.gsub!(/\$RWD_FOCUS\$/ , focus) + + html + end +end + +class RWDMessage < RWDWindow + def initialize(msg) + super("<window title=´RWD Message´ nobackbuttons><vertical><p><b>Message:</b> #{msg}</p><back/></vertical></window>") + end +end + +class RWDError < RWDWindow + def initialize(msg) + super("<window title=´RWD Error´ nobackbuttons><vertical><p><b>Error:</b> #{msg}</p><back/></vertical></window>") + end +end + +class RWDDone < RWDWindow + def initialize(exitbrowser) + super("<window title=´RWD Message´ nobackbuttons noclosebutton><p>Done.</p><horizontal><close/>#{exitbrowser ? "" : "<button caption=´Login´/>"}</horizontal>#{exitbrowser ? "<closewindow/>" : ""}</window>") + end +end + +class RWDialog + def initialize(xml) + @rwd_xml = xml + @rwd_exitbrowser = false + @rwd_history = [] + @rwd_clone_vars = ["@rwd_history"] + @rwd_ignore_vars = ["@rwd_server"] + end + + def self.file(rwdfile, *args) + new(File.new(rwdfile).readlines, *args) + end + + def serve(port=1234, auth=nil, realm=self.class.to_s) + raise "RWD is not initialized." if @rwd_xml.nil? + + @rwd_server = RWDServer.new(self, port, auth, realm) + end + + def render(res, path, post, sessionid) + + # Initialize some vars. + + vars = Hash.new if vars.nil? + @rwd_switches = Hash.new if @rwd_switches.nil? + + done = false + help = false + back = false + tab = "" + @rwd_msg = nil + + # Switches are used for checkboxes. + + @rwd_switches.each do |key, value| + vars[key] = "off" + end + + @rwd_switches = Hash.new + + # Copy the vars from the window to vars. vars wil later on be copied to instance variables. + + post.sort.each do |key, value| + puts "Post: #{key} -> #{value.from_html.inspect}" if Debug + + vars[key] = value.from_html + end + + # Stack handling for rwd_action and rwd_window. + + @rwd_action = vars["rwd_action"] + @rwd_action, @rwd_args = @rwd_action.split(/\//, 2) unless @rwd_action.nil? + + if @rwd_action =~ /^rwd_tab_/ + tab = @rwd_action.sub(/^rwd_tab_/, "") + else + case @rwd_action + when "rwd_back" + @rwd_history.pop + @rwd_action = (@rwd_history[-1] or [nil, nil])[0] + @rwd_window = (@rwd_history[-1] or [nil, nil])[1] + back = true + when "rwd_help" + help = true + when "rwd_main" + @rwd_window = "main" + @rwd_action = "main" + @rwd_history = [] + when "rwd_quit" + done = true + end + + # History stuff + + @rwd_history = @rwd_history[-100..-1] if @rwd_history.length >= 100 + @rwd_action = "main" if @rwd_action.nil? + @rwd_action = "main" if @rwd_action.empty? + @rwd_args = [] if @rwd_args.nil? + @rwd_window = "main" if @rwd_window.nil? + + vars["rwd_action"] = @rwd_action + vars["rwd_window"] = @rwd_window + + # Copy vars from window to instance. + + vars.each do |k, v| + instance_eval "@#{k} = vars[´#{k}´]" if ((not k.empty?) and k.scan(/^rwd_/).empty? and not @rwd_ignore_vars.include?("@#{k}")) + end + + # Callback. + + if not back + begin + puts "Method: #{@rwd_action}(#{@rwdargs.join(", ")})" if Debug + method(@rwd_action).call(*@rwd_args) + rescue NameError + end + + # History stuff + + @rwd_history = [["main", "main"]] if @rwd_action == "main" + @rwd_history = [["main", "main"]] if @rwd_history.empty? + @rwd_history.push [@rwd_action, @rwd_window] if (@rwd_history[-1] != [@rwd_action, @rwd_window] or not @rwd_msg.nil?) + end + end + + # Copy vars from instance to window. + + instance_variables.each do |k| + k.sub!(/^@/, "") + instance_eval "vars[´#{k}´] = @#{k}.to_s" if (k.scan(/^rwd_/).empty? and not @rwd_ignore_vars.include?("@#{k}")) + end + + # just ignore. + + vars.sort.each do |key, value| + puts "Pre: #{key} -> #{value.inspect}" if Debug + end + + # Answer to browser. + + if done + res << RWDDone.new(@rwd_exitbrowser).render + else + if not @rwd_msg.nil? + res << RWDMessage.new(@rwd_msg).render if @rwd_msgtype == "message" + res << RWDError.new(@rwd_msg).render if @rwd_msgtype == "error" + else + puts "Window: #{@rwd_window}" if Debug + res << RWDWindow.new(@rwd_xml, @rwd_window).render(vars, @rwd_switches, help, tab) + end + end + + return done + end + + def samewindow? + @rwd_history[-1][1] == @rwd_window + end + + def message(msg) + @rwd_msg = msg + @rwd_msgtype = "message" + end + + def error(msg) + @rwd_msg = msg + @rwd_msgtype = "error" + end + + def clone + @rwd_history = [] + + @rwd_clone_vars.each do |var| + instance_eval "#{var} = #{var}.clone" + end + + super + end + + def exitbrowser + @rwd_exitbrowser = true + end +end + +class RWDLogin < RWDialog + def initialize(realm) + super("<window name=´main´ title=´RWD Login for #{realm}´ nobackbuttons noclosebutton><table><row><p align=´right´>Username:</p><text name=´rwd_a´/></row><row><p align=´right´>Password:</p><password name=´rwd_b´/></row></table><button caption=´Login´/></window>") + end +end + +class RWDTimeOut < RWDialog + def initialize + super("<window name=´main´ title=´RWD Error´ nobackbuttons noclosebutton><p><b>Error:</b> Session has expired.</p><button caption=´New session´/></window>") + end +end + +class SessionCleanup + def initialize(sessions, interval, timeout) + every(interval) do + sessions.delete_if do |id, session| + time = Time.now.to_i - session.lastaccess.to_i + + puts "Session %s deleted" % id if time > timeout + + time > timeout + end + end + end +end + +class Sessions + def initialize(rack, cleanup) + @rack = rack.to_s + @cleanup = SessionCleanup.new(self, 3600, 24*3600) if cleanup + @sessions = {} + #@store = PStore.new("#{temp}/store.#{@rack}.#{user}") + + #@store.transaction do + #@store[@rack] = {} if not @store.root?(@rack) + #@sessions = @store[@rack] + #end + + #at_exit do + #@store.transaction do + #@store[@rack] = @sessions + #end + #end + end + + def [](sessionid) + @sessions[sessionid] + end + + def []=(sessionid, value) + @sessions[sessionid] = value + end + + def delete(sessionid) + @sessions.delete(sessionid) + end + + def delete_if(&block) + @sessions.delete_if{|k, v| block.call(k, v)} + end +end + +class Session < Hash + attr_reader :sessionid + attr_reader :lastaccess + attr_reader :authenticated + attr_writer :authenticated + + def initialize(sessionid=nil) + @sessionid = sessionid + @lastaccess = Time.now + @authenticated = false + end + + def touch + @lastaccess = Time.now + end +end + +class RWDSession < Session + def render(res, path, post) + done = self["object"].render(res, path, post, @sessionid) + + if done + res.gsub!(/\$RWD_SESSION\$/, "") + else + res.gsub!(/\$RWD_SESSION\$/, "#{@sessionid}") + end + + done + end +end + +class RWDServer + def initialize(obj, port, auth, realm) + @object = obj + @localbrowsing = false + @browserstarted = false + @sessions = Sessions.new(obj.class, (not auth.nil?)) + + if auth.nil? + @localbrowsing = true + + if ENV.include?("RWDBROWSER") + @browserstarted = true + @object.exitbrowser + + # Start browser. + + @browserthread = Thread.new do + puts "Starting the browser..." + + #if ENV["RWDBROWSER"].downcase =~ /iexplore/ + #@ie = IE.new("http://localhost:#{port}/") + #else + if windows? + system("#{ENV["RWDBROWSER"]} \"http://localhost:#{port}/\"") + elsif cygwin? + system("#{ENV["RWDBROWSER"].gsub(/\\/, "/").gsub(/ /, "\ ")} \"http://localhost:#{port}/\"") + else + system("#{ENV["RWDBROWSER"]} \"http://localhost:#{port}/\"") + end + #end + + puts "The browser has terminated." + end + end + end + + # Start server. + + catch :exit do + HTTPServer.serve(port, (not auth.nil?)) do |req, resp| + vars = req.vars.dup + + if auth.kind_of? String + file = "#{home}/#{auth}" + auths = {} + auths = Hash.file(file) if FileTest.file?(file) + else + auths = auth + end + + oldsessionid = vars["rwd_session"] + + # Retrieve session. + + session = @sessions[oldsessionid] + + # Eventually create new session. + + if session.nil? + if auth.nil? + session = RWDSession.new(MD5.new(req.peeraddr[3].to_s + @object.inspect.to_s).to_s) + session["object"] = @object + else + session = RWDSession.new(MD5.new(Time.new.to_s + req.peeraddr[3].to_s + @object.inspect.to_s).to_s) + session["object"] = @object.clone + end + + if oldsessionid.nil? or oldsessionid.empty? + if not auth.nil? and not session.authenticated + + # Check authentication + + us = vars["rwd_a"] + pa = vars["rwd_b"] + + if us.nil? or pa.nil? or auths[us] != pa + session = RWDSession.new + session["object"] = RWDLogin.new(realm) + else + session.authenticated = true + @sessions[session.sessionid] = session + end + else + @sessions[session.sessionid] = session + end + else + session = RWDSession.new + session["object"] = RWDTimeOut.new + end + + vars = {} + end + + # Avoid timeout. + + session.touch + + if req.request.path == "/" + + # Serve methods/callbacks. + + # Build new page. + + res = "" + + done = session.render(res, req.request.path, vars) + + begin + resp["Content-Type"] = "text/html" + + resp << res + rescue + puts "Sending response to browser failed." + + @sessions.delete(session.sessionid) + end + + # Eventually delete this session. + + if done + @sessions.delete(session.sessionid) + + if @localbrowsing + resp.flush + + if @browserstarted and @browserthread.alive? + puts "Waiting for the browser to terminate..." + + @browserthread.join + end + + throw :exit + end + end + + else + + # Serve files. + + if req.request.path == "/pixel.gif" + resp << RWD_Pixel + else + if (FileTest.file?(req.request.path.sub(/^\/*/, ""))) + resp << File.new(req.request.path.sub(/^\/*/, ""), "rb").read rescue nil + else + resp.response = "HTTP/1.0 404 NOT FOUND" + end + end + + end + end + end + end +end + +RWD_HTML = " +<!-- Generated by RubyWebDialog. --> +<!-- For more information, please contact Erik Veenstra <rwd@erikveen.dds.nl>. --> +<html> + <head> + <title>%TITLE%</title> + + <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> + <meta http-equiv=´Content-Style-Type´ content=´text/css´> + + <link rel=´shortcut icon´ href=´%LOGO%´> + + <style type=´text/css´> + <!-- + a { text-decoration : none } + div.box { border : thin solid #AAAAAA } + div.box2 { border-top : thin solid #AAAAAA } + //--> + </style> + + <script type=´text/javascript´> + <!-- + function BodyGo() { + $RWD_FOCUS$ + } + //--> + </script> + </head> + + <body onload=´BodyGo()´ link=´#000000´ vlink=´#000000´ alink=´#000000´> + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´ width=´100%´ height=´100%´> + <tr align=´center´ valign=´middle´> + <td align=´center´> + + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + + <td align=´center´> + + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´> + <tr align=´center´> + <td align=´center´ bgcolor=´#444488´> + + <table align=´left´ border=´0´ cellspacing=´1´ cellpadding=´0´> + <tr align=´center´> + <td align=´border´><img src=´%LOGO%´ width=´14´ height=´14´></td> + <td align=´center´><b><small><font color=´#FFFFFF´> %TITLE% </font></small></b></td> + </tr> + </table> + + <table align=´right´ border=´0´ cellspacing=´1´ cellpadding=´0´> + <tr align=´center´> + <!-- %HELPBUTTON% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_help\";document.bodyform.submit();´> ? </a></small></b></td> + <!-- %BACKBUTTONS% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_main\";document.bodyform.submit();´> << </a></small></b></td> + <!-- %BACKBUTTONS% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_back\";document.bodyform.submit();´> < </a></small></b></td> + <!-- %CLOSEBUTTON% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_quit\";document.bodyform.submit();´> X </a></small></b></td> + </tr> + </table> + + </td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´#CCCCCC´> + <form name=´bodyform´ action=´/´ method=´post´> + + <table align=´center´ border=´0´ cellspacing=´3´ cellpadding=´0´> + + %BODY% + + </table> + + <input name=´rwd_action´ value=´$RWD_FIRSTACTION$´ type=´hidden´> + <input name=´rwd_session´ value=´$RWD_SESSION$´ type=´hidden´> + </form> + </td> + </tr> + </table> + + </td> + + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + </table> + + </td> + </tr> + </table> + </body> +</html> +" + +RWD_Pixel = " +R0lGODlhAQABAOcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoK +CgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZ +GRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygo +KCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3 +Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZG +RkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVV +VVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2Rk +ZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNz +c3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKC +goODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouLi4yMjI2NjY6Ojo+Pj5CQkJGR +kZKSkpOTk5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2dnZ6enp+fn6Cg +oKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+v +r7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7i4uLm5ubq6uru7u7y8vL29vb6+ +vr+/v8DAwMHBwcLCwsPDw8TExMXFxcbGxsfHx8jIyMnJycrKysvLy8zMzM3N +zc7Ozs/Pz9DQ0NHR0dLS0tPT09TU1NXV1dbW1tfX19jY2NnZ2dra2tvb29zc +3N3d3d7e3t/f3+Dg4OHh4eLi4uPj4+Tk5OXl5ebm5ufn5+jo6Onp6erq6uvr +6+zs7O3t7e7u7u/v7/Dw8PHx8fLy8vPz8/T09PX19fb29vf39/j4+Pn5+fr6 ++vv7+/z8/P39/f7+/v///yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh+QQB +CgD/ACwAAAAAAQABAAAIBAD/BQQAOw== +".unpack("m").shift + +RWD_HTML1, RWD_HTML2 = RWD_HTML.split(/^\s*%BODY%\s*\r*$/) diff -ur rubywebdialogs-none.tar.gz/rubywebdialogs/lib/sgml.lib.rb rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/sgml.lib.rb --- rubywebdialogs-none.tar.gz/rubywebdialogs/lib/sgml.lib.rb 2005-06-04 14:41:54.523515632 +0200 +++ rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/sgml.lib.rb 2004-04-18 14:20:31.000000000 +0200 @@ -0,0 +1,234 @@ +require "ev/tree" + +class SGMLObject < TreeObject + def to_s + res = "" + + parsetree("prechildren_to_s", "postchildren_to_s", res) + + res + end + + def to_h + res = "" + + parsetree("prechildren_to_sgml", "postchildren_to_sgml", res) + + res + end +end + +class Text < SGMLObject + def initialize(text) + super() + @text = text + end + + def prechildren_to_s(res) + res << "#{@text}" + end + + def prechildren_to_sgml(res) + res << "#{@text}" + end +end + +class Comment < SGMLObject + def initialize(text) + super() + @text = text + end + + def prechildren_to_sgml(res) + res << "#{@text}" + end +end + +class Special < SGMLObject + def initialize(text) + super() + @text = text + end + + def prechildren_to_sgml(res) + res << "#{@text}" + end +end + +class Instruction < SGMLObject + def initialize(text) + super() + @text = text + end + + def prechildren_to_sgml(res) + res << "#{@text}" + end +end + +class Tag < SGMLObject + attr_reader :args + attr_writer :args + + def initialize(subtype, args={}) + super(subtype) + @args = args + end +end + +class OpenTag < Tag + def initialize(*args) + super + @upordown = Down + end + + def prechildren_to_sgml(res) + a = [@subtype] + + @args.each do |k, v| + if not v.include?("´") + a << "#{k}=´#{v}´" + else + if not v.include?(´"´) + a << "#{k}=\"#{v}\"" + else + a << "#{k}=´#{v.gsub(/\´/, ´"´)}´" + end + end + end + + res << "<#{a.join(" ")}>" + end + + def postchildren_to_sgml(res) + res << "</#{@subtype}>" if @closed + end +end + +class CloseTag < Tag + def initialize(*args) + super + @upordown = Dummy + end +end + +class SGML < Tree + def initialize(*args) + @tagcache = {} + + super + end + + def buildobjects(string) + @objects = [] + + string.splitblocks(["<!--", "<!", "<?", "<"], ["-->", ">", "?>", ">"]).each do |type, s| + case type + when 0 then @objects << Text.new(s) + when 1 then @objects << Comment.new(s) + when 2 then @objects << Special.new(s) + when 3 then @objects << Instruction.new(s) + when 4 + + tag, args, open, close = verwerktag1(s) + + @objects << OpenTag.new(tag.dup, args.dup) if open + @objects << CloseTag.new(tag.dup, args.dup) if close + end + end + end + + def verwerktag1(string) + res = nil + + if @tagcache.include? string + res = @tagcache[string] + + else + res = verwerktag2(string) + + @tagcache[string] = res + end + + return res + end + + def verwerktag2(string) + a = [] + + string.splitblocks(["´", ´"´], ["´", ´"´]).collect do |type, s| + case type + when 0 + if self.class.to_s == "HTML" + s.splitwords(["<", ">"]).each do |w| + d = w.split("=", 2) + + if d.length == 1 + a << d[0] + else + a << d[0] if not d[0].nil? and not d[0].empty? + a << "=" + a << d[1] if not d[1].nil? and not d[1].empty? + end + end + else + a.concat s.splitwords(["<", "/", "=", ">"]) + end + when 1, 2 then a << s + end + end + + a = a[1..-2] + open = false + close = false + + if not a.nil? + a = a[0].splitwords("/") + a[1..-1] + + if a[0] == "/" + close = true + a.shift + else + open = true + end + + if a[-1] == "/" + close = true + a.pop + end + + tag = a.shift.downcase + args = {} + + while not a.length.zero? + if a.length >= 3 and a[1] == "=" + key = a.shift.downcase + dummy = a.shift + value = a.shift.noquotes + args[key] = value + else + key = a.shift.downcase + args[key] = "" + end + end + end + + return [tag, args, open, close] + end + + def to_s + res = "" + + parsetree("prechildren_to_s", "postchildren_to_s", res) + + res + end + + def to_h + res = "" + + parsetree("prechildren_to_sgml", "postchildren_to_sgml", res) + + res + end +end diff -ur rubywebdialogs-none.tar.gz/rubywebdialogs/lib/tree.lib.rb rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/tree.lib.rb --- rubywebdialogs-none.tar.gz/rubywebdialogs/lib/tree.lib.rb 2005-06-04 14:41:54.524515480 +0200 +++ rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/tree.lib.rb 2004-04-18 14:20:31.000000000 +0200 @@ -0,0 +1,316 @@ +require "ev/ruby" +require "ev/net" +require "md5" +require "thread" + +Same = 0 +Down = 1 +Up = 2 +Dummy = 3 + +module TextArray + def textarray + @children.collect do |obj| + [obj.text] << obj.textarray + end.flatten.compact + end +end + + +module ParseTree + def parsetree(premethod="prechildren", postmethod="postchildren", *args) + if @visible + method(premethod).call(*args) if respond_to?(premethod) + + @children.each do |obj| + obj.parsetree(premethod, postmethod, *args) + end + + method(postmethod).call(*args) if respond_to?(postmethod) + end + end + + #def parsetree(premethod="prechildren", postmethod="postchildren", *args) + # stack = [self] + # done = [] + # + # while not stack.empty? + # obj = stack.pop + # + # if not done.include?(obj) + # obj.method(premethod).call(*args) if obj.respond_to?(premethod) + # + # stack.push(obj) + # done.push(obj) + # + # stack.concat obj.children.reverse + # #obj.children.reverse.each do |cobj| + # #stack.push(cobj) + # #end + # else + # obj.method(postmethod).call(*args) if obj.respond_to?(postmethod) + # end + # end + #end +end + +class TreeObject + attr_reader :subtype + attr_writer :subtype + attr_reader :upordown + attr_writer :upordown + attr_reader :level + attr_writer :level + attr_reader :parent + attr_writer :parent + attr_reader :children + attr_writer :children + attr_writer :closed + attr_writer :closed + attr_reader :text + attr_writer :text + attr_reader :visible + attr_writer :visible + + include TextArray + include ParseTree + + def initialize(subtype=nil) + @subtype = subtype + @upordown = Same + @level = nil + @parent = nil + @children = [] + @closed = nil + @visible = true + end + + def inspect + parent, children = @parent, @children + + @parent, @children = parent.id, children.collect{|obj| obj.id} + + res = " " * (level-1) + "#{self.class}(#{@subtype}) #{super}" + + @parent, @children = parent, children + + res + end +end + +class Tree + @@versie = 1 + @@mutex = Mutex.new + + attr_reader :data + attr_writer :data + attr_reader :parent + attr_writer :parent + attr_reader :children + attr_writer :children + attr_reader :visible + attr_writer :visible + + include TextArray + include ParseTree + + def initialize(string) + string = string.join("") if string.kind_of?(Array) + + @data = string + @parent = nil + @children = [] + @objects = [] + @visible = true + @checkvisibility = false + + buildobjects(string) + buildparents + buildchildren + markclosed + deletedummies + + @checkvisibility = true + end + + def self.file(file) + new(File.new(file).readlines) + end + + def self.location(url, form=Hash.new) + s = HTTPClient.get(url, form) + s = "" if s.nil? + new(s) + end + + def self.new_from_cache2(data) + new(data) + end + + def self.new_from_cache(data) + hash = MD5.new("#{@@versie} #{data}") + + dir = "#{temp}/evcache.#{user}/tree.new" + file = "#{dir}/#{hash}" + + tree = nil + + Dir.mkdirrec(dir) + + if FileTest.file?(file) + @@mutex.synchronize do + tree = Marshal.restore(File.new(file, "rb")) + end + else + tree = new(data) + + if not tree.nil? + @@mutex.synchronize do + File.open(file, "wb") {|f| Marshal.dump(tree, f)} + end + end + end + + return tree + end + + def inspect + @objects.collect do |obj| + obj.inspect + end.join("\n") + end + + def buildobjects(string) + raise "Has to be defined in the subclass." + end + + def buildparents + level = 1 + levels = Hash.new + levels[0] = nil + parse do |type, obj| + case obj.upordown + when Down + obj.level = level + obj.parent = levels[level-1] + levels[level] = obj + level += 1 + when Up, Dummy + pl = level + 1.upto(level-1) do |l| + po = levels[l] + pl = l if po.subtype == obj.subtype + end + level = pl + obj.level = level + obj.parent = levels[level-1] + when Same + obj.level = level + obj.parent = levels[level-1] + end + end + end + + def buildchildren + @objects.each do |obj| + obj.children = [] + end + + parse do |type, obj| + if not obj.parent.nil? + po = obj.parent + po.children << obj + else + @children << obj + end + end + end + + def markclosed + ([self].concat @objects).each do |obj| + obj.children.each_index do |i| + co1 = obj.children[i] + co2 = obj.children[i+1] + + co1.closed = (not co2.nil? and co1.upordown == Down and (co2.upordown == Up or co2.upordown == Dummy) and co1.subtype == co2.subtype) + end + end + end + + def deletedummies + ([self].concat @objects).each do |obj| + obj.children.delete_if do |obj2| + obj2.upordown == Dummy + end + end + + @objects.delete_if do |obj| + obj.upordown == Dummy + end + end + + def parse(types=[], subtypes=[]) + types = [types] if types.class == Class + subtypes = [subtypes] if subtypes.class == String + hidelevel = nil + + @objects.each do |obj| + hidelevel = obj.level if (@checkvisibility and hidelevel.nil? and (not obj.visible)) + hidelevel = nil if (@checkvisibility and (not hidelevel.nil?) and obj.visible and obj.level <= hidelevel) + + if hidelevel.nil? + ok = false + if types.empty? + if subtypes.empty? + ok = true + else + subtypes.each do |st| + ok = true if obj.subtype == st + end + end + else + if subtypes.empty? + types.each do |t| + ok = true if obj.kind_of?(t) + end + else + types.each do |t| + subtypes.each do |st| + ok = true if obj.kind_of?(t) if obj.subtype == st + end + end + end + end + + yield(obj.class.to_s, obj) if ok + end + end + end + + def path(pad) + p = self + + pad.split(/\//).each do |deel| + tag, voorkomen = deel.split(/:/) + + if (not tag.nil?) and (not p.nil?) + voorkomen = 1 if voorkomen.nil? + voorkomen = voorkomen.to_i + + teller = 0 + p2 = nil + p.children.each_index do |i| + if p.children[i].upordown == Down + if p.children[i].subtype.noquotes == tag.noquotes + teller += 1 + p2 = p.children[i] if teller == voorkomen + end + end + end + p = p2 + end + end + + p + end +end diff -ur rubywebdialogs-none.tar.gz/rubywebdialogs/lib/xml.lib.rb rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/xml.lib.rb --- rubywebdialogs-none.tar.gz/rubywebdialogs/lib/xml.lib.rb 2005-06-04 14:41:54.519516240 +0200 +++ rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/xml.lib.rb 2004-04-18 14:20:31.000000000 +0200 @@ -0,0 +1,4 @@ +require "ev/sgml" + +class XML < SGML +end diff -ur rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.0.2.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.0.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-18 14:20:31.000000000 +0200 +++ rubywebdialogs-0.0.2.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-20 22:41:43.000000000 +0200 @@ -375,11 +375,12 @@ res.concat " <table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´>" res.concat " <tr #{AC}>" tabs.each do |obj| + name = obj.args["name"] caption = obj.args["caption"] - if caption == tab + if name == tab res.concat "<td #{AC}><div class=´box´><tt><b> #{caption} </b></tt></div></td>" else - res.concat "<td #{AC}><div class=´box´><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_tab_#{caption}\";document.bodyform.submit();´><tt> #{caption} </tt></a></div></td>" + res.concat "<td #{AC}><div class=´box´><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_tab_#{name}\";document.bodyform.submit();´><tt> #{caption} </tt></a></div></td>" end end res.concat " </tr>" @@ -588,10 +589,10 @@ tabs = tabsobj.children.dup.delete_if{|obj| (not obj.kind_of?(OpenTag)) or (obj.subtype != "tab")} if tab.empty? - tab = tabs[0].args["caption"] + tab = tabs[0].args["name"] end - tabsobj.children.delete_if{|obj| (obj.kind_of?(OpenTag)) and (obj.subtype == "tab") and obj.args["caption"] != tab} + tabsobj.children.delete_if{|obj| (obj.kind_of?(OpenTag)) and (obj.subtype == "tab") and obj.args["name"] != tab} end if help @@ -696,12 +697,14 @@ @rwd_history.pop @rwd_action = (@rwd_history[-1] or [nil, nil])[0] @rwd_window = (@rwd_history[-1] or [nil, nil])[1] + @rwd_tab = nil back = true when "rwd_help" help = true when "rwd_main" - @rwd_window = "main" @rwd_action = "main" + @rwd_window = "main" + @rwd_tab = nil @rwd_history = [] when "rwd_quit" done = true @@ -733,6 +736,8 @@ rescue NameError end + tab = @rwd_tab unless @rwd_tab.nil? + # History stuff @rwd_history = [["main", "main"]] if @rwd_action == "main" @@ -1077,7 +1082,7 @@ </script> </head> - <body onload=´BodyGo()´ link=´#000000´ vlink=´#000000´ alink=´#000000´> + <body bgcolor=´white´ onload=´BodyGo()´ link=´#000000´ vlink=´#000000´ alink=´#000000´> <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´ width=´100%´ height=´100%´> <tr align=´center´ valign=´middle´> <td align=´center´> diff -ur rubywebdialogs-0.0.2.tar.gz/rubywebdialogs/lib/ruby.lib.rb rubywebdialogs-0.0.3.tar.gz/rubywebdialogs/lib/ruby.lib.rb --- rubywebdialogs-0.0.2.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-04-20 22:41:43.000000000 +0200 +++ rubywebdialogs-0.0.3.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-04-21 22:37:44.000000000 +0200 @@ -37,6 +37,10 @@ self.gsub(/[\r\n]*\z/, "") end + def lf + self.gsub(/\r*\n/, "\n").gsub(/\n\z/, "") + "\n" + end + def crlf self.gsub(/\r*\n/, "\r\n").gsub(/\r\n\z/, "") + "\r\n" end diff -ur rubywebdialogs-0.0.2.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.0.3.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.0.2.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-20 22:41:43.000000000 +0200 +++ rubywebdialogs-0.0.3.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-21 22:37:44.000000000 +0200 @@ -620,7 +620,7 @@ class RWDMessage < RWDWindow def initialize(msg) - super("<window title=´RWD Message´ nobackbuttons><vertical><p><b>Message:</b> #{msg}</p><back/></vertical></window>") + super("<window title=´RWD Message´ nobackbuttons><vertical><p>#{msg}</p><back/></vertical></window>") end end diff -ur rubywebdialogs-0.0.3.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.0.4.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.0.3.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-21 22:37:44.000000000 +0200 +++ rubywebdialogs-0.0.4.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-23 00:08:14.000000000 +0200 @@ -12,10 +12,11 @@ $".push "win32/registry.rb" end -exit if ARGV.include?("--rwd-exit") +exit if ARGV.include?("--rwd-exit") # Hack ??? + +$rwd_debug = ($rwd_debug or false) +$rwd_border = ($rwd_border or 0) -Debug = false -Border = 0 RWDEmptyline = "..." rcfile = nil @@ -269,12 +270,12 @@ end class OpenTag - def prechildren(res, before, after, vars, switches, help, firstaction, tabs, tab) + def prechildren(res, before, after, vars, switches, help, oneormorefields, firstaction, tabs, tab) bef = before[-1] - res.concat Format % ["Before", @subtype] if (Debug and not bef.nil?) + res.concat Format % ["Before", @subtype] if ($rwd_debug and not bef.nil?) res.concat bef if not bef.nil? - res.concat Format % ["Pre", @subtype] if Debug + res.concat Format % ["Pre", @subtype] if $rwd_debug align = AC align = "align=´#{@args["align"]}´" if @args.include?("align") @@ -312,14 +313,20 @@ else res.concat "<a href=´javascript:document.bodyform.rwd_action.value=\"#{@args["action"]}\";document.bodyform.submit();´>" end - when "vertical" then res.concat "<table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´>" - when "horizontal" then res.concat "<table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´><tr #{align} #{valign}>" - when "table" then res.concat "<table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´>" + when "vertical" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" + when "horizontal" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´><tr #{align} #{valign}>" + when "table" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" when "row" then res.concat "<tr #{align} #{valign}>" when "hidden" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´hidden´>" - when "text" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´text´>" - when "textarea" then res.concat "<p #{align}><textarea name=´#{@args["name"]}´>#{value}</textarea>" - when "password" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´password´>" + when "text" + res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´text´>" + oneormorefields << "true" + when "textarea" + res.concat "<p #{align}><textarea name=´#{@args["name"]}´>#{value}</textarea>" + oneormorefields << "true" + when "password" + res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´password´>" + oneormorefields << "true" when "checkbox" if vars[@args["name"]] == "on" switches[@args["name"]] = true @@ -328,16 +335,19 @@ switches[@args["name"]] = false res.concat "<p #{align}><input name=´#{@args["name"]}´ type=´checkbox´>" end + oneormorefields << "true" when "radio" if vars[@args["name"]] == value res.concat "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ value=´#{value}´ type=´radio´>" else res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´radio´>" end + oneormorefields << "true" when "select" res.concat "<select #{align} name=´#{@args["name"]}´ width=´#{@args["width"]}´>" name = @args["name"] $select = vars[name] + oneormorefields << "true" when "option" if $select == @children[0].text res.concat "<option selected=´true´>" @@ -347,21 +357,27 @@ when "button" res.concat "<input type=´submit´ value=´#{@args["caption"]}´ onclick=´document.bodyform.rwd_action.value=\"#{@args["action"]}\";´>" firstaction << @args["action"] if (firstaction.empty? and @args.include?("action")) + oneormorefields << "true" when "back" res.concat "<input type=´submit´ value=´Back´ onclick=´document.bodyform.rwd_action.value=\"rwd_back\";´>" firstaction << "rwd_back" if firstaction.empty? + oneormorefields << "true" when "help" res.concat "<input type=´submit´ value=´Help´ onclick=´document.bodyform.rwd_action.value=\"rwd_help\";´>" firstaction << "rwd_help" if firstaction.empty? + oneormorefields << "true" when "quit" res.concat "<input type=´submit´ value=´Quit´ onclick=´document.bodyform.rwd_action.value=\"rwd_quit\";´>" firstaction << "rwd_quit" if firstaction.empty? + oneormorefields << "true" when "close" res.concat "<input type=´submit´ value=´Close´ onclick=´window.close();´>" firstaction << "rwd_quit" if firstaction.empty? + oneormorefields << "true" when "reset" res.concat "<input type=´reset´ value=´Reset´>" firstaction << "rwd_quit" if firstaction.empty? + oneormorefields << "true" when "closewindow" #res.concat "<script type=´text/javascript´>\n" #res.concat "<!--\n" @@ -369,10 +385,10 @@ #res.concat "//-->\n" #res.concat "</script>" when "tabs" - res.concat "<table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´>" + res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" res.concat " <tr #{AC}>" res.concat " <td #{AC}>" - res.concat " <table #{AC} border=´#{Border}´ cellspacing=´3´ cellpadding=´0´>" + res.concat " <table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" res.concat " <tr #{AC}>" tabs.each do |obj| name = obj.args["name"] @@ -399,7 +415,7 @@ case @subtype when "vertical", "window", "helpwindow" - res.concat Format % ["AftPre", @subtype] if Debug + res.concat Format % ["AftPre", @subtype] if $rwd_debug if @args.include?("spacing") s = "<tr><td> </td></tr>" * (@args["spacing"].to_i) else @@ -408,7 +424,7 @@ bef = "#{s}<tr #{align} #{valign}><td #{align}>" aft = "</td></tr>" when "horizontal", "row" - res.concat Format % ["AftPre", @subtype] if Debug + res.concat Format % ["AftPre", @subtype] if $rwd_debug bef = "<td #{align}>" aft = "</td>" end @@ -417,18 +433,18 @@ after.push(aft) end - def postchildren(res, before, after, vars, switches, help, firstaction, tabs, tab) + def postchildren(res, before, after, vars, switches, help, oneormorefields, firstaction, tabs, tab) case @subtype when "vertical", "window", "helpwindow" - res.concat Format % ["BefPost", @subtype] if Debug + res.concat Format % ["BefPost", @subtype] if $rwd_debug if @args.include?("spacing") res.concat "<tr><td> </td></tr>" * (@args["spacing"].to_i) end when "horizontal", "row" - res.concat Format % ["BefPost", @subtype] if Debug + res.concat Format % ["BefPost", @subtype] if $rwd_debug end - res.concat Format % ["Post", @subtype] if Debug + res.concat Format % ["Post", @subtype] if $rwd_debug case @subtype when "application" @@ -483,7 +499,7 @@ after.pop aft = after[-1] - res.concat Format % ["After", @subtype] if (Debug and not aft.nil?) + res.concat Format % ["After", @subtype] if ($rwd_debug and not aft.nil?) res.concat aft if not aft.nil? end @@ -524,9 +540,9 @@ end class Text - def prechildren(res, before, after, vars, switches, help, firstaction, tabs, tab) + def prechildren(res, before, after, vars, switches, help, oneormorefields, firstaction, tabs, tab) if not @text.scan(/[^ \t\r\n]/).empty? - res.concat Format % ["Text", ""] if Debug + res.concat Format % ["Text", ""] if $rwd_debug res.concat "#{@text}" end end @@ -562,9 +578,10 @@ end def render(vars=Hash.new, switches=Hash.new, help=false, tab="") - vars2 = Hash.new - firstaction = "" - html = "" + vars2 = Hash.new + oneormorefields = "" + firstaction = "" + html = "" vars.each do |key, value| if not key.empty? @@ -596,16 +613,16 @@ end if help - helpobject.parsetree("prechildren", "postchildren", html, [""], [""], vars2, switches, false, firstaction, tabs, tab) + helpobject.parsetree("prechildren", "postchildren", html, [""], [""], vars2, switches, false, oneormorefields, firstaction, tabs, tab) else - windowobject.parsetree("prechildren", "postchildren", html, [""], [""], vars2, switches, (not @helprwd.empty?), firstaction, tabs, tab) + windowobject.parsetree("prechildren", "postchildren", html, [""], [""], vars2, switches, (not @helprwd.empty?), oneormorefields, firstaction, tabs, tab) end - html.gsub!(/%%*[[:alnum:]_\-]+%%*/, "") if not Debug + html.gsub!(/%%*[[:alnum:]_\-]+%%*/, "") if not $rwd_debug html.gsub!(/%%/, "%") html.gsub!(/\n\n*/, "\n") - if firstaction.empty? + if oneormorefields.empty? focus = "" else focus = "document.bodyform.elements[0].focus();" @@ -632,7 +649,7 @@ class RWDDone < RWDWindow def initialize(exitbrowser) - super("<window title=´RWD Message´ nobackbuttons noclosebutton><p>Done.</p><horizontal><close/>#{exitbrowser ? "" : "<button caption=´Login´/>"}</horizontal>#{exitbrowser ? "<closewindow/>" : ""}</window>") + super("<window title=´RWD Message´ nobackbuttons noclosebutton><p>Done.</p><horizontal><close/>#{exitbrowser ? "" : "<button caption=´Again´/>"}</horizontal>#{exitbrowser ? "<closewindow/>" : ""}</window>") end end @@ -679,31 +696,32 @@ # Copy the vars from the window to vars. vars wil later on be copied to instance variables. post.sort.each do |key, value| - puts "Post: #{key} -> #{value.from_html.inspect}" if Debug + puts "Post: #{key} -> #{value.from_html.inspect}" if $rwd_debug vars[key] = value.from_html end - # Stack handling for rwd_action and rwd_window. + # Stack handling for rwd_action, rwd_window and rwd_tab. @rwd_action = vars["rwd_action"] @rwd_action, @rwd_args = @rwd_action.split(/\//, 2) unless @rwd_action.nil? if @rwd_action =~ /^rwd_tab_/ - tab = @rwd_action.sub(/^rwd_tab_/, "") + @rwd_tab = @rwd_action.sub(/^rwd_tab_/, "") + @rwd_history[-1][2] = @rwd_tab else case @rwd_action when "rwd_back" @rwd_history.pop - @rwd_action = (@rwd_history[-1] or [nil, nil])[0] - @rwd_window = (@rwd_history[-1] or [nil, nil])[1] - @rwd_tab = nil + @rwd_action = (@rwd_history[-1] or [nil, nil, nil])[0] + @rwd_window = (@rwd_history[-1] or [nil, nil, nil])[1] + @rwd_tab = (@rwd_history[-1] or [nil, nil, nil])[2] back = true when "rwd_help" help = true when "rwd_main" - @rwd_action = "main" - @rwd_window = "main" + @rwd_action = nil + @rwd_window = nil @rwd_tab = nil @rwd_history = [] when "rwd_quit" @@ -713,13 +731,15 @@ # History stuff @rwd_history = @rwd_history[-100..-1] if @rwd_history.length >= 100 + @rwd_args = [] if @rwd_args.nil? @rwd_action = "main" if @rwd_action.nil? @rwd_action = "main" if @rwd_action.empty? - @rwd_args = [] if @rwd_args.nil? @rwd_window = "main" if @rwd_window.nil? + @rwd_tab = "" if @rwd_tab.nil? vars["rwd_action"] = @rwd_action vars["rwd_window"] = @rwd_window + vars["rwd_tab"] = @rwd_tab # Copy vars from window to instance. @@ -731,18 +751,16 @@ if not back begin - puts "Method: #{@rwd_action}(#{@rwdargs.join(", ")})" if Debug + puts "Method: #{@rwd_action}(#{@rwd_args.join(", ")})" if $rwd_debug method(@rwd_action).call(*@rwd_args) rescue NameError end - tab = @rwd_tab unless @rwd_tab.nil? - # History stuff - @rwd_history = [["main", "main"]] if @rwd_action == "main" - @rwd_history = [["main", "main"]] if @rwd_history.empty? - @rwd_history.push [@rwd_action, @rwd_window] if (@rwd_history[-1] != [@rwd_action, @rwd_window] or not @rwd_msg.nil?) + @rwd_history = [["main", "main", nil]] if @rwd_action == "main" + @rwd_history = [["main", "main", nil]] if @rwd_history.empty? + @rwd_history.push [@rwd_action, @rwd_window, @rwd_tab] if (@rwd_history[-1] != [@rwd_action, @rwd_window, @rwd_tab] or not @rwd_msg.nil?) end end @@ -756,7 +774,7 @@ # just ignore. vars.sort.each do |key, value| - puts "Pre: #{key} -> #{value.inspect}" if Debug + puts "Pre: #{key} -> #{value.inspect}" if $rwd_debug end # Answer to browser. @@ -768,8 +786,9 @@ res << RWDMessage.new(@rwd_msg).render if @rwd_msgtype == "message" res << RWDError.new(@rwd_msg).render if @rwd_msgtype == "error" else - puts "Window: #{@rwd_window}" if Debug - res << RWDWindow.new(@rwd_xml, @rwd_window).render(vars, @rwd_switches, help, tab) + puts "Window: #{@rwd_window}" if $rwd_debug + puts "Tab: #{@rwd_tab}" if $rwd_debug + res << RWDWindow.new(@rwd_xml, @rwd_window).render(vars, @rwd_switches, help, @rwd_tab) end end @@ -836,7 +855,7 @@ @rack = rack.to_s @cleanup = SessionCleanup.new(self, 3600, 24*3600) if cleanup @sessions = {} - #@store = PStore.new("#{temp}/store.#{@rack}.#{user}") + #@store = PStore.new("#{temp}/store.#{@rack}.#{user}") # ??? #@store.transaction do #@store[@rack] = {} if not @store.root?(@rack) @@ -958,11 +977,11 @@ if session.nil? if auth.nil? - session = RWDSession.new(MD5.new(req.peeraddr[3].to_s + @object.inspect.to_s).to_s) - session["object"] = @object + session = RWDSession.new(MD5.new(req.peeraddr[3].to_s + @object.inspect.to_s).to_s) + session["object"] = @object else - session = RWDSession.new(MD5.new(Time.new.to_s + req.peeraddr[3].to_s + @object.inspect.to_s).to_s) - session["object"] = @object.clone + session = RWDSession.new(MD5.new(Time.new.to_s + req.peeraddr[3].to_s + @object.inspect.to_s).to_s) + session["object"] = @object.clone end if oldsessionid.nil? or oldsessionid.empty? @@ -972,10 +991,10 @@ us = vars["rwd_a"] pa = vars["rwd_b"] - + if us.nil? or pa.nil? or auths[us] != pa - session = RWDSession.new - session["object"] = RWDLogin.new(realm) + session = RWDSession.new + session["object"] = RWDLogin.new(realm) else session.authenticated = true @sessions[session.sessionid] = session diff -ur rubywebdialogs-0.0.4.tar.gz/rubywebdialogs/init.rb rubywebdialogs-0.0.5.tar.gz/rubywebdialogs/init.rb --- rubywebdialogs-0.0.4.tar.gz/rubywebdialogs/init.rb 2004-04-23 00:08:14.000000000 +0200 +++ rubywebdialogs-0.0.5.tar.gz/rubywebdialogs/init.rb 2004-04-23 11:11:25.000000000 +0200 @@ -1,39 +1,24 @@ require "rbconfig" -Reversed = (ARGV.include?("-r")) - -FromDirs = ENV["PATH"].split(/:/) + [".", "./lib", "./rubylib/lib"] +FromDirs = [".", "./lib", "./rubylib/lib"] ToDir = Config::CONFIG["sitelibdir"] + "/ev" Dir.mkdir(ToDir) if not File.directory?(ToDir) FromDirs.each do |fromdir| fromdir = Dir.pwd if fromdir == "." + if File.directory?(fromdir) Dir.new(fromdir).each do |file| - if not file.scan(/\.lib\.rb$/).empty? + if file =~ /\.lib\.rb$/ fromfile = fromdir + "/" + file tofile = ToDir + "/" + file.sub(/\.lib\.rb/, ".rb") - if not (File.directory?("c:/")) - printf "%s -> %s\n", fromfile, tofile + printf "%s -> %s\n", fromfile, tofile + + File.delete(tofile) if File.file?(tofile) - File.unlink(tofile) if File.symlink?(tofile) - File.symlink(fromfile, tofile) - else - if Reversed - tofile, fromfile = fromfile, tofile - end - - if FileTest.file?(fromfile) - printf "%s -> %s\n", fromfile, tofile - - File.delete(tofile) if File.writable?(tofile) - File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} - else - printf "%s -> %s (Skipped!)\n", fromfile, tofile - end - end + File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} end end end diff -ur rubywebdialogs-0.0.4.tar.gz/rubywebdialogs/install.rb rubywebdialogs-0.0.5.tar.gz/rubywebdialogs/install.rb --- rubywebdialogs-0.0.4.tar.gz/rubywebdialogs/install.rb 2004-04-23 00:08:14.000000000 +0200 +++ rubywebdialogs-0.0.5.tar.gz/rubywebdialogs/install.rb 2004-04-23 11:11:25.000000000 +0200 @@ -1,39 +1,24 @@ require "rbconfig" -Reversed = (ARGV.include?("-r")) - -FromDirs = ENV["PATH"].split(/:/) + [".", "./lib", "./rubylib/lib"] +FromDirs = [".", "./lib", "./rubylib/lib"] ToDir = Config::CONFIG["sitelibdir"] + "/ev" Dir.mkdir(ToDir) if not File.directory?(ToDir) FromDirs.each do |fromdir| fromdir = Dir.pwd if fromdir == "." + if File.directory?(fromdir) Dir.new(fromdir).each do |file| - if not file.scan(/\.lib\.rb$/).empty? + if file =~ /\.lib\.rb$/ fromfile = fromdir + "/" + file tofile = ToDir + "/" + file.sub(/\.lib\.rb/, ".rb") - if not (File.directory?("c:/")) - printf "%s -> %s\n", fromfile, tofile + printf "%s -> %s\n", fromfile, tofile + + File.delete(tofile) if File.file?(tofile) - File.unlink(tofile) if File.symlink?(tofile) - File.symlink(fromfile, tofile) - else - if Reversed - tofile, fromfile = fromfile, tofile - end - - if FileTest.file?(fromfile) - printf "%s -> %s\n", fromfile, tofile - - File.delete(tofile) if File.writable?(tofile) - File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} - else - printf "%s -> %s (Skipped!)\n", fromfile, tofile - end - end + File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} end end end diff -ur rubywebdialogs-0.0.5.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.0.6.tar.gz/rubywebdialogs/lib/net.lib.rb --- rubywebdialogs-0.0.5.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-04-23 11:11:24.000000000 +0200 +++ rubywebdialogs-0.0.6.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-04-24 18:43:46.000000000 +0200 @@ -479,7 +479,7 @@ req = Request.new(io) resp = Response.new(io) - rescue + rescue NameError puts "Getting request from browser failed." io = nil end diff -ur rubywebdialogs-0.0.5.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.0.6.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.0.5.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-23 11:11:24.000000000 +0200 +++ rubywebdialogs-0.0.6.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-24 18:43:46.000000000 +0200 @@ -294,7 +294,7 @@ args["nohelpbutton"] = (not help) - res.concat(template(RWD_HTML1, args)) + res.concat(template($rwd_html1, args)) when "p" then res.concat "<p #{align}>" when "pre" then res.concat "<pre>" when "big" then res.concat "<p #{align}><big>" @@ -379,24 +379,27 @@ firstaction << "rwd_quit" if firstaction.empty? oneormorefields << "true" when "closewindow" - #res.concat "<script type=´text/javascript´>\n" + #res.concat "<script type=´text/javascript´>\n" # ??? #res.concat "<!--\n" #res.concat " window.close();\n" #res.concat "//-->\n" #res.concat "</script>" when "tabs" - res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" - res.concat " <tr #{AC}>" - res.concat " <td #{AC}>" - res.concat " <table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" - res.concat " <tr #{AC}>" + res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´0´ cellpadding=´0´>" + res.concat " <tr #{AL}>" + res.concat " <td #{AL} class=´tabs´>" + res.concat " <table #{AL} border=´#{$rwd_border}´ cellspacing=´0´ cellpadding=´0´>" + res.concat " <tr #{AL}>" tabs.each do |obj| name = obj.args["name"] caption = obj.args["caption"] + + res.concat "<td class=´notab´> </td>" unless obj == tabs[0] + if name == tab - res.concat "<td #{AC}><div class=´box´><tt><b> #{caption} </b></tt></div></td>" + res.concat "<td #{AC} class=´thistab´><tt><b> #{caption} </b></tt></td>" else - res.concat "<td #{AC}><div class=´box´><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_tab_#{name}\";document.bodyform.submit();´><tt> #{caption} </tt></a></div></td>" + res.concat "<td #{AC} class=´tab´><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_tab_#{name}\";document.bodyform.submit();´><tt> #{caption} </tt></a></td>" end end res.concat " </tr>" @@ -404,7 +407,9 @@ res.concat " </td>" res.concat " </tr>" when "tab" - res.concat "<tr #{align} #{valign}><td #{align}><div class=´box2´>" + res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" + res.concat " <tr #{AL}>" + res.concat " <td #{AL} class=´tabblad´>" else puts "<#{@subtype}>" res.concat "<#{@subtype}>" @@ -414,7 +419,7 @@ aft = nil case @subtype - when "vertical", "window", "helpwindow" + when "vertical", "window", "helpwindow", "tabs", "tab" res.concat Format % ["AftPre", @subtype] if $rwd_debug if @args.include?("spacing") s = "<tr><td> </td></tr>" * (@args["spacing"].to_i) @@ -435,7 +440,7 @@ def postchildren(res, before, after, vars, switches, help, oneormorefields, firstaction, tabs, tab) case @subtype - when "vertical", "window", "helpwindow" + when "vertical", "window", "helpwindow", "tabs", "tab" res.concat Format % ["BefPost", @subtype] if $rwd_debug if @args.include?("spacing") res.concat "<tr><td> </td></tr>" * (@args["spacing"].to_i) @@ -453,7 +458,7 @@ args["nohelpbutton"] = (not help) - res.concat(template(RWD_HTML2, args)) + res.concat(template($rwd_html2, args)) when "p" then res.concat "</p>" when "pre" then res.concat "</pre>" when "big" then res.concat "</big></p>" @@ -489,7 +494,7 @@ when "reset" then res.concat "" when "closewindow" then res.concat "" when "tabs" then res.concat "</table>" - when "tab" then res.concat "</div></td></tr>" + when "tab" then res.concat "</td></tr></table>" else puts "</#{@subtype}>" res.concat "</#{@subtype}>" @@ -519,6 +524,12 @@ a["BACKBUTTONS"] = (not (vars["nobackbuttons"])) a["CLOSEBUTTON"] = (not (vars["noclosebutton"])) + if a.include?("WIDTH") + a["WIDTH"] = "width=´#{a["WIDTH"]}´" + else + a["WIDTH"] = " " + end + html.split(/\r*\n/).each do |line| if line =~ /%[A-Z]+%/ a.each do |k, v| @@ -913,7 +924,7 @@ res.gsub!(/\$RWD_SESSION\$/, "#{@sessionid}") end - done + return done end end @@ -936,7 +947,7 @@ @browserthread = Thread.new do puts "Starting the browser..." - #if ENV["RWDBROWSER"].downcase =~ /iexplore/ + #if ENV["RWDBROWSER"].downcase =~ /iexplore/ # ??? #@ie = IE.new("http://localhost:#{port}/") #else if windows? @@ -955,7 +966,7 @@ # Start server. - catch :exit do + catch :rwd_exit do HTTPServer.serve(port, (not auth.nil?)) do |req, resp| vars = req.vars.dup @@ -966,15 +977,15 @@ else auths = auth end - + oldsessionid = vars["rwd_session"] - + # Retrieve session. - + session = @sessions[oldsessionid] - + # Eventually create new session. - + if session.nil? if auth.nil? session = RWDSession.new(MD5.new(req.peeraddr[3].to_s + @object.inspect.to_s).to_s) @@ -983,15 +994,15 @@ session = RWDSession.new(MD5.new(Time.new.to_s + req.peeraddr[3].to_s + @object.inspect.to_s).to_s) session["object"] = @object.clone end - + if oldsessionid.nil? or oldsessionid.empty? if not auth.nil? and not session.authenticated - + # Check authentication - + us = vars["rwd_a"] pa = vars["rwd_b"] - + if us.nil? or pa.nil? or auths[us] != pa session = RWDSession.new session["object"] = RWDLogin.new(realm) @@ -1006,58 +1017,60 @@ session = RWDSession.new session["object"] = RWDTimeOut.new end - + vars = {} end - + # Avoid timeout. - + session.touch - + if req.request.path == "/" - + # Serve methods/callbacks. - + # Build new page. - + res = "" - + done = session.render(res, req.request.path, vars) - + begin resp["Content-Type"] = "text/html" - + resp << res rescue puts "Sending response to browser failed." - + @sessions.delete(session.sessionid) end - + # Eventually delete this session. - + if done @sessions.delete(session.sessionid) - + if @localbrowsing resp.flush - + if @browserstarted and @browserthread.alive? puts "Waiting for the browser to terminate..." - + @browserthread.join end - - throw :exit + + throw :rwd_exit end end - + else - + # Serve files. - + if req.request.path == "/pixel.gif" - resp << RWD_Pixel + resp["Cache-Control"] = "max-age=86400" + resp["Content-Type"] = "image/gif" + resp << $rwd_pixel else if (FileTest.file?(req.request.path.sub(/^\/*/, ""))) resp << File.new(req.request.path.sub(/^\/*/, ""), "rb").read rescue nil @@ -1065,14 +1078,14 @@ resp.response = "HTTP/1.0 404 NOT FOUND" end end - + end end end end end -RWD_HTML = " +$rwd_html = " <!-- Generated by RubyWebDialog. --> <!-- For more information, please contact Erik Veenstra <rwd@erikveen.dds.nl>. --> <html> @@ -1086,9 +1099,34 @@ <style type=´text/css´> <!-- - a { text-decoration : none } - div.box { border : thin solid #AAAAAA } - div.box2 { border-top : thin solid #AAAAAA } + + a { + text-decoration : none; + } + + td.tabs { + border-color : #000000; + border-width : thin; + border-style : none none solid none; + } + + td.tab { + border-color : #000000; + border-width : thin; + border-style : solid solid none solid; + } + + td.thistab { + border-color : #000000; + border-width : medium; + border-style : solid solid none solid; + } + + td.notab { + border-width : thin; + border-style : none; + } + //--> </style> @@ -1102,224 +1140,224 @@ </head> <body bgcolor=´white´ onload=´BodyGo()´ link=´#000000´ vlink=´#000000´ alink=´#000000´> - <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´ width=´100%´ height=´100%´> - <tr align=´center´ valign=´middle´> - <td align=´center´> - - <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´> - - <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - - <td align=´center´> - - <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´> - <tr align=´center´> - <td align=´center´ bgcolor=´#444488´> - - <table align=´left´ border=´0´ cellspacing=´1´ cellpadding=´0´> - <tr align=´center´> - <td align=´border´><img src=´%LOGO%´ width=´14´ height=´14´></td> - <td align=´center´><b><small><font color=´#FFFFFF´> %TITLE% </font></small></b></td> - </tr> - </table> - - <table align=´right´ border=´0´ cellspacing=´1´ cellpadding=´0´> - <tr align=´center´> - <!-- %HELPBUTTON% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_help\";document.bodyform.submit();´> ? </a></small></b></td> - <!-- %BACKBUTTONS% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_main\";document.bodyform.submit();´> << </a></small></b></td> - <!-- %BACKBUTTONS% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_back\";document.bodyform.submit();´> < </a></small></b></td> - <!-- %CLOSEBUTTON% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_quit\";document.bodyform.submit();´> X </a></small></b></td> - </tr> - </table> - - </td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´#CCCCCC´> - <form name=´bodyform´ action=´/´ method=´post´> - - <table align=´center´ border=´0´ cellspacing=´3´ cellpadding=´0´> - - %BODY% + <form name=´bodyform´ action=´/´ method=´post´> + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´ width=´100%´ height=´100%´> + <tr align=´center´ valign=´middle´> + <td align=´center´> + + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + + <td align=´center´> + + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´ %WIDTH%> + <tr align=´center´> + <td align=´center´ bgcolor=´#444488´> + + <table align=´left´ border=´0´ cellspacing=´1´ cellpadding=´0´> + <tr align=´center´> + <td align=´border´><img src=´%LOGO%´ width=´14´ height=´14´></td> + <td align=´center´><b><small><font color=´#FFFFFF´> %TITLE% </font></small></b></td> + </tr> + </table> + <table align=´right´ border=´0´ cellspacing=´1´ cellpadding=´0´> + <tr align=´center´> + <!-- %HELPBUTTON% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_help\";document.bodyform.submit();´> ? </a></small></b></td> + <!-- %BACKBUTTONS% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_main\";document.bodyform.submit();´> << </a></small></b></td> + <!-- %BACKBUTTONS% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_back\";document.bodyform.submit();´> < </a></small></b></td> + <!-- %CLOSEBUTTON% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_quit\";document.bodyform.submit();´> X </a></small></b></td> + </tr> </table> - <input name=´rwd_action´ value=´$RWD_FIRSTACTION$´ type=´hidden´> - <input name=´rwd_session´ value=´$RWD_SESSION$´ type=´hidden´> - </form> - </td> - </tr> - </table> - - </td> - - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - </tr> - - </table> - - </td> - </tr> - </table> + </td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´#CCCCCC´> + + <table align=´center´ border=´0´ cellspacing=´3´ cellpadding=´0´> + + %BODY% + + </table> + + <input name=´rwd_action´ value=´$RWD_FIRSTACTION$´ type=´hidden´> + <input name=´rwd_session´ value=´$RWD_SESSION$´ type=´hidden´> + </td> + </tr> + </table> + + </td> + + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + </tr> + + </table> + + </td> + </tr> + </table> + </form> </body> </html> " -RWD_Pixel = " +$rwd_pixel = " R0lGODlhAQABAOcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoK CgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZ GRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygo @@ -1341,4 +1379,4 @@ CgD/ACwAAAAAAQABAAAIBAD/BQQAOw== ".unpack("m").shift -RWD_HTML1, RWD_HTML2 = RWD_HTML.split(/^\s*%BODY%\s*\r*$/) +$rwd_html1, $rwd_html2 = $rwd_html.split(/^\s*%BODY%\s*\r*$/) diff -ur rubywebdialogs-0.0.6.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.0.7.tar.gz/rubywebdialogs/lib/net.lib.rb --- rubywebdialogs-0.0.6.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-04-24 18:43:46.000000000 +0200 +++ rubywebdialogs-0.0.7.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-04-28 21:41:23.000000000 +0200 @@ -211,7 +211,7 @@ res = io.read header, data = nil, nil header, data = res.split(/\r*\n\r*\n/, 2) if not res.nil? - header = Header.new(header) + header = Header.new(header) if recursive and header.header["location"] != uri.to_s uri = EVURI.new(uri) + header.header["location"] @@ -479,8 +479,8 @@ req = Request.new(io) resp = Response.new(io) - rescue NameError - puts "Getting request from browser failed." + rescue NameError, StandardError => e + puts "Getting request from browser failed. (%s)" % e.class.to_s io = nil end @@ -502,7 +502,7 @@ begin resp.flush - rescue + rescue NameError, StandardError end #end end diff -ur rubywebdialogs-0.0.6.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.0.7.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.0.6.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-24 18:43:46.000000000 +0200 +++ rubywebdialogs-0.0.7.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-28 21:41:23.000000000 +0200 @@ -40,8 +40,10 @@ else begin puts "Looking for default browser..." - ENV["RWDBROWSER"] = Win32::Registry::HKEY_CLASSES_ROOT.open(´htmlfile\shell\open\command´)[0] - rescue + Win32::Registry::HKEY_CLASSES_ROOT.open(´htmlfile\shell\open\command´) do |reg| + ENV["RWDBROWSER"] = reg[""] + end + rescue NameError puts "Not found." end @@ -319,13 +321,17 @@ when "row" then res.concat "<tr #{align} #{valign}>" when "hidden" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´hidden´>" when "text" - res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´text´>" + maxlength = "" + maxlength = "maxlength=´%s´" % @args["maxlength"] if @args.include?("maxlength") + res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´text´ #{maxlength}>" oneormorefields << "true" when "textarea" res.concat "<p #{align}><textarea name=´#{@args["name"]}´>#{value}</textarea>" oneormorefields << "true" when "password" - res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´password´>" + maxlength = "" + maxlength = "maxlength=´%s´" % @args["maxlength"] if @args.include?("maxlength") + res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´password´ #{maxlength}>" oneormorefields << "true" when "checkbox" if vars[@args["name"]] == "on" @@ -996,7 +1002,7 @@ end if oldsessionid.nil? or oldsessionid.empty? - if not auth.nil? and not session.authenticated + if not auth.nil? and not auth.empty? and not session.authenticated # Check authentication diff -ur rubywebdialogs-0.0.7.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/net.lib.rb --- rubywebdialogs-0.0.7.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-04-28 21:41:23.000000000 +0200 +++ rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-05-05 23:40:17.000000000 +0200 @@ -490,7 +490,7 @@ @@times[com]=Time.new.to_f if not @@times.include?(com) - if (not remote) or (remote and (auth.nil? or authenticate(auth, realm, req, resp))) + if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp))) #puts "#{Time.new.strftime("%H:%M:%S")}: #{req.peeraddr[3]}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: > #{req.request}" yield(req, resp) diff -ur rubywebdialogs-0.0.7.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.0.7.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-04-28 21:41:23.000000000 +0200 +++ rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-05-05 23:40:17.000000000 +0200 @@ -38,13 +38,15 @@ ENV[k] = v end else - begin - puts "Looking for default browser..." - Win32::Registry::HKEY_CLASSES_ROOT.open(´htmlfile\shell\open\command´) do |reg| - ENV["RWDBROWSER"] = reg[""] + if not ENV.include?("RWDBROWSER") + begin + puts "Looking for default browser..." + Win32::Registry::HKEY_CLASSES_ROOT.open(´htmlfile\shell\open\command´) do |reg| + ENV["RWDBROWSER"] = reg[""] + end + rescue NameError + puts "Not found." end - rescue NameError - puts "Not found." end if not ENV.include?("RWDBROWSER") and false # ??? @@ -274,7 +276,7 @@ class OpenTag def prechildren(res, before, after, vars, switches, help, oneormorefields, firstaction, tabs, tab) bef = before[-1] - res.concat Format % ["Before", @subtype] if ($rwd_debug and not bef.nil?) + res.concat Format % ["Before", @subtype] if ($rwd_debug and not bef.nil?) res.concat bef if not bef.nil? res.concat Format % ["Pre", @subtype] if $rwd_debug @@ -311,7 +313,7 @@ when "i" then res.concat "<i>" when "a" if @args.include?("href") - res.concat "<a href=´#{@args["href"]}´ target=´#{@args["target"] or "new"}´>" + res.concat "<a href=´#{@args["href"]}´ target=´#{@args["target"] or "_blank"}´>" else res.concat "<a href=´javascript:document.bodyform.rwd_action.value=\"#{@args["action"]}\";document.bodyform.submit();´>" end @@ -672,11 +674,11 @@ class RWDialog def initialize(xml) - @rwd_xml = xml - @rwd_exitbrowser = false - @rwd_history = [] - @rwd_clone_vars = ["@rwd_history"] - @rwd_ignore_vars = ["@rwd_server"] + @rwd_xml = xml + @rwd_exitbrowser = false + @rwd_history = [] + @rwd_ignore_vars = [] + @rwd_call_after_back = [] end def self.file(rwdfile, *args) @@ -752,6 +754,7 @@ @rwd_action = "main" if @rwd_action.nil? @rwd_action = "main" if @rwd_action.empty? @rwd_window = "main" if @rwd_window.nil? + @rwd_window = "main" if @rwd_window.empty? @rwd_tab = "" if @rwd_tab.nil? vars["rwd_action"] = @rwd_action @@ -766,7 +769,7 @@ # Callback. - if not back + if (not back) or @rwd_call_after_back.include?(@rwd_action) begin puts "Method: #{@rwd_action}(#{@rwd_args.join(", ")})" if $rwd_debug method(@rwd_action).call(*@rwd_args) @@ -826,16 +829,6 @@ @rwd_msgtype = "error" end - def clone - @rwd_history = [] - - @rwd_clone_vars.each do |var| - instance_eval "#{var} = #{var}.clone" - end - - super - end - def exitbrowser @rwd_exitbrowser = true end @@ -944,7 +937,7 @@ if auth.nil? @localbrowsing = true - if ENV.include?("RWDBROWSER") + if ENV.include?("RWDBROWSER") and not ENV["RWDBROWSER"].empty? @browserstarted = true @object.exitbrowser @@ -1110,6 +1103,10 @@ text-decoration : none; } + a:hover { + background : #AAAAAA; + } + td.tabs { border-color : #000000; border-width : thin; diff -ur rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/net.lib.rb --- rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-05-05 23:40:17.000000000 +0200 +++ rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-05-15 11:16:23.000000000 +0200 @@ -25,6 +25,53 @@ s end +class TCPServer + def self.freeport(from, to) + res = nil + port = from + + while res.nil? and port <= to + begin + #evtimeout(0.1) do + io = TCPSocket.new("localhost", port) + io.close + #end + + port += 1 + rescue + res = port + end + end + + return res + end + + def self.usedports(from, to) + threads = [] + res = [] + + from.upto(to) do |port| + threads << Thread.new do + begin + io = TCPSocket.new("localhost", port) + io.close + + port + rescue + nil + end + end + end + + threads.each do |thread| + port = thread.value + res << port unless port.nil? + end + + return res + end +end + class EVURI attr_reader :protocol attr_writer :protocol @@ -472,40 +519,41 @@ if not server.nil? loop do - io = nil - - begin - io = server.accept + io = server.accept - req = Request.new(io) - resp = Response.new(io) - rescue NameError, StandardError => e - puts "Getting request from browser failed. (%s)" % e.class.to_s - io = nil - end + catch :rwd_io_error do + begin + req = Request.new(io) + resp = Response.new(io) + rescue + throw :rwd_io_error + end - if not io.nil? and not req.peeraddr.nil? - #Thread.new(req, resp) do |req, resp| - com = req.request.to_s.strip + req.peeraddr[3] + begin + ip = req.peeraddr[3] + com = req.request.to_s.strip + ip + rescue NameError + throw :rwd_io_error + end + if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp))) @@times[com]=Time.new.to_f if not @@times.include?(com) - if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp))) - #puts "#{Time.new.strftime("%H:%M:%S")}: #{req.peeraddr[3]}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: > #{req.request}" + #puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: > #{req.request}" + + yield(req, resp) - yield(req, resp) + puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: < #{req.request}" - puts "#{Time.new.strftime("%H:%M:%S")}: #{req.peeraddr[3]}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: < #{req.request}" + @@times.delete(com) + end - @@times.delete(com) - end - - begin - resp.flush - rescue NameError, StandardError - end - #end - end + begin + resp.flush + rescue + throw :rwd_io_error + end + end end end end diff -ur rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/ruby.lib.rb rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/ruby.lib.rb --- rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-05-05 23:40:17.000000000 +0200 +++ rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-05-15 11:16:23.000000000 +0200 @@ -95,9 +95,17 @@ DRbObject.new(nil, "druby://localhost:3100").speak(self) end - def splitblocks(begindelimiters, enddelimiter) - bd = begindelimiters.collect {|s| Regexp.escape(s)} - ed = enddelimiter.collect {|s| Regexp.escape(s)} + def splitblocks(*delimiters) + begindelimiters = [] + enddelimiters = [] + + delimiters.each do |k, v| + begindelimiters << k + enddelimiters << v + end + + bd = begindelimiters.collect {|s| Regexp.escape(s)} + ed = enddelimiters.collect {|s| Regexp.escape(s)} be = bd.join("|") ee = ed.join("|") @@ -106,14 +114,14 @@ type = 0 tmp = "" es = "" + self.split(/(#{be}|#{ee})/).each do |s| if type == 0 if begindelimiters.include?(s) type = begindelimiters.index(s)+1 tmp = s - es = enddelimiter[begindelimiters.index(s)] + es = enddelimiters[begindelimiters.index(s)] else - #res << [0, s] if not s.compress.empty? res << [0, s] if not s.empty? end else @@ -127,13 +135,17 @@ end end end - res + + res << [0, tmp] if not tmp.empty? + + return res end - def splitwords(tokens=[], begindelimiters=["´", ´"´], enddelimiter=["´", ´"´]) + def splitwords(tokens=[]) tokens = [tokens] if not tokens.kind_of?(Array) res = [] - self.splitblocks(begindelimiters, enddelimiter).each do |type, s| + + self.splitblocks(["´", "´"], [´"´, ´"´]).each do |type, s| case type when 0 tokens.each do |token| @@ -148,18 +160,20 @@ res << s[1..-2] end end - res + + return res end def uncomment res = [] - self.splitblocks( ["´" , ´"´ , "/*" , "<!--" , "#" , ";" ], - ["´" , ´"´ , "*/" , "-->" , "\n", "\n"]).each do |type, s| + + self.splitblocks(["´", "´"], [´"´, ´"´], ["/*", "*/"], ["<!--", "-->"], ["#", "\n"]).each do |type, s| case type when 0, 1, 2 then res << s when 3, 4, 5 end end + res.join("") end diff -ur rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-05-05 23:40:17.000000000 +0200 +++ rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-05-15 11:16:23.000000000 +0200 @@ -12,8 +12,7 @@ $".push "win32/registry.rb" end -exit if ARGV.include?("--rwd-exit") # Hack ??? - +$rwd_exit = ARGV.include?("--rwd-exit") # Hack ??? $rwd_debug = ($rwd_debug or false) $rwd_border = ($rwd_border or 0) @@ -31,68 +30,29 @@ Format = "\n<!-- %-10s %-10s -->\t" -if not rcfile.nil? +unless rcfile.nil? puts "Reading #{rcfile} ..." Hash.file(rcfile).each do |k, v| ENV[k] = v end -else - if not ENV.include?("RWDBROWSER") - begin - puts "Looking for default browser..." - Win32::Registry::HKEY_CLASSES_ROOT.open(´htmlfile\shell\open\command´) do |reg| - ENV["RWDBROWSER"] = reg[""] - end - rescue NameError - puts "Not found." - end - end - - if not ENV.include?("RWDBROWSER") and false # ??? - s = ENV["HOME"] ; s = s + "/.rwdrc" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil?) - s = ENV["USERPROFILE"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil?) - s = ENV["windir"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil?) - - if not rcfile.nil? - puts "Creating #{rcfile} ..." - puts "" - puts "# This is the first time you start a RubyWebDialog application." - puts "# I have to know your favorite browser." - puts "# " - puts "# Put the full path to your favorite browser between the quotes" - puts "# (\"...\") after RWDBROWSER= and remove the hash (#) at the" - puts "# beginning of the line." - puts "# " - puts "# Restart your application." - puts "" - - File.open(rcfile, "a") do |f| - f.puts "# This is the first time you start a RubyWebDialog application." - f.puts "# I have to know your favorite browser." - f.puts "# " - f.puts "# Put the full path to your favorite browser between the quotes" - f.puts "# (\"...\") after RWDBROWSER= and remove the hash (#) at the" - f.puts "# beginning of the line." - f.puts "# " - f.puts "# Restart your application." - f.puts "" - f.puts "#RWDBROWSER=\"...\"" - end - end - - if windows? - system("notepad #{rcfile}") +end - sleep 1 - else - puts "Please edit #{rcfile}." +unless ENV.include?("RWDBROWSER") + begin + puts "Looking for default browser..." + Win32::Registry::HKEY_CLASSES_ROOT.open(´htmlfile\shell\open\command´) do |reg| + ENV["RWDBROWSER"] = reg[""] end - - exit + rescue NameError + puts "Not found." end end +unless ENV.include?("RWDPORTS") + ENV["RWDPORTS"] = "7701-7709" +end + trap("INT") {puts "Terminating..." ; exit} $SAFE = 2 @@ -155,7 +115,7 @@ res = "" res = res + "<row valign=´top´>" - res = res + "<radio name=´#{key.to_html}´ value=´#{value.to_html}´/>" if not key.nil? + res = res + "<radio name=´#{key.to_html}´ value=´#{value.to_html}´/>" unless key.nil? res = res + self.collect{|s| "<p align=´left´>#{s.to_html}</p>"}.join("") res = res + "</row>" @@ -212,11 +172,11 @@ end class Hash - def rwd_table(field, joinwith=@sep, headers=nil) + def rwd_table(field=nil, joinwith=nil, headers=nil) res = [] res << "<table>" - res << headers.rwd_headers(true) if not headers.nil? + res << headers.rwd_headers((not field.nil?)) if not headers.nil? self.keys.numsort.each do |key| key2 = key value2 = self[key] @@ -233,8 +193,8 @@ end class EVTable - def rwd_table(key, joinwith) - super(key, joinwith, @headers) + def rwd_table(field=nil, joinwith=@sep) + super(field, joinwith, @headers) end def rwd_form(prefix="", key=nil, twoparts=false) @@ -685,9 +645,19 @@ new(File.new(rwdfile).readlines, *args) end - def serve(port=1234, auth=nil, realm=self.class.to_s) + def serve(port=nil, auth=nil, realm=self.class.to_s) + exit if $rwd_exit + raise "RWD is not initialized." if @rwd_xml.nil? + low, high = ENV["RWDPORTS"].split(/[^\d+]/) + high = low if high.nil? + low, high = low.to_i, high.to_i + + port = TCPServer.freeport(low, high) if port.nil? + raise "No free TCP port." if port.nil? + port = port.to_i + @rwd_server = RWDServer.new(self, port, auth, realm) end @@ -950,11 +920,11 @@ #@ie = IE.new("http://localhost:#{port}/") #else if windows? - system("#{ENV["RWDBROWSER"]} \"http://localhost:#{port}/\"") + system("#{ENV["RWDBROWSER"]} \"http://localhost:#{port}/\"".gsub(/%port%/, port.to_s)) elsif cygwin? - system("#{ENV["RWDBROWSER"].gsub(/\\/, "/").gsub(/ /, "\ ")} \"http://localhost:#{port}/\"") + system("#{ENV["RWDBROWSER"].gsub(/\\/, "/").gsub(/ /, "\ ")} \"http://localhost:#{port}/\"".gsub(/%port%/, port.to_s)) else - system("#{ENV["RWDBROWSER"]} \"http://localhost:#{port}/\"") + system("#{ENV["RWDBROWSER"]} \"http://localhost:#{port}/\"".gsub(/%port%/, port.to_s)) end #end diff -ur rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/sgml.lib.rb rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/sgml.lib.rb --- rubywebdialogs-0.0.8.tar.gz/rubywebdialogs/lib/sgml.lib.rb 2004-05-05 23:40:17.000000000 +0200 +++ rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/sgml.lib.rb 2004-05-15 11:16:23.000000000 +0200 @@ -122,7 +122,7 @@ def buildobjects(string) @objects = [] - string.splitblocks(["<!--", "<!", "<?", "<"], ["-->", ">", "?>", ">"]).each do |type, s| + string.splitblocks(["<!--", "-->"], ["<!", ">"], ["<?", "?>"], ["<", ">"]).each do |type, s| case type when 0 then @objects << Text.new(s) when 1 then @objects << Comment.new(s) @@ -156,7 +156,7 @@ def verwerktag2(string) a = [] - string.splitblocks(["´", ´"´], ["´", ´"´]).collect do |type, s| + string.splitblocks(["´", "´"], [´"´, ´"´]).collect do |type, s| case type when 0 if self.class.to_s == "HTML" diff -ur rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/init.rb rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/init.rb --- rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/init.rb 2004-05-15 11:16:23.000000000 +0200 +++ rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/init.rb 2004-08-21 10:56:03.000000000 +0200 @@ -1,9 +1,19 @@ require "rbconfig" +def mkdirrec(dir) + pdir = File.dirname(dir) + + if not pdir.empty? and not File.directory?(pdir) + mkdirrec (pdir) + end + + Dir.mkdir(dir) rescue nil +end + FromDirs = [".", "./lib", "./rubylib/lib"] ToDir = Config::CONFIG["sitelibdir"] + "/ev" -Dir.mkdir(ToDir) if not File.directory?(ToDir) +mkdirrec(ToDir) if not File.directory?(ToDir) FromDirs.each do |fromdir| fromdir = Dir.pwd if fromdir == "." diff -ur rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/install.rb rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/install.rb --- rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/install.rb 2004-05-15 11:16:23.000000000 +0200 +++ rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/install.rb 2004-08-21 10:56:03.000000000 +0200 @@ -1,9 +1,19 @@ require "rbconfig" +def mkdirrec(dir) + pdir = File.dirname(dir) + + if not pdir.empty? and not File.directory?(pdir) + mkdirrec (pdir) + end + + Dir.mkdir(dir) rescue nil +end + FromDirs = [".", "./lib", "./rubylib/lib"] ToDir = Config::CONFIG["sitelibdir"] + "/ev" -Dir.mkdir(ToDir) if not File.directory?(ToDir) +mkdirrec(ToDir) if not File.directory?(ToDir) FromDirs.each do |fromdir| fromdir = Dir.pwd if fromdir == "." diff -ur rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/ftools.lib.rb rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/ftools.lib.rb --- rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2005-06-04 14:41:58.713878600 +0200 +++ rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2004-08-21 10:56:03.000000000 +0200 @@ -0,0 +1,161 @@ +require "ftools" + +class Dir + def self.mkdirrec(dir) + pdir = File.dirname(dir) + + if not pdir.empty? and not File.directory?(pdir) + Dir.mkdirrec(pdir) + end + + Dir.mkdir(dir) rescue nil + end + + def self.copy(from, to) + if File.directory?(from) + pdir = Dir.pwd + todir = File.expand_path(to) + + mkdirrec(todir) + + Dir.chdir(from) + Dir.new(".").each do |e| + Dir.copy(e, todir+"/"+e) if not [".", ".."].include?(e) + end + Dir.chdir(pdir) + else + todir = File.dirname(File.expand_path(to)) + + mkdirrec(todir) + + File.copy(from, to) + end + end + + def self.move(from, to) + Dir.copy(from, to) + Dir.rm_rf(from) + end + + def self.rm_rf(entry) + if File.ftype(entry) == "directory" + pdir = Dir.pwd + + Dir.chdir(entry) + Dir.new(".").each do |e| + Dir.rm_rf(e) if not [".", ".."].include?(e) + end + Dir.chdir(pdir) + + Dir.delete(entry) + else + File.delete(entry) + end + end + + def self.find(entry=nil, mask=nil) + entry = @dir if entry.nil? + + entry.gsub!(/[\/\\]*$/, "") unless entry.nil? + + res = [] + + if File.directory?(entry) + pdir = Dir.pwd + + res += ["%s/" % entry] if mask.nil? or entry =~ mask + + Dir.chdir(entry) + Dir.new(".").each do |e| + res += Dir.find(e, mask).collect{|e| entry+"/"+e} unless [".", ".."].include?(e) + end + Dir.chdir(pdir) + else + res += [entry] if mask.nil? or entry =~ mask + end + + res + end +end + +class File + def self.rollbackup(file, mode=nil) + backupfile = file + ".RB.BACKUP" + controlfile = file + ".RB.CONTROL" + + File.touch(file) unless File.file?(file) + + # Rollback + + if File.file?(backupfile) and File.file?(controlfile) + $stdout.puts "Restoring #{file}..." + + File.copy(backupfile, file) # Rollback from phase 3 + end + + # Reset + + File.delete(backupfile) if File.file?(backupfile) # Reset from phase 2 or 3 + File.delete(controlfile) if File.file?(controlfile) # Reset from phase 3 or 4 + + # Backup + + File.copy(file, backupfile) # Enter phase 2 + File.touch(controlfile) # Enter phase 3 + + # The real thing + + if block_given? + if mode.nil? + yield + else + File.open(file, mode) do |f| + yield(f) + end + end + end + + # Cleanup + + File.delete(backupfile) # Enter phase 4 + File.delete(controlfile) # Enter phase 5 + + # Return, like File.open + + if block_given? + return nil + else + return File.open(file, (mode or "r")) + end + end + + def self.touch(file) + File.open(file, "a"){|f|} + end + + def self.which(file) + res = nil + + if windows? + file = file.gsub(/\.exe$/i, "") + ".exe" + sep = ";" + else + sep = ":" + end + + catch :stop do + ENV["PATH"].split(/#{sep}/).reverse.each do |d| + if File.directory?(d) + Dir.new(d).each do |e| + if e.downcase == file.downcase + res = File.expand_path(e, d) + throw :stop + end + end + end + end + end + + res + end +end diff -ur rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/net.lib.rb --- rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-05-15 11:16:23.000000000 +0200 +++ rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-08-21 10:56:03.000000000 +0200 @@ -1,4 +1,5 @@ require "ev/ruby" +require "ev/ftools" #alias old_timeout :timeout require "net/http" #alias timeout :old_timeout @@ -26,16 +27,68 @@ end class TCPServer - def self.freeport(from, to) + def self.freeport(from, to, remote=false) + if windows? + TCPServer.freeport_windows(from, to, remote) + else + TCPServer.freeport_linux(from, to, remote) + end + end + + def self.freeport_linux(from, to, remote) + ports = (from..to).to_a + port = nil + res = nil + + while res.nil? and not ports.empty? + begin + port = ports[0] + ports.delete(port) + + io = TCPServer.new(remote ? "0.0.0.0" : "localhost", port) + + res = [port, io] + rescue + end + end + + res = [nil, nil] if res.nil? + + port, io = res + + return port, io + end + + def self.freeport_windows(from, to, remote) + ports = (from..to).to_a + port = nil + res = nil + + while res.nil? and not ports.empty? + begin + port = ports.any + ports.delete(port) + + io = TCPSocket.new("localhost", port) + io.close + rescue + res = port + end + end + + port, io = res + + return port, io + end + + def self.freeport_windows2(from, to, remote) res = nil port = from while res.nil? and port <= to begin - #evtimeout(0.1) do - io = TCPSocket.new("localhost", port) - io.close - #end + io = TCPSocket.new("localhost", port) + io.close port += 1 rescue @@ -134,7 +187,7 @@ vars = nil if @vars.empty? anchor = nil if @anchor.empty? - res = URI::HTTP.new(@protocol, @userpass, @host, port, nil, @path, nil, vars, @anchor).to_s + res = URI::HTTP.new(@protocol, @userpass, @host, port, nil, @path, nil, vars, @anchor).to_s.from_html res.gsub!(/@/, "") if (@userpass.nil? or @userpass.empty?) @@ -181,6 +234,8 @@ @protocol, @code, @text = firstline.split(/ */, 3) + @code = @code.to_i + if not rest.nil? rest.split(/\r*\n/).each do |line| key, value = line.split(/ /, 2) @@ -274,11 +329,11 @@ end def self.get(uri, form={}) - res = Array.new + post = Array.new form.each_pair do |var, value| - res << "#{var.to_html}=#{value.to_html}" + post << "#{var.to_html}=#{value.to_html}" end - post = res.join("?") + post = post.join("?") data = nil @@ -296,10 +351,17 @@ end if post.empty? - io.write("GET #{uri.path or ´/´}#{uri.varstring.empty? ? ´´ : ´?´ + uri.varstring} HTTP/1.0\r\nHost: #{host}\r\n\r\n") + io.write "GET %s%s HTTP/1.0\r\n" % [(uri.path or ´/´), (uri.varstring.empty? ? ´´ : ´?´ + uri.varstring)] + io.write "Host: %s\r\n" % host + io.write "\r\n" else - io.write("POST #{uri.path or ´/´}#{uri.varstring.empty? ? ´´ : ´?´ + uri.varstring} HTTP/1.0\r\nHost: #{host}\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: #{post.length}\r\n\r\n") - io.write(post) + io.write "POST %s%s HTTP/1.0\r\n" % [(uri.path or ´/´), (uri.varstring.empty? ? ´´ : ´?´ + uri.varstring)] + io.write "Host: %s\r\n" % host + io.write "Content-Type: application/x-www-form-urlencoded\r\n" + io.write "Content-Length: %s\r\n" % post.length + io.write "Pragma: \r\n" + io.write "\r\n" + io.write post end else proxy = EVURI.new($proxy) @@ -310,10 +372,19 @@ io = TCPSocket.new(host, port.zero? ? 8080 : port) if post.empty? - io.write("GET #{uri} HTTP/1.0\r\n#{"Proxy-Authorization: Basic "+$proxy_auth+"\r\n" if not $proxy_auth.nil?}\r\n\r\n") + io.write "GET %s HTTP/1.0\r\n" % uri + io.write "Host: %s\r\n" % host + io.write "Proxy-Authorization: Basic %s\r\n" % $proxy_auth unless $proxy_auth.nil? + io.write "\r\n" else - io.write("POST #{uri} HTTP/1.0\r\n#{"Proxy-Authorization: Basic "+$proxy_auth+"\r\n" if not $proxy_auth.nil?}Content-Type: application/x-www-form-urlencoded\r\nContent-Length: #{post.length}\r\n\r\n") - io.write(post) + io.write "POST %s HTTP/1.0\r\n" % uri + io.write "Host: %s\r\n" % host + io.write "Proxy-Authorization: Basic %s\r\n" % $proxy_auth unless $proxy_auth.nil? + io.write "Content-Type: application/x-www-form-urlencoded\r\n" + io.write "Content-Length: %s\r\n" % post.length + io.write "Pragma: \r\n" + io.write "\r\n" + io.write post end end @@ -334,6 +405,8 @@ if header.header["transfer-encoding"] == "chunked" data = Chunk.new(data).to_s if not data.nil? end + + data = nil unless header.code == 200 end rescue data = nil @@ -362,7 +435,7 @@ expire = 356*24*60*60 - if FileTest.file?(file) and (Time.new.to_f - File.stat(file).mtime.to_f < expire) + if File.file?(file) and (Time.new.to_f - File.stat(file).mtime.to_f < expire) @@mutex.synchronize do File.open(file, "rb") {|f| data = f.read} end @@ -418,6 +491,10 @@ def to_s "#{@method} #{@uri} #{@protocol}\r\n" end + + def inspect + "(RequestRequest: %s)" % [@method, @path, @data, @protocol].join(", ") + end end class Request < Hash @@ -435,12 +512,14 @@ @request = RequestRequest.new(firstline.strip) - line = @io.gets.strip - while not line.empty? do + line = @io.gets + line = line.strip unless line.nil? + while not line.nil? and not line.empty? key, value = line.split(" ", 2) self[key.sub(/:$/, "").downcase] = value - line = @io.gets.strip + line = @io.gets + line = line.strip unless line.nil? end cookie = self["cookie"] @@ -452,12 +531,12 @@ end if not @request.method.nil? - case @request.method + case @request.method.upcase when "HEAD" when "GET" @vars = RequestGet.new(@request.data.nil? ? "" : @request.data) when "POST" - data = @io.read(self["content-length"].to_i) + data = (@io.read(self["content-length"].to_i) or "") @vars = RequestPost.new((self["content-type"] == "application/x-www-form-urlencoded") ? data : "") else puts "Unknown request (´#{firstline}´)." @@ -476,14 +555,20 @@ end res end + + def inspect + "(Request: %s)" % [@peeraddr, @request.inspect, @vars.inspect, @cookies.inspect, super].join(", ") + end end class Response < Hash attr_writer :response + attr_reader :cookies def initialize(io) @io = io @response = "HTTP/1.0 200 OK" + @cookies = {} @data = "" end @@ -497,23 +582,36 @@ self.each do |k, v| res << "#{k}: #{v}\r\n" end + + @cookies.each do |k, v| + res << "Set-Cookie: %s=%s;\r\n" % [k, v] + end + res end def << (s) @data << s end + + def inspect + "(Response: %s)" % [@response, @data].join(", ") + end end class HTTPServer @@times = {} - def self.serve(port=80, remote=false, auth=nil, realm="ev/net") + def self.serve(portio=80, remote=false, auth=nil, realm="ev/net") + port, server = portio + begin - server = TCPServer.new(remote ? "0.0.0.0" : "localhost", port) + server = TCPServer.new(remote ? "0.0.0.0" : "localhost", port) if server.nil? + puts "Just point your browser to http://localhost:#{port}/ ..." rescue server = nil + puts "Port #{port} is in use." end @@ -562,7 +660,7 @@ if auth.kind_of? String file = "#{home}/#{auth}" auths = {} - auths = Hash.file(file) if FileTest.file?(file) + auths = Hash.file(file) if File.file?(file) else auths = auth end diff -ur rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/ruby.lib.rb rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/ruby.lib.rb --- rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-05-15 11:16:23.000000000 +0200 +++ rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-08-21 10:56:03.000000000 +0200 @@ -1,7 +1,26 @@ require "cgi" require "rbconfig" -Thread.abort_on_exception = true +#tekens = ´\w\~\@\#\$\%\^\&\*\-\+´ +tekens = ´^\s\r\n\`\!\(\)\[\]\{\}\<\>\,\.\/\?\\\|\=\;\:\"´ + +#tekens11 = ´\w´ +tekens11 = tekens + "´" + +tekens21 = tekens + "´" +tekens22 = tekens +tekens23 = tekens + "´" + +tekens31 = ´\w\s\r\n´ + +RegExpStringWord = "([#{tekens11}]+)" ; RegExpWord = Regexp.new(RegExpStringWord) +RegExpStringWord2 = "([#{tekens21}]([#{tekens22}]*[#{tekens23}])?)" ; RegExpWord2 = Regexp.new(RegExpStringWord2) +RegExpStringText = "([#{tekens31}]+)" ; RegExpText = Regexp.new(RegExpStringText) +RegExpStringFile = ´(\w[\w\.\-]*)´ ; RegExpFile = Regexp.new(RegExpStringFile) +RegExpStringEmail = ´([\w\-\.]+@[\w\-\.]+)´ ; RegExpEmail = Regexp.new(RegExpStringEmail) +RegExpStringURL = ´(\w+:\/\/[\w\.\-]+(:\d*)?\/[\w\.\-\/\#\?\=\%]*)´ ; RegExpURL = Regexp.new(RegExpStringURL) +RegExpStringPrint = ´([\w \t\r\n\`\~\!\@\#\$\%\^\&\*\(\)\-\+\=\[\]\{\}\;\:\´\"\,\.\/\<\>\?\\\|]+)´ ; RegExpPrint = Regexp.new(RegExpStringPrint) +RegExpStringDiff = ´(^[\-\+]([^\-\+].*)?)´ ; RegExpDiff = Regexp.new(RegExpStringDiff) module Enumerable def deep_dup @@ -13,6 +32,16 @@ end end +class Thread + def self.background(*args) + new(*args) do |*args| + Thread.pass + + yield(*args) + end + end +end + class Object alias deep_dup :dup alias deep_clone :clone @@ -20,6 +49,10 @@ def to_fs to_s end + + def ids + id + end end class Numeric @@ -28,6 +61,21 @@ end end +class Integer + def oct + n = self + res = [] + + while n > 8 + n, x = n.divmod(8) + res << x + end + res << n + + res.reverse.join("") + end +end + class String def chomp!(dummy=nil) self.gsub!(/[\r\n]*\z/, "") @@ -65,6 +113,13 @@ self.gsub(/[[:blank:]]+/, " ") end + def compressperline + res = self.split(/\n/) + res.collect!{|line| line.compress} + res.delete_if{|line| line.empty?} + res.join("\n") + end + def numeric? d, a, n = [self].to_par @@ -75,7 +130,7 @@ res = [] IO.popen(self, "w+") do |f| - f.puts input if not input.nil? + f.puts input unless input.nil? f.close_write res = f.readlines if output @@ -100,8 +155,8 @@ enddelimiters = [] delimiters.each do |k, v| - begindelimiters << k - enddelimiters << v + begindelimiters << k.downcase + enddelimiters << v.downcase end bd = begindelimiters.collect {|s| Regexp.escape(s)} @@ -113,36 +168,45 @@ res = [] type = 0 tmp = "" + bs = "" es = "" - self.split(/(#{be}|#{ee})/).each do |s| + self.split(/(#{ee}|#{be})/i).each do |s| if type == 0 - if begindelimiters.include?(s) - type = begindelimiters.index(s)+1 + if begindelimiters.include?(s.downcase) + i = begindelimiters.index(s.downcase) + type = i+1 tmp = s - es = enddelimiters[begindelimiters.index(s)] + bs = s.downcase + es = enddelimiters[i] else - res << [0, s] if not s.empty? + res << [0, s] unless s.empty? end else - if s == es + if s.downcase == es res << [type, tmp + s] type = 0 tmp = "" + bs = "" es = "" else - tmp = tmp + s + if s.downcase == bs + res << [0, tmp] + tmp = s + else + tmp = tmp + s + end end end end - res << [0, tmp] if not tmp.empty? + res << [0, tmp] unless tmp.empty? return res end def splitwords(tokens=[]) - tokens = [tokens] if not tokens.kind_of?(Array) + tokens = [tokens] unless tokens.kind_of?(Array) res = [] self.splitblocks(["´", "´"], [´"´, ´"´]).each do |type, s| @@ -167,10 +231,10 @@ def uncomment res = [] - self.splitblocks(["´", "´"], [´"´, ´"´], ["/*", "*/"], ["<!--", "-->"], ["#", "\n"]).each do |type, s| + self.splitblocks(["´", "´"], [´"´, ´"´], ["#", "\n"]).each do |type, s| case type when 0, 1, 2 then res << s - when 3, 4, 5 + when 3 end end @@ -313,10 +377,12 @@ end def subset(fields, values, results, exact=true, emptyline=nil, joinwith=nil) - fields = [fields] if not fields.kind_of? Array - values = [values] if not values.kind_of? Array - results = [results] if not results.kind_of? Array - res = [] + fields = [fields] unless fields.kind_of? Array + values = [values] unless values.kind_of? Array + results = [results] unless results.kind_of? Array + emptyline = emptyline.downcase unless emptyline.nil? + res = self.dup + res.delete_if {true} self.each do |l| ok = true @@ -331,25 +397,33 @@ correction = 0 end - 0.upto(c.length-1) do |n| - if fields.include?(n+correction) - v = values[fields.index(n+correction)] - if not emptyline.nil? and not v.downcase == emptyline.downcase + #catch :stop do + values2 = values.dup + fields.each do |f| + v = values2.shift + v = v.downcase unless v.nil? + if emptyline.nil? or (not v == emptyline) if exact - ok = false unless (v.nil? or c[n].downcase == v.downcase) + unless (v.nil? or c[f-correction].downcase == v) + ok = false + #throw :stop + end else - ok = false unless (v.nil? or c[n].downcase.include?(v.downcase)) + unless (v.nil? or c[f-correction].downcase.include?(v)) + ok = false + #throw :stop + end end end end - end + #end if ok res2 = [] results.each do |n| res2 << c[n-1] end - res2 = res2.join(joinwith) if not joinwith.nil? + res2 = res2.join(joinwith) unless joinwith.nil? res << res2 end end @@ -405,8 +479,10 @@ def self.file(file) res = [] - File.new(file).readlines.uncomment.chomp.each do |line| - res << line + File.open(file) do |f| + f.readlines.uncomment.chomp.each do |line| + res << line + end end res @@ -443,10 +519,22 @@ res end + def any + if empty? + nil + else + self[rand(self.length)] + end + end + def minmax min, value, max = self [min, [value, max].min].max end + + def ids + collect{|e| e.ids} + end end class Hash @@ -455,21 +543,21 @@ org = Hash.file(file) if (append and File.file?(file)) self.sort.each do |k, v| - org[k] = v + org[k] = v end File.open(file, "w") do |f| org.sort.each do |k, v| - #f.puts "´%s´=´%s´" % [k, v] - f.puts "%s = %s" % [k, v] + f.puts "%s\t= %s" % [k, v] end end end def subset(fields, values, results=nil, exact=true, emptyline=nil, joinwith=nil) - fields = [fields] if not fields.kind_of? Array - values = [values] if not values.kind_of? Array - results = [results] if not results.kind_of? Array + fields = [fields] unless fields.kind_of? Array + values = [values] unless values.kind_of? Array + results = [results] unless results.kind_of? Array + emptyline = emptyline.downcase unless emptyline.nil? res = self.dup res.delete_if {true} @@ -486,18 +574,26 @@ correction = 0 end - 0.upto(c.length-1) do |n| - if fields.include?(n+correction) - v = values[fields.index(n+correction)] - if emptyline.nil? or (not emptyline.nil? and not v.downcase == emptyline.downcase) + #catch :stop do + values2 = values.dup + fields.each do |f| + v = values2.shift + v = v.downcase unless v.nil? + if emptyline.nil? or (not v == emptyline) if exact - ok = false unless (v.nil? or c[n].downcase == v.downcase) + unless (v.nil? or c[f-correction].downcase == v) + ok = false + #throw :stop + end else - ok = false unless (v.nil? or c[n].downcase.include?(v.downcase)) + unless (v.nil? or c[f-correction].downcase.include?(v)) + ok = false + #throw :stop + end end end end - end + #end if ok res2 = [] @@ -508,7 +604,7 @@ res2 << c[n-correction] end end - res2 = res2.join(joinwith) if not joinwith.nil? + res2 = res2.join(joinwith) unless joinwith.nil? res[k] = res2 end end @@ -523,37 +619,23 @@ def self.file(file) res = {} - File.new(file).readlines.chomp.each do |line| - if not line.compress.empty? - k, v = line.split(/\s*=\s*/, 2) - res[k] = v - end - end -# File.new(file).readlines.uncomment.chomp.each do |line| -# if not line.compress.empty? -# a = line.splitwords("=") -# -# if a.size == 3 and a[1] == "=" -# res[a[0]] = a[2] -# else -# puts "Error in #{file} (not ´var=\"value\"´)." -# end -# end -# end + File.open(file) do |f| + #f.readlines.chomp.each do |line| + while line = f.gets do + line.chomp! + + unless line.empty? + k, v = line.split(/\s+=\s+/, 2) + res[k] = v + end + end + end res end -end - -class Dir - def Dir.mkdirrec(dir) - pdir = File.dirname(dir) - if not pdir.empty? and not FileTest.directory?(pdir) - mkdirrec (pdir) - end - - Dir.mkdir(dir) rescue nil + def ids + collect{|k, v| [k, v].ids} end end @@ -561,33 +643,33 @@ ObjectSpace._id2ref(id) end -def after(seconds) +def after(seconds, *args) if not seconds.nil? and not seconds.zero? - Thread.new do + Thread.new(*args) do |*args| sleep seconds - yield + yield(*args) end end end -def every(seconds) +def every(seconds, *args) if not seconds.nil? and not seconds.zero? - Thread.new do + Thread.new(*args) do |*args| loop do sleep seconds - yield + yield(*args) end end end end -def evtimeout(seconds) +def evtimeout(seconds, *args) if not seconds.nil? and not seconds.zero? t = Thread.current threads = [] res = nil - threads[1] = Thread.new do + threads[1] = Thread.new(*args) do |*args| sleep seconds begin threads[2].kill @@ -597,8 +679,8 @@ t.wakeup end - threads[2] = Thread.new do - yield + threads[2] = Thread.new(*args) do |*args| + yield(*args) begin threads[1].kill rescue NameError @@ -612,16 +694,16 @@ return res else - yield + yield(*args) end end -def evtimeoutretry(seconds) +def evtimeoutretry(seconds, *args) ok = false while not ok - evtimeout(seconds) do - yield + evtimeout(seconds, *args) do |*args| + yield(*args) ok = true end end @@ -634,7 +716,7 @@ # Seems pointless, but it´s for catching ^C under Windows... - every(1) {} + every(1) {} if windows? end def linux? @@ -664,3 +746,43 @@ def temp (ENV["TEMP"] or "/tmp").gsub(/\\/, "/") end + +def stdtmp + $stderr = $stdout = File.new("#{temp}/ruby.#{Process.pid}.log", "a") unless ARGV.include?("--rwd-exit") +end + +def bm(label="") + if $bm.nil? + require "ev/bm" + + $bm = {} + + at_exit do + format1 = "%10s %10s %10s %10s %10s %10s %10s" + format2 = "%10s %10.6f %10.6f %10.6f %10.6f %10.6f %10d" + + $stderr.puts format1 % ["LABEL", "USERCPU", "SYSCPU", "CUSERCPU", "CSYSCPU", "ELAPSED", "TIMES"] + $bm.sort{|a, b| [a[1], a[0]] <=> [b[1], b[0]]}.each do |k, v| + $stderr.puts format2 % [k, *v] + end + end + end + + label = label.to_s + res = nil + + $bm[label] = [0.0]*5 + [0] unless $bm.include?(label) + + if block_given? + bm = Benchmark.measure{res = yield} + bma = bm.to_a # [dummy label, user CPU time, system CPU time, childrens user CPU time, childrens system CPU time, elapsed real time] + + 0.upto(4) do |n| + $bm[label][n] += bma[n+1] + end + end + + $bm[label][5] += 1 + + res +end diff -ur rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-05-15 11:16:23.000000000 +0200 +++ rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-08-21 10:56:03.000000000 +0200 @@ -8,7 +8,7 @@ require "win32ole" require "win32/registry" rescue LoadError - $".push "win32ole.rb" + $".push "win32ole.so" $".push "win32/registry.rb" end @@ -16,12 +16,17 @@ $rwd_debug = ($rwd_debug or false) $rwd_border = ($rwd_border or 0) +ARGV.delete_if do |arg| + arg =~ /^--rwd-/ +end + + RWDEmptyline = "..." rcfile = nil -s = ENV["HOME"] ; s = s + "/.rwdrc" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and FileTest.file?(s)) -s = ENV["USERPROFILE"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and FileTest.file?(s)) -s = ENV["windir"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and FileTest.file?(s)) +s = ENV["HOME"] ; s = s + "/.rwdrc" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and File.file?(s)) +s = ENV["USERPROFILE"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and File.file?(s)) +s = ENV["windir"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and File.file?(s)) AL = "align=´left´" AC = "align=´center´" @@ -41,9 +46,19 @@ unless ENV.include?("RWDBROWSER") begin puts "Looking for default browser..." - Win32::Registry::HKEY_CLASSES_ROOT.open(´htmlfile\shell\open\command´) do |reg| - ENV["RWDBROWSER"] = reg[""] + + filetype = nil + application = nil + + Win32::Registry::HKEY_CLASSES_ROOT.open(´.html´) do |reg| + filetype = reg[""] end + + Win32::Registry::HKEY_CLASSES_ROOT.open(filetype + ´\shell\open\command´) do |reg| + application = reg[""] + end + + ENV["RWDBROWSER"] = application rescue NameError puts "Not found." end @@ -234,7 +249,7 @@ end class OpenTag - def prechildren(res, before, after, vars, switches, help, oneormorefields, firstaction, tabs, tab) + def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab) bef = before[-1] res.concat Format % ["Before", @subtype] if ($rwd_debug and not bef.nil?) res.concat bef if not bef.nil? @@ -247,9 +262,13 @@ valign = VA valign = "valign=´#{@args["valign"]}´" if @args.include?("valign") - value = "" - value = vars[@args["name"]] if vars.include?(@args["name"]) - value = @args["value"] if @args.include?("value") + value1 = "" + value1 = varshtml[@args["name"]] if varshtml.include?(@args["name"]) + value1 = @args["value"] if @args.include?("value") + + value2 = "" + value2 = varsstring[@args["name"]] if varsstring.include?(@args["name"]) + value2 = @args["value"] if @args.include?("value") case @subtype when "application" @@ -260,7 +279,7 @@ res.concat(template($rwd_html1, args)) when "p" then res.concat "<p #{align}>" - when "pre" then res.concat "<pre>" + when "pre" then res.concat "<pre #{align}>" when "big" then res.concat "<p #{align}><big>" when "small" then res.concat "<p #{align}><small>" when "list" then res.concat "<ul #{align}>" @@ -281,22 +300,22 @@ when "horizontal" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´><tr #{align} #{valign}>" when "table" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" when "row" then res.concat "<tr #{align} #{valign}>" - when "hidden" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´hidden´>" + when "hidden" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´hidden´>" when "text" maxlength = "" maxlength = "maxlength=´%s´" % @args["maxlength"] if @args.include?("maxlength") - res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´text´ #{maxlength}>" + res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´text´ #{maxlength}>" oneormorefields << "true" when "textarea" - res.concat "<p #{align}><textarea name=´#{@args["name"]}´>#{value}</textarea>" + res.concat "<p #{align}><textarea name=´#{@args["name"]}´ rows=´25´ cols=´80´>#{value2.crlf}</textarea>" oneormorefields << "true" when "password" maxlength = "" maxlength = "maxlength=´%s´" % @args["maxlength"] if @args.include?("maxlength") - res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´password´ #{maxlength}>" + res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´password´ #{maxlength}>" oneormorefields << "true" when "checkbox" - if vars[@args["name"]] == "on" + if varshtml[@args["name"]] == "on" switches[@args["name"]] = true res.concat "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ type=´checkbox´>" else @@ -305,16 +324,16 @@ end oneormorefields << "true" when "radio" - if vars[@args["name"]] == value - res.concat "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ value=´#{value}´ type=´radio´>" + if varshtml[@args["name"]] == value1 # ??? 1 of 2? + res.concat "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ value=´#{value1}´ type=´radio´>" else - res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value}´ type=´radio´>" + res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´radio´>" end oneormorefields << "true" when "select" res.concat "<select #{align} name=´#{@args["name"]}´ width=´#{@args["width"]}´>" name = @args["name"] - $select = vars[name] + $select = varshtml[name] oneormorefields << "true" when "option" if $select == @children[0].text @@ -406,7 +425,7 @@ after.push(aft) end - def postchildren(res, before, after, vars, switches, help, oneormorefields, firstaction, tabs, tab) + def postchildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab) case @subtype when "vertical", "window", "helpwindow", "tabs", "tab" res.concat Format % ["BefPost", @subtype] if $rwd_debug @@ -485,7 +504,7 @@ a[k.upcase] = v end - a["LOGO"] = "" unless ((not vars["logo"].nil?) and FileTest.file?(vars["logo"])) + a["LOGO"] = "" unless ((not vars["logo"].nil?) and File.file?(vars["logo"])) a["HELPBUTTON"] = (not (vars["nohelpbutton"])) a["BACKBUTTONS"] = (not (vars["nobackbuttons"])) @@ -493,13 +512,15 @@ a["CLOSEBUTTON"] = (not (vars["noclosebutton"])) if a.include?("WIDTH") - a["WIDTH"] = "width=´#{a["WIDTH"]}´" + a["WIDTH1"] = "width=´#{a["WIDTH"]}´" + a["WIDTH2"] = a["WIDTH"] else - a["WIDTH"] = " " + a["WIDTH1"] = " " + a["WIDTH2"] = "1" end html.split(/\r*\n/).each do |line| - if line =~ /%[A-Z]+%/ + if line =~ /%[A-Z0-9]+%/ a.each do |k, v| v = false if (v.kind_of?(String) and v.empty?) @@ -508,7 +529,7 @@ end end - line = "<!-- #{line.scan(/%[A-Z]+%/).join(" ")} -->" if line =~ /%[A-Z]+%/ + line = "<!-- #{line.scan(/%[A-Z0-9]+%/).join(" ")} -->" if line =~ /%[A-Z0-9]+%/ end res << line @@ -519,7 +540,7 @@ end class Text - def prechildren(res, before, after, vars, switches, help, oneormorefields, firstaction, tabs, tab) + def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab) if not @text.scan(/[^ \t\r\n]/).empty? res.concat Format % ["Text", ""] if $rwd_debug res.concat "#{@text}" @@ -557,7 +578,8 @@ end def render(vars=Hash.new, switches=Hash.new, help=false, tab="") - vars2 = Hash.new + varshtml = Hash.new + varsstring = Hash.new oneormorefields = "" firstaction = "" html = "" @@ -571,7 +593,8 @@ @helprwd.gsub!(/%%#{key}%%/, value.to_s) @helprwd.gsub!(/%#{key}%/, value.to_s.to_html) - vars2[key] = value.to_s.to_html + varshtml[key] = value.to_s.to_html + varsstring[key] = value.to_s end end end @@ -592,9 +615,9 @@ end if help - helpobject.parsetree("prechildren", "postchildren", html, [""], [""], vars2, switches, false, oneormorefields, firstaction, tabs, tab) + helpobject.parsetree("prechildren", "postchildren", html, [""], [""], varshtml, varsstring, switches, false, oneormorefields, firstaction, tabs, tab) else - windowobject.parsetree("prechildren", "postchildren", html, [""], [""], vars2, switches, (not @helprwd.empty?), oneormorefields, firstaction, tabs, tab) + windowobject.parsetree("prechildren", "postchildren", html, [""], [""], varshtml, varsstring, switches, (not @helprwd.empty?), oneormorefields, firstaction, tabs, tab) end html.gsub!(/%%*[[:alnum:]_\-]+%%*/, "") if not $rwd_debug @@ -616,13 +639,13 @@ class RWDMessage < RWDWindow def initialize(msg) - super("<window title=´RWD Message´ nobackbuttons><vertical><p>#{msg}</p><back/></vertical></window>") + super("<window title=´RWD Message´ nobackbuttons noclosebutton><vertical><p>#{msg}</p><back/></vertical></window>") end end class RWDError < RWDWindow def initialize(msg) - super("<window title=´RWD Error´ nobackbuttons><vertical><p><b>Error:</b> #{msg}</p><back/></vertical></window>") + super("<window title=´RWD Error´ nobackbuttons noclosebutton><vertical><p><b>Error:</b> #{msg}</p><back/></vertical></window>") end end @@ -654,25 +677,29 @@ high = low if high.nil? low, high = low.to_i, high.to_i - port = TCPServer.freeport(low, high) if port.nil? - raise "No free TCP port." if port.nil? + io = nil + + port, io = TCPServer.freeport(low, high, (not auth.nil?)) if port.nil? + raise "No free TCP port." if port.nil? + port = port.to_i - @rwd_server = RWDServer.new(self, port, auth, realm) + @rwd_server = RWDServer.new(self, port, io, auth, realm) end - def render(res, path, post, sessionid) + def render(res, path, post, download, sessionid) # Initialize some vars. vars = Hash.new if vars.nil? @rwd_switches = Hash.new if @rwd_switches.nil? - done = false - help = false - back = false - tab = "" - @rwd_msg = nil + done = false + help = false + back = false + tab = "" + @rwd_msg = nil + @rwd_download = nil # Switches are used for checkboxes. @@ -694,17 +721,26 @@ @rwd_action = vars["rwd_action"] @rwd_action, @rwd_args = @rwd_action.split(/\//, 2) unless @rwd_action.nil? + @rwd_action, rest = @rwd_action.split(/\?/) unless @rwd_action.nil? + + unless rest.nil? + rest.each do |s| + k, v = s.split(/=/, 2) + vars[k] = v + end + end if @rwd_action =~ /^rwd_tab_/ @rwd_tab = @rwd_action.sub(/^rwd_tab_/, "") - @rwd_history[-1][2] = @rwd_tab + @rwd_history[-1][3] = @rwd_tab else case @rwd_action when "rwd_back" @rwd_history.pop @rwd_action = (@rwd_history[-1] or [nil, nil, nil])[0] - @rwd_window = (@rwd_history[-1] or [nil, nil, nil])[1] - @rwd_tab = (@rwd_history[-1] or [nil, nil, nil])[2] + @rwd_args = (@rwd_history[-1] or [nil, nil, nil])[1] + @rwd_window = (@rwd_history[-1] or [nil, nil, nil])[2] + @rwd_tab = (@rwd_history[-1] or [nil, nil, nil])[3] back = true when "rwd_help" help = true @@ -720,12 +756,13 @@ # History stuff @rwd_history = @rwd_history[-100..-1] if @rwd_history.length >= 100 - @rwd_args = [] if @rwd_args.nil? @rwd_action = "main" if @rwd_action.nil? @rwd_action = "main" if @rwd_action.empty? @rwd_window = "main" if @rwd_window.nil? @rwd_window = "main" if @rwd_window.empty? @rwd_tab = "" if @rwd_tab.nil? + @rwd_args = [] if @rwd_args.nil? + @rwd_args = [] if @rwd_action == "main" vars["rwd_action"] = @rwd_action vars["rwd_window"] = @rwd_window @@ -740,17 +777,23 @@ # Callback. if (not back) or @rwd_call_after_back.include?(@rwd_action) - begin + unless @rwd_action =~ /^rwd_/ puts "Method: #{@rwd_action}(#{@rwd_args.join(", ")})" if $rwd_debug - method(@rwd_action).call(*@rwd_args) - rescue NameError + if methods.include?(@rwd_action) + method(@rwd_action).call(*@rwd_args) + else + puts "Method ´%s´ is not defined." % @rwd_action + end end # History stuff - @rwd_history = [["main", "main", nil]] if @rwd_action == "main" - @rwd_history = [["main", "main", nil]] if @rwd_history.empty? - @rwd_history.push [@rwd_action, @rwd_window, @rwd_tab] if (@rwd_history[-1] != [@rwd_action, @rwd_window, @rwd_tab] or not @rwd_msg.nil?) + @rwd_history = [["main", nil, "main", nil]] if @rwd_action == "main" + @rwd_history = [["main", nil, "main", nil]] if @rwd_history.empty? + + a = [@rwd_action, @rwd_args, @rwd_window, @rwd_tab] + + @rwd_history.push a if (@rwd_history[-1] != a or not @rwd_msg.nil?) end end @@ -772,13 +815,20 @@ if done res << RWDDone.new(@rwd_exitbrowser).render else - if not @rwd_msg.nil? - res << RWDMessage.new(@rwd_msg).render if @rwd_msgtype == "message" - res << RWDError.new(@rwd_msg).render if @rwd_msgtype == "error" + if not @rwd_download.nil? + puts "Download: #{@rwd_window}" if $rwd_debug + + download << @rwd_download else - puts "Window: #{@rwd_window}" if $rwd_debug - puts "Tab: #{@rwd_tab}" if $rwd_debug - res << RWDWindow.new(@rwd_xml, @rwd_window).render(vars, @rwd_switches, help, @rwd_tab) + if not @rwd_msg.nil? + res << RWDMessage.new(@rwd_msg).render if @rwd_msgtype == "message" + res << RWDError.new(@rwd_msg).render if @rwd_msgtype == "error" + else + puts "Window: #{@rwd_window}" if $rwd_debug + puts "Tab: #{@rwd_tab}" if $rwd_debug + + res << RWDWindow.new(@rwd_xml, @rwd_window).render(vars, @rwd_switches, help, @rwd_tab) + end end end @@ -786,7 +836,7 @@ end def samewindow? - @rwd_history[-1][1] == @rwd_window + @rwd_history[-1][2] == @rwd_window end def message(msg) @@ -799,6 +849,10 @@ @rwd_msgtype = "error" end + def download(data) + @rwd_download = data + end + def exitbrowser @rwd_exitbrowser = true end @@ -835,6 +889,7 @@ @rack = rack.to_s @cleanup = SessionCleanup.new(self, 3600, 24*3600) if cleanup @sessions = {} + #@store = PStore.new("#{temp}/store.#{@rack}.#{user}") # ??? #@store.transaction do @@ -864,6 +919,10 @@ def delete_if(&block) @sessions.delete_if{|k, v| block.call(k, v)} end + + def include?(sessionid) + @sessions.include?(sessionid) + end end class Session < Hash @@ -884,8 +943,8 @@ end class RWDSession < Session - def render(res, path, post) - done = self["object"].render(res, path, post, @sessionid) + def render(res, path, post, download) + done = self["object"].render(res, path, post, download, @sessionid) if done res.gsub!(/\$RWD_SESSION\$/, "") @@ -898,7 +957,7 @@ end class RWDServer - def initialize(obj, port, auth, realm) + def initialize(obj, port, io, auth, realm) @object = obj @localbrowsing = false @browserstarted = false @@ -936,18 +995,22 @@ # Start server. catch :rwd_exit do - HTTPServer.serve(port, (not auth.nil?)) do |req, resp| + portio = port + portio = [port, io] unless io.nil? + HTTPServer.serve(portio, (not auth.nil?)) do |req, resp| vars = req.vars.dup + pad = req.request.path if auth.kind_of? String file = "#{home}/#{auth}" auths = {} - auths = Hash.file(file) if FileTest.file?(file) + auths = Hash.file(file) if File.file?(file) else auths = auth end - oldsessionid = vars["rwd_session"] + #oldsessionid = vars["rwd_session"] + oldsessionid = req.cookies["sessionid"] # Retrieve session. @@ -957,15 +1020,18 @@ if session.nil? if auth.nil? - session = RWDSession.new(MD5.new(req.peeraddr[3].to_s + @object.inspect.to_s).to_s) + sessionid = MD5.new(req.peeraddr[3].to_s + @object.inspect.to_s).to_s + session = RWDSession.new(sessionid) session["object"] = @object else - session = RWDSession.new(MD5.new(Time.new.to_s + req.peeraddr[3].to_s + @object.inspect.to_s).to_s) + sessionid = nil + sessionid = MD5.new(Time.new.to_s + req.peeraddr[3].to_s + @object.inspect.to_s).to_s while (sessionid.nil? or @sessions.include?(sessionid)) + session = RWDSession.new(sessionid) session["object"] = @object.clone end if oldsessionid.nil? or oldsessionid.empty? - if not auth.nil? and not auth.empty? and not session.authenticated + if not auth.nil? and not auth.empty? and not session.authenticated and pad != "/pixel.gif" # Check authentication @@ -975,6 +1041,7 @@ if us.nil? or pa.nil? or auths[us] != pa session = RWDSession.new session["object"] = RWDLogin.new(realm) + pad = "/" else session.authenticated = true @sessions[session.sessionid] = session @@ -994,20 +1061,33 @@ session.touch - if req.request.path == "/" + if pad == "/" # Serve methods/callbacks. # Build new page. - res = "" + download = "" + res = "" - done = session.render(res, req.request.path, vars) + done = session.render(res, pad, vars, download) begin - resp["Content-Type"] = "text/html" + if download.empty? + resp["Content-Type"] = "text/html" + if done + resp.cookies["sessionid"] = "" + else + resp.cookies["sessionid"] = session.sessionid + end + + resp << res + else + resp["Content-Type"] = "application/octet-stream" + resp["Content-Disposition"] = "attachment; filename=data" - resp << res + resp << download + end rescue puts "Sending response to browser failed." @@ -1036,13 +1116,13 @@ # Serve files. - if req.request.path == "/pixel.gif" + if pad == "/pixel.gif" resp["Cache-Control"] = "max-age=86400" resp["Content-Type"] = "image/gif" resp << $rwd_pixel else - if (FileTest.file?(req.request.path.sub(/^\/*/, ""))) - resp << File.new(req.request.path.sub(/^\/*/, ""), "rb").read rescue nil + if (File.file?(pad.sub(/^\/*/, ""))) + resp << File.new(pad.sub(/^\/*/, ""), "rb").read rescue nil else resp.response = "HTTP/1.0 404 NOT FOUND" end @@ -1199,7 +1279,7 @@ <td align=´center´> - <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´ %WIDTH%> + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´ %WIDTH1%> <tr align=´center´> <td align=´center´ bgcolor=´#444488´> @@ -1223,7 +1303,7 @@ </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´%WIDTH2%´></td> </tr> <tr align=´center´> diff -ur rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/sgml.lib.rb rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/sgml.lib.rb --- rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/sgml.lib.rb 2004-05-15 11:16:23.000000000 +0200 +++ rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/sgml.lib.rb 2004-08-21 10:56:03.000000000 +0200 @@ -25,11 +25,11 @@ end def prechildren_to_s(res) - res << "#{@text}" + res << "#{CGI.unescapeHTML(@text)} " end def prechildren_to_sgml(res) - res << "#{@text}" + res << "#{CGI.unescapeHTML(@text)}" end end @@ -73,6 +73,7 @@ def initialize(subtype, args={}) super(subtype) @args = args + @text = "" end end @@ -97,7 +98,7 @@ end end - res << "<#{a.join(" ")}>" + res << "<#{a.join(" ")}>" + @text end def postchildren_to_sgml(res) @@ -122,84 +123,52 @@ def buildobjects(string) @objects = [] - string.splitblocks(["<!--", "-->"], ["<!", ">"], ["<?", "?>"], ["<", ">"]).each do |type, s| - case type - when 0 then @objects << Text.new(s) - when 1 then @objects << Comment.new(s) - when 2 then @objects << Special.new(s) - when 3 then @objects << Instruction.new(s) - when 4 - - tag, args, open, close = verwerktag1(s) - - @objects << OpenTag.new(tag.dup, args.dup) if open - @objects << CloseTag.new(tag.dup, args.dup) if close - end - end - end - - def verwerktag1(string) - res = nil - - if @tagcache.include? string - res = @tagcache[string] - - else - res = verwerktag2(string) - - @tagcache[string] = res - end - - return res - end - - def verwerktag2(string) - a = [] - - string.splitblocks(["´", "´"], [´"´, ´"´]).collect do |type, s| - case type - when 0 - if self.class.to_s == "HTML" - s.splitwords(["<", ">"]).each do |w| - d = w.split("=", 2) - - if d.length == 1 - a << d[0] - else - a << d[0] if not d[0].nil? and not d[0].empty? - a << "=" - a << d[1] if not d[1].nil? and not d[1].empty? + verwerk3 = + lambda do |string| + a = [] + + string[1..-2].splitblocks(["´", "´"], [´"´, ´"´]).collect do |type, s| + case type + when 0 + if self.class.to_s == "HTML" + s.splitwords.each do |w| + d = w.split("=", 2) + + if d.length == 1 + a << d[0] + else + a << d[0] if not d[0].nil? and not d[0].empty? + a << "=" + a << d[1] if not d[1].nil? and not d[1].empty? + end end + else + a.concat s.splitwords(["/", "="]) end - else - a.concat s.splitwords(["<", "/", "=", ">"]) + when 1, 2 then a << s end - when 1, 2 then a << s end - end - - a = a[1..-2] - open = false - close = false - - if not a.nil? + + open = false + close = false + a = a[0].splitwords("/") + a[1..-1] - + if a[0] == "/" close = true a.shift else open = true end - + if a[-1] == "/" close = true a.pop end - + tag = a.shift.downcase args = {} - + while not a.length.zero? if a.length >= 3 and a[1] == "=" key = a.shift.downcase @@ -211,9 +180,40 @@ args[key] = "" end end + + [tag, args, open, close] + end + + verwerk2 = + lambda do |string| + if @tagcache.include? string + res = @tagcache[string] + else + res = verwerk3.call(string) + + @tagcache[string] = res + end + + res + end + + verwerk1 = + lambda do |string| + tag, args, open, close = verwerk2.call(string) + + @objects << OpenTag.new(tag.dup, args.dup) if open + @objects << CloseTag.new(tag.dup, args.dup) if close end - return [tag, args, open, close] + string.splitblocks(["<!--", "-->"], ["<!", ">"], ["<?", "?>"], ["<", ">"]).each do |type, s| + case type + when 0 then @objects << Text.new(s) + when 1 then @objects << Comment.new(s) + when 2 then @objects << Special.new(s) + when 3 then @objects << Instruction.new(s) + when 4 then verwerk1.call(s) + end + end end def to_s diff -ur rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/tree.lib.rb rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/tree.lib.rb --- rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/lib/tree.lib.rb 2004-05-15 11:16:23.000000000 +0200 +++ rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/tree.lib.rb 2004-08-21 10:56:03.000000000 +0200 @@ -157,7 +157,7 @@ Dir.mkdirrec(dir) - if FileTest.file?(file) + if File.file?(file) @@mutex.synchronize do tree = Marshal.restore(File.new(file, "rb")) end @@ -249,68 +249,93 @@ end end - def parse(types=[], subtypes=[]) + def parse(types=[], subtypes=[], once=false) types = [types] if types.class == Class subtypes = [subtypes] if subtypes.class == String hidelevel = nil - @objects.each do |obj| - hidelevel = obj.level if (@checkvisibility and hidelevel.nil? and (not obj.visible)) - hidelevel = nil if (@checkvisibility and (not hidelevel.nil?) and obj.visible and obj.level <= hidelevel) - - if hidelevel.nil? - ok = false - if types.empty? - if subtypes.empty? - ok = true - else - subtypes.each do |st| - ok = true if obj.subtype == st - end - end + catch :once do + @objects.each do |obj| + if (@checkvisibility and hidelevel.nil? and (not obj.visible)) + hidelevel = obj.level else - if subtypes.empty? - types.each do |t| - ok = true if obj.kind_of?(t) - end - else - types.each do |t| - subtypes.each do |st| - ok = true if obj.kind_of?(t) if obj.subtype == st + if (@checkvisibility and (not hidelevel.nil?) and obj.visible and obj.level <= hidelevel) + hidelevel = nil + end + end + + if hidelevel.nil? + ok = false + catch :stop do + if types.empty? + if subtypes.empty? + ok = true + throw :stop + else + subtypes.each do |st| + if obj.subtype == st + ok = true + throw :stop + end + end + end + else + if subtypes.empty? + types.each do |t| + if obj.kind_of?(t) + ok = true + throw :stop + end + end + else + types.each do |t| + subtypes.each do |st| + if obj.kind_of?(t) and obj.subtype == st + ok = true + throw :stop + end + end + end end end end - end - yield(obj.class.to_s, obj) if ok + if ok + yield(obj.class.to_s, obj) + + throw :once if once + end + end end end end def path(pad) - p = self + p1 = self pad.split(/\//).each do |deel| tag, voorkomen = deel.split(/:/) - if (not tag.nil?) and (not p.nil?) + if (not tag.nil?) and (not p1.nil?) voorkomen = 1 if voorkomen.nil? voorkomen = voorkomen.to_i teller = 0 p2 = nil - p.children.each_index do |i| - if p.children[i].upordown == Down - if p.children[i].subtype.noquotes == tag.noquotes - teller += 1 - p2 = p.children[i] if teller == voorkomen + p1.children.each_index do |i| + #if p1.children[i].upordown == Down + unless p1.children[i].subtype.nil? + if p1.children[i].subtype.noquotes == tag.noquotes + teller += 1 + p2 = p1.children[i] if teller == voorkomen + end end - end + #end end - p = p2 + p1 = p2 end end - p + p1 end end diff -ur rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/LICENSE rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/LICENSE --- rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/LICENSE 2005-06-04 14:41:58.715878296 +0200 +++ rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/LICENSE 2004-07-26 16:14:10.000000000 +0200 @@ -0,0 +1,15 @@ +# Copyright Erik Veenstra <rubywebdialogs@erikveen.dds.nl> +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License, +# version 2, as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public +# License along with this program; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, +# Boston, MA 02111-1307 USA. diff -ur rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/README rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/README --- rubywebdialogs-0.0.9.tar.gz/rubywebdialogs/README 2005-06-04 14:41:58.716878144 +0200 +++ rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/README 2004-07-26 16:16:13.000000000 +0200 @@ -0,0 +1,4 @@ + Usage: ruby install.rb + +For more information, see +http://www.erikveen.dds.nl/rubywebdialogs/ . diff -ur rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/ftools.lib.rb rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/ftools.lib.rb --- rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2004-08-21 10:56:03.000000000 +0200 +++ rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2004-09-03 12:26:26.000000000 +0200 @@ -58,6 +58,8 @@ entry.gsub!(/[\/\\]*$/, "") unless entry.nil? + mask = /^#{mask}$/i if mask.kind_of?(String) + res = [] if File.directory?(entry) @@ -65,11 +67,19 @@ res += ["%s/" % entry] if mask.nil? or entry =~ mask - Dir.chdir(entry) - Dir.new(".").each do |e| - res += Dir.find(e, mask).collect{|e| entry+"/"+e} unless [".", ".."].include?(e) + begin + Dir.chdir(entry) + + begin + Dir.new(".").each do |e| + res += Dir.find(e, mask).collect{|e| entry+"/"+e} unless [".", ".."].include?(e) + end + ensure + Dir.chdir(pdir) end - Dir.chdir(pdir) + rescue Errno::EACCES => error + puts error + end else res += [entry] if mask.nil? or entry =~ mask end diff -ur rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/net.lib.rb --- rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-08-21 10:56:03.000000000 +0200 +++ rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-09-03 12:26:26.000000000 +0200 @@ -28,7 +28,7 @@ class TCPServer def self.freeport(from, to, remote=false) - if windows? + if windows? or cygwin? TCPServer.freeport_windows(from, to, remote) else TCPServer.freeport_linux(from, to, remote) @@ -343,8 +343,8 @@ uri = EVURI.new(uri) if uri.kind_of? String host = uri.host port = uri.port - io = nil + io = nil @@mutex.synchronize do @@hosts[host] = IPSocket.getaddress(host) if not @@hosts.include?(host) io = TCPSocket.new(@@hosts[host], port.zero? ? 80 : port) @@ -352,42 +352,33 @@ if post.empty? io.write "GET %s%s HTTP/1.0\r\n" % [(uri.path or ´/´), (uri.varstring.empty? ? ´´ : ´?´ + uri.varstring)] - io.write "Host: %s\r\n" % host - io.write "\r\n" else io.write "POST %s%s HTTP/1.0\r\n" % [(uri.path or ´/´), (uri.varstring.empty? ? ´´ : ´?´ + uri.varstring)] - io.write "Host: %s\r\n" % host - io.write "Content-Type: application/x-www-form-urlencoded\r\n" - io.write "Content-Length: %s\r\n" % post.length - io.write "Pragma: \r\n" - io.write "\r\n" - io.write post end else proxy = EVURI.new($proxy) host = proxy.host port = proxy.port - io = nil io = TCPSocket.new(host, port.zero? ? 8080 : port) if post.empty? io.write "GET %s HTTP/1.0\r\n" % uri - io.write "Host: %s\r\n" % host - io.write "Proxy-Authorization: Basic %s\r\n" % $proxy_auth unless $proxy_auth.nil? - io.write "\r\n" else io.write "POST %s HTTP/1.0\r\n" % uri - io.write "Host: %s\r\n" % host - io.write "Proxy-Authorization: Basic %s\r\n" % $proxy_auth unless $proxy_auth.nil? - io.write "Content-Type: application/x-www-form-urlencoded\r\n" - io.write "Content-Length: %s\r\n" % post.length - io.write "Pragma: \r\n" - io.write "\r\n" - io.write post end end + io.write "Host: %s\r\n" % host + io.write "User-Agent: evwget\r\n" + io.write "Proxy-Authorization: Basic %s\r\n" % $proxy_auth unless $proxy_auth.nil? + #io.write "Accept-Encoding: deflate\r\n" + #io.write "Connection: close\r\n" + io.write "Content-Type: application/x-www-form-urlencoded\r\n" unless post.empty? + io.write "Content-Length: %s\r\n" % post.length unless post.empty? + io.write "\r\n" + io.write post unless post.empty? + io.close_write res = io.read @@ -545,9 +536,17 @@ @peeraddr = @io.peeraddr + @pda = false + @pda = true if (self.include?("user-agent") and self["user-agent"].downcase.include?("windows ce")) + @pda = true if (self.include?("user-agent") and self["user-agent"].downcase.include?("handhttp")) + @io.close_read end + def pda? + @pda + end + def to_s res = @request.to_s self.each do |k, v| @@ -637,11 +636,11 @@ if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp))) @@times[com]=Time.new.to_f if not @@times.include?(com) - #puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: > #{req.request}" + #puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: > #{req.request.to_s.strip}" yield(req, resp) - puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: < #{req.request}" + puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: < #{req.request.to_s.strip}" @@times.delete(com) end diff -ur rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-08-21 10:56:03.000000000 +0200 +++ rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-09-03 12:26:26.000000000 +0200 @@ -2,7 +2,6 @@ require "ev/net" require "md5" require "rbconfig" -require "pstore" begin require "win32ole" @@ -15,6 +14,8 @@ $rwd_exit = ARGV.include?("--rwd-exit") # Hack ??? $rwd_debug = ($rwd_debug or false) $rwd_border = ($rwd_border or 0) +$rwd_dir = Dir.pwd +$rwd_files = File.expand_path("rwd_files", Dir.pwd) ARGV.delete_if do |arg| arg =~ /^--rwd-/ @@ -96,7 +97,7 @@ Thread.new do loop do - WIN32OLE_EVENT.message_loop + WIN32OLE_EVENT.message_loop end end end @@ -167,11 +168,11 @@ else s = "" - s << "<text name=´#{name}´" - s << " value=´#{values[n].to_html}´" if n < values.length - s << "/>" + s << "<text name=´#{name}´" + s << " value=´#{values[n].to_html}´" if n < values.length + s << "/>" - res << s + res << s end res << "</row>" @@ -249,7 +250,7 @@ end class OpenTag - def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab) + def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda) bef = before[-1] res.concat Format % ["Before", @subtype] if ($rwd_debug and not bef.nil?) res.concat bef if not bef.nil? @@ -270,6 +271,9 @@ value2 = varsstring[@args["name"]] if varsstring.include?(@args["name"]) value2 = @args["value"] if @args.include?("value") + cellspacing = 3 + cellspacing = 0 if pda + case @subtype when "application" when "window", "helpwindow" @@ -277,7 +281,10 @@ args["nohelpbutton"] = (not help) - res.concat(template($rwd_html1, args)) + template = $rwd_html_11 + template = $rwd_html_21 if pda + + res.concat(template(template, args)) when "p" then res.concat "<p #{align}>" when "pre" then res.concat "<pre #{align}>" when "big" then res.concat "<p #{align}><big>" @@ -296,15 +303,17 @@ else res.concat "<a href=´javascript:document.bodyform.rwd_action.value=\"#{@args["action"]}\";document.bodyform.submit();´>" end - when "vertical" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" - when "horizontal" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´><tr #{align} #{valign}>" - when "table" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" + when "vertical" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´#{cellspacing}´ cellpadding=´0´>" + when "horizontal" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´#{cellspacing}´ cellpadding=´0´><tr #{align} #{valign}>" + when "table" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´#{cellspacing}´ cellpadding=´0´>" when "row" then res.concat "<tr #{align} #{valign}>" when "hidden" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´hidden´>" when "text" maxlength = "" maxlength = "maxlength=´%s´" % @args["maxlength"] if @args.include?("maxlength") - res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´text´ #{maxlength}>" + size = "" + size = "size=´%s´" % 10 if pda + res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´text´ #{maxlength} #{size}>" oneormorefields << "true" when "textarea" res.concat "<p #{align}><textarea name=´#{@args["name"]}´ rows=´25´ cols=´80´>#{value2.crlf}</textarea>" @@ -312,7 +321,9 @@ when "password" maxlength = "" maxlength = "maxlength=´%s´" % @args["maxlength"] if @args.include?("maxlength") - res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´password´ #{maxlength}>" + size = "" + size = "size=´%s´" % 10 if pda + res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´password´ #{maxlength} #{size}>" oneormorefields << "true" when "checkbox" if varshtml[@args["name"]] == "on" @@ -324,7 +335,7 @@ end oneormorefields << "true" when "radio" - if varshtml[@args["name"]] == value1 # ??? 1 of 2? + if varshtml[@args["name"]] == value1 # ??? 1 or 2? res.concat "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ value=´#{value1}´ type=´radio´>" else res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´radio´>" @@ -425,7 +436,7 @@ after.push(aft) end - def postchildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab) + def postchildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda) case @subtype when "vertical", "window", "helpwindow", "tabs", "tab" res.concat Format % ["BefPost", @subtype] if $rwd_debug @@ -445,7 +456,10 @@ args["nohelpbutton"] = (not help) - res.concat(template($rwd_html2, args)) + template = $rwd_html_12 + template = $rwd_html_22 if pda + + res.concat(template(template, args)) when "p" then res.concat "</p>" when "pre" then res.concat "</pre>" when "big" then res.concat "</big></p>" @@ -504,7 +518,11 @@ a[k.upcase] = v end - a["LOGO"] = "" unless ((not vars["logo"].nil?) and File.file?(vars["logo"])) + logo = nil + logo = File.expand_path(vars["logo"], $rwd_files) if vars.include?("logo") + logo = nil unless logo.nil? or File.file?(logo) + + a["LOGO"] = "" unless not logo.nil? a["HELPBUTTON"] = (not (vars["nohelpbutton"])) a["BACKBUTTONS"] = (not (vars["nobackbuttons"])) @@ -540,7 +558,7 @@ end class Text - def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab) + def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda) if not @text.scan(/[^ \t\r\n]/).empty? res.concat Format % ["Text", ""] if $rwd_debug res.concat "#{@text}" @@ -577,7 +595,7 @@ @helprwd = (@@helpwindows[rwd][window] or "").dup end - def render(vars=Hash.new, switches=Hash.new, help=false, tab="") + def render(pda, vars=Hash.new, switches=Hash.new, help=false, tab="") varshtml = Hash.new varsstring = Hash.new oneormorefields = "" @@ -615,9 +633,9 @@ end if help - helpobject.parsetree("prechildren", "postchildren", html, [""], [""], varshtml, varsstring, switches, false, oneormorefields, firstaction, tabs, tab) + helpobject.parsetree("prechildren", "postchildren", html, [""], [""], varshtml, varsstring, switches, false, oneormorefields, firstaction, tabs, tab, pda) else - windowobject.parsetree("prechildren", "postchildren", html, [""], [""], varshtml, varsstring, switches, (not @helprwd.empty?), oneormorefields, firstaction, tabs, tab) + windowobject.parsetree("prechildren", "postchildren", html, [""], [""], varshtml, varsstring, switches, (not @helprwd.empty?), oneormorefields, firstaction, tabs, tab, pda) end html.gsub!(/%%*[[:alnum:]_\-]+%%*/, "") if not $rwd_debug @@ -687,7 +705,7 @@ @rwd_server = RWDServer.new(self, port, io, auth, realm) end - def render(res, path, post, download, sessionid) + def render(res, path, post, download, downloadfile, pda, sessionid) # Initialize some vars. @@ -700,6 +718,7 @@ tab = "" @rwd_msg = nil @rwd_download = nil + @rwd_download_file = nil # Switches are used for checkboxes. @@ -813,21 +832,22 @@ # Answer to browser. if done - res << RWDDone.new(@rwd_exitbrowser).render + res << RWDDone.new(@rwd_exitbrowser).render(pda) else if not @rwd_download.nil? puts "Download: #{@rwd_window}" if $rwd_debug - download << @rwd_download + download << @rwd_download + downloadfile << @rwd_download_file else if not @rwd_msg.nil? - res << RWDMessage.new(@rwd_msg).render if @rwd_msgtype == "message" - res << RWDError.new(@rwd_msg).render if @rwd_msgtype == "error" + res << RWDMessage.new(@rwd_msg).render(pda) if @rwd_msgtype == "message" + res << RWDError.new(@rwd_msg).render(pda) if @rwd_msgtype == "error" else puts "Window: #{@rwd_window}" if $rwd_debug puts "Tab: #{@rwd_tab}" if $rwd_debug - res << RWDWindow.new(@rwd_xml, @rwd_window).render(vars, @rwd_switches, help, @rwd_tab) + res << RWDWindow.new(@rwd_xml, @rwd_window).render(pda, vars, @rwd_switches, help, @rwd_tab) end end end @@ -849,8 +869,9 @@ @rwd_msgtype = "error" end - def download(data) + def download(data, filename="") @rwd_download = data + @rwd_download_file = filename end def exitbrowser @@ -889,19 +910,6 @@ @rack = rack.to_s @cleanup = SessionCleanup.new(self, 3600, 24*3600) if cleanup @sessions = {} - - #@store = PStore.new("#{temp}/store.#{@rack}.#{user}") # ??? - - #@store.transaction do - #@store[@rack] = {} if not @store.root?(@rack) - #@sessions = @store[@rack] - #end - - #at_exit do - #@store.transaction do - #@store[@rack] = @sessions - #end - #end end def [](sessionid) @@ -943,8 +951,8 @@ end class RWDSession < Session - def render(res, path, post, download) - done = self["object"].render(res, path, post, download, @sessionid) + def render(res, path, post, download, downloadfile, pda) + done = self["object"].render(res, path, post, download, downloadfile, pda, @sessionid) if done res.gsub!(/\$RWD_SESSION\$/, "") @@ -972,7 +980,8 @@ # Start browser. - @browserthread = Thread.new do + @browserthread = + Thread.new do puts "Starting the browser..." #if ENV["RWDBROWSER"].downcase =~ /iexplore/ # ??? @@ -1012,11 +1021,11 @@ #oldsessionid = vars["rwd_session"] oldsessionid = req.cookies["sessionid"] - # Retrieve session. + # Retrieve session. session = @sessions[oldsessionid] - # Eventually create new session. + # Eventually create new session. if session.nil? if auth.nil? @@ -1033,7 +1042,7 @@ if oldsessionid.nil? or oldsessionid.empty? if not auth.nil? and not auth.empty? and not session.authenticated and pad != "/pixel.gif" - # Check authentication + # Check authentication us = vars["rwd_a"] pa = vars["rwd_b"] @@ -1047,6 +1056,7 @@ @sessions[session.sessionid] = session end else + session.authenticated = true @sessions[session.sessionid] = session end else @@ -1057,20 +1067,21 @@ vars = {} end - # Avoid timeout. + # Avoid timeout. session.touch if pad == "/" - # Serve methods/callbacks. + # Serve methods/callbacks. - # Build new page. + # Build new page. download = "" + downloadfile = "" res = "" - done = session.render(res, pad, vars, download) + done = session.render(res, pad, vars, download, downloadfile, req.pda?) begin if download.empty? @@ -1084,7 +1095,8 @@ resp << res else resp["Content-Type"] = "application/octet-stream" - resp["Content-Disposition"] = "attachment; filename=data" + resp["Content-Disposition"] = "attachment;" + resp["Content-Disposition"] = "attachment; filename=%s" % downloadfile unless downloadfile.empty? resp << download end @@ -1094,7 +1106,7 @@ @sessions.delete(session.sessionid) end - # Eventually delete this session. + # Eventually delete this session. if done @sessions.delete(session.sessionid) @@ -1102,7 +1114,7 @@ if @localbrowsing resp.flush - if @browserstarted and @browserthread.alive? + if @browserstarted and not @browserthread.nil? and @browserthread.alive? puts "Waiting for the browser to terminate..." @browserthread.join @@ -1114,17 +1126,32 @@ else - # Serve files. + # Serve files. if pad == "/pixel.gif" resp["Cache-Control"] = "max-age=86400" resp["Content-Type"] = "image/gif" resp << $rwd_pixel else - if (File.file?(pad.sub(/^\/*/, ""))) - resp << File.new(pad.sub(/^\/*/, ""), "rb").read rescue nil + if session.authenticated + pwd = Dir.pwd + file = File.expand_path(pad.gsub(/^\/*/, ""), $rwd_files) + + if not file.index(pwd) == 0 + resp["Content-Type"] = "text/html" + resp.response = "HTTP/1.0 400 BAD REQUEST" + resp << "<html><body><p><b>Bad Request.</b> (<tt>#{pad}</tt>)</p></body></html>" + elsif File.file?(file) + resp << File.new(file, "rb").read rescue nil + else + resp["Content-Type"] = "text/html" + resp.response = "HTTP/1.0 404 NOT FOUND" + resp << "<html><body><p><b>Not found.</b> (<tt>#{pad}</tt>)</p></body></html>" + end else - resp.response = "HTTP/1.0 404 NOT FOUND" + resp["Content-Type"] = "text/html" + resp.response = "HTTP/1.0 ??? NOT AUTHORIZED" + resp << "<html><body><p><b>Not Authorized.</b></p></body></html>" end end @@ -1134,7 +1161,7 @@ end end -$rwd_html = " +$rwd_html_1 = " <!-- Generated by RubyWebDialog. --> <!-- For more information, please contact Erik Veenstra <rwd@erikveen.dds.nl>. --> <html> @@ -1410,6 +1437,78 @@ </html> " +$rwd_html_2 = " +<!-- Generated by RubyWebDialog. --> +<!-- For more information, please contact Erik Veenstra <rwd@erikveen.dds.nl>. --> +<html> + <head> + <title>%TITLE%</title> + + <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> + + <link rel=´shortcut icon´ href=´%LOGO%´> + + <script type=´text/javascript´> + <!-- + function BodyGo() { + $RWD_FOCUS$ + } + //--> + </script> + </head> + + <body bgcolor=´white´ onload=´BodyGo()´ link=´#000000´ vlink=´#000000´ alink=´#000000´> + <form name=´bodyform´ action=´/´ method=´post´> + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´ width=´100%´ height=´100%´> + + <tr align=´center´> + <td align=´center´ bgcolor=´#444488´> + + <table align=´left´ border=´0´ cellspacing=´1´ cellpadding=´0´> + <tr align=´center´> + <td align=´border´><img src=´%LOGO%´ width=´14´ height=´14´></td> + <td align=´center´><b><small><font color=´#FFFFFF´> %TITLE% </font></small></b></td> + </tr> + </table> + + <table align=´right´ border=´0´ cellspacing=´1´ cellpadding=´0´> + <tr align=´center´> + <!-- %HELPBUTTON% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_help\";document.bodyform.submit();´> ? </a></small></b></td> + <!-- %BACKBUTTONS% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_main\";document.bodyform.submit();´> << </a></small></b></td> + <!-- %BACKBUTTONS% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_back\";document.bodyform.submit();´> < </a></small></b></td> + <!-- %CLOSEBUTTON% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_quit\";document.bodyform.submit();´> X </a></small></b></td> + </tr> + </table> + + </td> + </tr> + + <!-- + <tr align=´center´> + <td align=´center´ bgcolor=´#FFFFFF´> </td> + </tr> + --> + + <tr align=´center´> + <td align=´center´ bgcolor=´#FFFFFF´> + + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´> + + %BODY% + + </table> + + <input name=´rwd_action´ value=´$RWD_FIRSTACTION$´ type=´hidden´> + <input name=´rwd_session´ value=´$RWD_SESSION$´ type=´hidden´> + </td> + </tr> + + </table> + </form> + </body> +</html> +" + $rwd_pixel = " R0lGODlhAQABAOcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoK CgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZ @@ -1432,4 +1531,5 @@ CgD/ACwAAAAAAQABAAAIBAD/BQQAOw== ".unpack("m").shift -$rwd_html1, $rwd_html2 = $rwd_html.split(/^\s*%BODY%\s*\r*$/) +$rwd_html_11, $rwd_html_12 = $rwd_html_1.split(/^\s*%BODY%\s*\r*$/) +$rwd_html_21, $rwd_html_22 = $rwd_html_2.split(/^\s*%BODY%\s*\r*$/) diff -ur rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/sgml.lib.rb rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/sgml.lib.rb --- rubywebdialogs-0.0.10.tar.gz/rubywebdialogs/lib/sgml.lib.rb 2004-08-21 10:56:03.000000000 +0200 +++ rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/sgml.lib.rb 2004-09-03 12:26:26.000000000 +0200 @@ -25,11 +25,13 @@ end def prechildren_to_s(res) - res << "#{CGI.unescapeHTML(@text)} " + #res << "#{CGI.unescapeHTML(@text)} " + res << @text end def prechildren_to_sgml(res) - res << "#{CGI.unescapeHTML(@text)}" + #res << "#{CGI.unescapeHTML(@text)}" + res << @text end end diff -ur rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/init.rb rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/init.rb --- rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/init.rb 2004-09-03 12:26:26.000000000 +0200 +++ rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/init.rb 2004-11-28 14:41:35.000000000 +0100 @@ -10,6 +10,8 @@ Dir.mkdir(dir) rescue nil end +Dir.chdir(File.dirname($0)) + FromDirs = [".", "./lib", "./rubylib/lib"] ToDir = Config::CONFIG["sitelibdir"] + "/ev" diff -ur rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/install.rb rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/install.rb --- rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/install.rb 2004-09-03 12:26:26.000000000 +0200 +++ rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/install.rb 2004-11-28 14:41:35.000000000 +0100 @@ -10,6 +10,8 @@ Dir.mkdir(dir) rescue nil end +Dir.chdir(File.dirname($0)) + FromDirs = [".", "./lib", "./rubylib/lib"] ToDir = Config::CONFIG["sitelibdir"] + "/ev" diff -ur rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/browser.lib.rb rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/browser.lib.rb --- rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/browser.lib.rb 2005-06-04 14:41:59.620740736 +0200 +++ rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/browser.lib.rb 2004-11-28 14:41:35.000000000 +0100 @@ -0,0 +1,112 @@ +require "ev/ruby" +require "ev/net" + +begin + require "win32ole" + require "win32/registry" +rescue LoadError + $".push "win32ole.so" + $".push "win32/registry.rb" +end + +def windowsbrowser + $stderr.puts "Looking for default browser..." + + filetype = nil + application = nil + + begin + Win32::Registry::HKEY_CLASSES_ROOT.open(´.html´) do |reg| + filetype = reg[""] + end + + Win32::Registry::HKEY_CLASSES_ROOT.open(filetype + ´\shell\open\command´) do |reg| + application = reg[""] + end + rescue NameError + $stderr.puts "Only available for Windows." + end + + application +end + +def linuxbrowser + application = "" + + application = `which galeon 2> /dev/null`.chomp if application.empty? + application = `which mozilla 2> /dev/null`.chomp if application.empty? + application = `which firefox 2> /dev/null`.chomp if application.empty? + application = `which opera 2> /dev/null`.chomp if application.empty? + application = `which konqueror 2> /dev/null`.chomp if application.empty? + application = `which htmlview 2> /dev/null`.chomp if application.empty? + application = nil if application.empty? + + application +end + +def defaultbrowser + res = nil + res = windowsbrowser if windows? + res = linuxbrowser if linux? + res +end + +def showinbrowser(html, browser=defaultbrowser) + port, io = TCPServer.freeport(7701, 7709) + + unless browser.nil? + Thread.new do + begin + #command = "1234 \"http://localhost:#{port}\"" if linux? + #command = "L:/prog/MozillaFirefox/firefox.exe \"http://localhost:#{port}\"" if cygwin? + #command = Win32::Registry::HKEY_CLASSES_ROOT.open(´htmlfile\shell\open\command´)[0] + " \"http://localhost:#{port}/\"" if windows? + + command = "#{browser} \"http://localhost:#{port}\"" + + Thread.pass + + system(command) + rescue + end + end + end + + catch :once do + HTTPServer.serve([port, io]) do |req, resp| + resp << html + resp.flush + + throw :once + end + end +end + +def tab2html(tab) + res = "" + + tab = tab.to_html(false) + + res << "<html>\n" + res << "<body>\n" + res << "<table align=´center´ border=´1´ cellspacing=´0´ cellpadding=´3´>\n" + res << "<tbody>\n" + + tab.split(/\r*\n/).each do |line| + res << "<tr>\n" + + line.split(/\t/, -1).each do |veld| + veld = " " if veld.compress.empty? + + res << "<td>%s</td>\n" % veld + end + + res << "</tr>\n" + end + + res << "</tbody>\n" + res << "</table>\n" + res << "</body>\n" + res << "</html>\n" + + res +end diff -ur rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/ftools.lib.rb rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ftools.lib.rb --- rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2004-09-03 12:26:26.000000000 +0200 +++ rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2004-11-28 14:41:35.000000000 +0100 @@ -54,9 +54,9 @@ end def self.find(entry=nil, mask=nil) - entry = @dir if entry.nil? + entry = "." if entry.nil? - entry.gsub!(/[\/\\]*$/, "") unless entry.nil? + entry = entry.gsub!(/[\/\\]*$/, "") unless entry.nil? mask = /^#{mask}$/i if mask.kind_of?(String) @@ -86,12 +86,29 @@ res end + + def self.findandchangecontent(entry=nil, mask=nil) + Dir.find(entry, mask).each do |file| + unless File.directory?(file) + data1 = File.open(file){|f| f.read} + + data2 = yield(data1) + + if data2 != data1 + $stderr.puts "Changing #{file} ..." + + File.open(file, "w"){|f| f.write data2} + end + end + end + end end class File def self.rollbackup(file, mode=nil) backupfile = file + ".RB.BACKUP" controlfile = file + ".RB.CONTROL" + res = nil File.touch(file) unless File.file?(file) @@ -117,10 +134,10 @@ if block_given? if mode.nil? - yield + res = yield else File.open(file, mode) do |f| - yield(f) + res = yield(f) end end end @@ -132,11 +149,9 @@ # Return, like File.open - if block_given? - return nil - else - return File.open(file, (mode or "r")) - end + res = File.open(file, (mode or "r")) unless block_given? + + res end def self.touch(file) diff -ur rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/net.lib.rb --- rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-09-03 12:26:26.000000000 +0200 +++ rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-11-28 14:41:35.000000000 +0100 @@ -9,6 +9,8 @@ require "md5" require "thread" +$proxy = ENV["PROXY"] if $proxy.nil? + file = "#{home}/.evnet" if File.file?(file) Hash.file(file).each do |k, v| @@ -530,7 +532,7 @@ data = (@io.read(self["content-length"].to_i) or "") @vars = RequestPost.new((self["content-type"] == "application/x-www-form-urlencoded") ? data : "") else - puts "Unknown request (´#{firstline}´)." + $stderr.puts "Unknown request (´#{firstline}´)." end end @@ -569,10 +571,11 @@ @response = "HTTP/1.0 200 OK" @cookies = {} @data = "" + @syncd = false end def flush - @io.write("#{to_s}\r\n#{@data}") + sync @io.close end @@ -589,6 +592,13 @@ res end + def sync + @io.write("#{to_s}\r\n") unless @syncd + @io.write(@data) + @data = "" + @syncd = true + end + def << (s) @data << s end @@ -607,11 +617,11 @@ begin server = TCPServer.new(remote ? "0.0.0.0" : "localhost", port) if server.nil? - puts "Just point your browser to http://localhost:#{port}/ ..." + $stderr.puts "Just point your browser to http://localhost:#{port}/ ..." rescue server = nil - puts "Port #{port} is in use." + $stderr.puts "Port #{port} is in use." end if not server.nil? @@ -636,11 +646,11 @@ if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp))) @@times[com]=Time.new.to_f if not @@times.include?(com) - #puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: > #{req.request.to_s.strip}" + #$stderr.puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: > #{req.request.to_s.strip}" yield(req, resp) - puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: < #{req.request.to_s.strip}" + $stderr.puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: < #{req.request.to_s.strip}" @@times.delete(com) end diff -ur rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/ruby.lib.rb rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ruby.lib.rb --- rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-09-03 12:26:26.000000000 +0200 +++ rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-11-28 14:41:35.000000000 +0100 @@ -234,7 +234,7 @@ self.splitblocks(["´", "´"], [´"´, ´"´], ["#", "\n"]).each do |type, s| case type when 0, 1, 2 then res << s - when 3 + when 3 then res << "\n" end end @@ -477,7 +477,7 @@ end def self.file(file) - res = [] + res = new File.open(file) do |f| f.readlines.uncomment.chomp.each do |line| @@ -617,7 +617,7 @@ end def self.file(file) - res = {} + res = new File.open(file) do |f| #f.readlines.chomp.each do |line| @@ -625,7 +625,7 @@ line.chomp! unless line.empty? - k, v = line.split(/\s+=\s+/, 2) + k, v = line.split(/\s*=\s*/, 2) res[k] = v end end @@ -663,47 +663,21 @@ end end -def evtimeout(seconds, *args) - if not seconds.nil? and not seconds.zero? - t = Thread.current - threads = [] - res = nil - - threads[1] = Thread.new(*args) do |*args| - sleep seconds - begin - threads[2].kill - rescue NameError - end - res = false - t.wakeup +def evtimeout(seconds) + begin + timeout(seconds) do + yield end - - threads[2] = Thread.new(*args) do |*args| - yield(*args) - begin - threads[1].kill - rescue NameError - end - res = true - t.wakeup - end - - threads[1].join - threads[2].join - - return res - else - yield(*args) + rescue TimeoutError end end -def evtimeoutretry(seconds, *args) +def evtimeoutretry(seconds) ok = false while not ok - evtimeout(seconds, *args) do |*args| - yield(*args) + evtimeout(seconds) do + yield ok = true end end @@ -744,14 +718,28 @@ end def temp - (ENV["TEMP"] or "/tmp").gsub(/\\/, "/") + (ENV["TMPDIR"] or ENV["TMP"] or ENV["TEMP"] or "/tmp").gsub(/\\/, "/") end def stdtmp $stderr = $stdout = File.new("#{temp}/ruby.#{Process.pid}.log", "a") unless ARGV.include?("--rwd-exit") end +$nobm = false + +def nobm + $nobm = true +end + def bm(label="") + if $nobm + if block_given? + return yield + else + return nil + end + end + if $bm.nil? require "ev/bm" @@ -786,3 +774,34 @@ res end + +def trace + res =nil + + set_trace_func lambda { |event, file, line, id, binding, classname| + $stderr.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname + } + if block_given? + res = yield + + notrace + end + + res +end + +def notrace + set_trace_func nil +end + +def lambda_cached(&block) + hash = {} + lambda do |*args| + res = hash[args] + if res.nil? + res = block.call(*args) + hash[args] = res + end + res + end +end diff -ur rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-09-03 12:26:26.000000000 +0200 +++ rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-11-28 14:41:35.000000000 +0100 @@ -1,5 +1,7 @@ +require "ev/ruby" require "ev/xml" require "ev/net" +require "ev/browser" require "md5" require "rbconfig" @@ -12,16 +14,17 @@ end $rwd_exit = ARGV.include?("--rwd-exit") # Hack ??? -$rwd_debug = ($rwd_debug or false) +$rwd_debug = ($rwd_debug or $DEBUG or false) $rwd_border = ($rwd_border or 0) $rwd_dir = Dir.pwd $rwd_files = File.expand_path("rwd_files", Dir.pwd) +$rwd_html = {} + ARGV.delete_if do |arg| arg =~ /^--rwd-/ end - RWDEmptyline = "..." rcfile = nil @@ -37,37 +40,18 @@ Format = "\n<!-- %-10s %-10s -->\t" unless rcfile.nil? - puts "Reading #{rcfile} ..." + $stderr.puts "Reading #{rcfile} ..." Hash.file(rcfile).each do |k, v| - ENV[k] = v - end -end - -unless ENV.include?("RWDBROWSER") - begin - puts "Looking for default browser..." - - filetype = nil - application = nil - - Win32::Registry::HKEY_CLASSES_ROOT.open(´.html´) do |reg| - filetype = reg[""] - end - - Win32::Registry::HKEY_CLASSES_ROOT.open(filetype + ´\shell\open\command´) do |reg| - application = reg[""] - end + #$stderr.puts "Setting #{k} to \"#{v}\" ..." - ENV["RWDBROWSER"] = application - rescue NameError - puts "Not found." + ENV[k] = v end end -unless ENV.include?("RWDPORTS") - ENV["RWDPORTS"] = "7701-7709" -end +ENV["RWDBROWSER"] = (ENV["RWDBROWSER"] or defaultbrowser) or puts "No browser found." +ENV["RWDPORTS"] = (ENV["RWDPORTS"] or "7701-7709") +ENV["RWDTHEME"] = (ENV["RWDTHEME"] or "DEFAULT") trap("INT") {puts "Terminating..." ; exit} @@ -252,10 +236,10 @@ class OpenTag def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda) bef = before[-1] - res.concat Format % ["Before", @subtype] if ($rwd_debug and not bef.nil?) - res.concat bef if not bef.nil? + res << Format % ["Before", @subtype] if ($rwd_debug and not bef.nil?) + res << bef if not bef.nil? - res.concat Format % ["Pre", @subtype] if $rwd_debug + res << Format % ["Pre", @subtype] if $rwd_debug align = AC align = "align=´#{@args["align"]}´" if @args.include?("align") @@ -281,144 +265,159 @@ args["nohelpbutton"] = (not help) - template = $rwd_html_11 - template = $rwd_html_21 if pda + template = $rwd_html_1 + template = $rwd_html_PDA_1 if pda - res.concat(template(template, args)) - when "p" then res.concat "<p #{align}>" - when "pre" then res.concat "<pre #{align}>" - when "big" then res.concat "<p #{align}><big>" - when "small" then res.concat "<p #{align}><small>" - when "list" then res.concat "<ul #{align}>" - when "item" then res.concat "<li #{align}>" - when "empty" then res.concat "<p><br>" - when "image" then res.concat "<img src=´#{@args["src"]}´>" - when "br" then res.concat "<br>" - when "hr" then res.concat "<hr>" - when "b" then res.concat "<b>" - when "i" then res.concat "<i>" + res <<(template(template, args)) + when "p" then res << "<p #{align}>" + when "pre" then res << "<pre #{align}>" + when "big" then res << "<p #{align}><big>" + when "small" then res << "<p #{align}><small>" + when "list" then res << "<ul #{align}>" + when "item" then res << "<li #{align}>" + when "empty" then res << "<p><br>" + when "image" then res << "<img src=´#{@args["src"]}´ alt=´#{@args["alt"]}´>" + when "br" then res << "<br>" + when "hr" then res << "<hr>" + when "b" then res << "<b>" + when "i" then res << "<i>" when "a" if @args.include?("href") - res.concat "<a href=´#{@args["href"]}´ target=´#{@args["target"] or "_blank"}´>" + res << "<a href=´#{@args["href"]}´ target=´#{@args["target"] or "_blank"}´>" else - res.concat "<a href=´javascript:document.bodyform.rwd_action.value=\"#{@args["action"]}\";document.bodyform.submit();´>" + res << "<a href=´javascript:document.bodyform.rwd_action.value=\"#{@args["action"]}\";document.bodyform.submit();´>" end - when "vertical" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´#{cellspacing}´ cellpadding=´0´>" - when "horizontal" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´#{cellspacing}´ cellpadding=´0´><tr #{align} #{valign}>" - when "table" then res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´#{cellspacing}´ cellpadding=´0´>" - when "row" then res.concat "<tr #{align} #{valign}>" - when "hidden" then res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´hidden´>" + when "vertical" then res << "<table #{AC} border=´#{$rwd_border}´ cellspacing=´#{cellspacing}´ cellpadding=´0´>" + when "horizontal" then res << "<table #{AC} border=´#{$rwd_border}´ cellspacing=´#{cellspacing}´ cellpadding=´0´><tr #{align} #{valign}>" + when "table" then res << "<table #{AC} border=´#{$rwd_border}´ cellspacing=´#{cellspacing}´ cellpadding=´0´>" + when "row" then res << "<tr #{align} #{valign}>" + when "hidden" then res << "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´hidden´>" when "text" maxlength = "" maxlength = "maxlength=´%s´" % @args["maxlength"] if @args.include?("maxlength") size = "" size = "size=´%s´" % 10 if pda - res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´text´ #{maxlength} #{size}>" + res << "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´text´ #{maxlength} #{size}>" oneormorefields << "true" when "textarea" - res.concat "<p #{align}><textarea name=´#{@args["name"]}´ rows=´25´ cols=´80´>#{value2.crlf}</textarea>" + res << "<p #{align}><textarea name=´#{@args["name"]}´ rows=´25´ cols=´80´>#{value2.crlf}</textarea>" oneormorefields << "true" when "password" maxlength = "" maxlength = "maxlength=´%s´" % @args["maxlength"] if @args.include?("maxlength") size = "" size = "size=´%s´" % 10 if pda - res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´password´ #{maxlength} #{size}>" + res << "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´password´ #{maxlength} #{size}>" oneormorefields << "true" when "checkbox" if varshtml[@args["name"]] == "on" switches[@args["name"]] = true - res.concat "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ type=´checkbox´>" + res << "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ type=´checkbox´>" else switches[@args["name"]] = false - res.concat "<p #{align}><input name=´#{@args["name"]}´ type=´checkbox´>" + res << "<p #{align}><input name=´#{@args["name"]}´ type=´checkbox´>" end oneormorefields << "true" when "radio" if varshtml[@args["name"]] == value1 # ??? 1 or 2? - res.concat "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ value=´#{value1}´ type=´radio´>" + res << "<p #{align}><input name=´#{@args["name"]}´ checked=´on´ value=´#{value1}´ type=´radio´>" else - res.concat "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´radio´>" + res << "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´radio´>" end oneormorefields << "true" when "select" - res.concat "<select #{align} name=´#{@args["name"]}´ width=´#{@args["width"]}´>" + res << "<select #{align} name=´#{@args["name"]}´ width=´#{@args["width"]}´>" name = @args["name"] $select = varshtml[name] oneormorefields << "true" when "option" if $select == @children[0].text - res.concat "<option selected=´true´>" + res << "<option selected=´true´>" else - res.concat "<option>" + res << "<option>" end when "button" - res.concat "<input type=´submit´ value=´#{@args["caption"]}´ onclick=´document.bodyform.rwd_action.value=\"#{@args["action"]}\";´>" + res << "<input type=´submit´ value=´#{@args["caption"]}´ onclick=´document.bodyform.rwd_action.value=\"#{@args["action"]}\";´>" firstaction << @args["action"] if (firstaction.empty? and @args.include?("action")) oneormorefields << "true" when "back" - res.concat "<input type=´submit´ value=´Back´ onclick=´document.bodyform.rwd_action.value=\"rwd_back\";´>" + res << "<input type=´submit´ value=´Back´ onclick=´document.bodyform.rwd_action.value=\"rwd_back\";´>" firstaction << "rwd_back" if firstaction.empty? oneormorefields << "true" when "help" - res.concat "<input type=´submit´ value=´Help´ onclick=´document.bodyform.rwd_action.value=\"rwd_help\";´>" + res << "<input type=´submit´ value=´Help´ onclick=´document.bodyform.rwd_action.value=\"rwd_help\";´>" firstaction << "rwd_help" if firstaction.empty? oneormorefields << "true" when "quit" - res.concat "<input type=´submit´ value=´Quit´ onclick=´document.bodyform.rwd_action.value=\"rwd_quit\";´>" + res << "<input type=´submit´ value=´Quit´ onclick=´document.bodyform.rwd_action.value=\"rwd_quit\";´>" firstaction << "rwd_quit" if firstaction.empty? oneormorefields << "true" when "close" - res.concat "<input type=´submit´ value=´Close´ onclick=´window.close();´>" + res << "<input type=´submit´ value=´Close´ onclick=´window.close();´>" firstaction << "rwd_quit" if firstaction.empty? oneormorefields << "true" when "reset" - res.concat "<input type=´reset´ value=´Reset´>" + res << "<input type=´reset´ value=´Reset´>" firstaction << "rwd_quit" if firstaction.empty? oneormorefields << "true" when "closewindow" - #res.concat "<script type=´text/javascript´>\n" # ??? - #res.concat "<!--\n" - #res.concat " window.close();\n" - #res.concat "//-->\n" - #res.concat "</script>" + #res << "<script type=´text/javascript´>\n" # ??? + #res << "<!--\n" + #res << " window.close();\n" + #res << "//-->\n" + #res << "</script>" when "tabs" - res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´0´ cellpadding=´0´>" - res.concat " <tr #{AL}>" - res.concat " <td #{AL} class=´tabs´>" - res.concat " <table #{AL} border=´#{$rwd_border}´ cellspacing=´0´ cellpadding=´0´>" - res.concat " <tr #{AL}>" + res << "<table #{AC} border=´#{$rwd_border}´ cellspacing=´0´ cellpadding=´0´>" + res << " <tr #{AL}>" + res << " <td #{AL} class=´tabs´>" + res << " <table #{AL} border=´#{$rwd_border}´ cellspacing=´0´ cellpadding=´0´>" + res << " <tr #{AL}>" + #res << " <td class=´notab´> </td>" tabs.each do |obj| name = obj.args["name"] caption = obj.args["caption"] - res.concat "<td class=´notab´> </td>" unless obj == tabs[0] + res << "<td #{AL} class=´notab´> </td>" unless obj == tabs[0] if name == tab - res.concat "<td #{AC} class=´thistab´><tt><b> #{caption} </b></tt></td>" + res << "<td #{AC} class=´activetab´><tt> #{caption} </tt></td>" else - res.concat "<td #{AC} class=´tab´><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_tab_#{name}\";document.bodyform.submit();´><tt> #{caption} </tt></a></td>" + res << "<td #{AC} class=´passivetab´><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_tab_#{name}\";document.bodyform.submit();´><tt> #{caption} </tt></a></td>" end end - res.concat " </tr>" - res.concat " </table>" - res.concat " </td>" - res.concat " </tr>" + res << " <td class=´notab´ width=´100%´> </td>" + res << " </tr>" + res << " </table>" + res << " </td>" + res << " </tr>" + res << " <tr #{align}>" + res << " <td #{align} class=´tabblad´>" when "tab" - res.concat "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" - res.concat " <tr #{AL}>" - res.concat " <td #{AL} class=´tabblad´>" + res << "<table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" + when "panel" + level = (@args["level"] or "normal") + res << "<table #{AC} border=´#{$rwd_border}´ cellspacing=´0´ cellpadding=´0´>" + res << " <tr #{align}>" + res << " <td #{align} class=´panel1´>" if level == "normal" + res << " <td #{align} class=´panel1high´>" if level == "high" + res << " <td #{align} class=´panel1low´>" if level == "low" + res << " <table #{AC} border=´#{$rwd_border}´ cellspacing=´0´ cellpadding=´0´>" + res << " <tr #{align}>" + res << " <td #{align} class=´panel2´>" if level == "normal" + res << " <td #{align} class=´panel2high´>" if level == "high" + res << " <td #{align} class=´panel2low´>" if level == "low" + res << " <table #{AC} border=´#{$rwd_border}´ cellspacing=´3´ cellpadding=´0´>" else puts "<#{@subtype}>" - res.concat "<#{@subtype}>" + res << "<#{@subtype}>" end bef = nil aft = nil case @subtype - when "vertical", "window", "helpwindow", "tabs", "tab" - res.concat Format % ["AftPre", @subtype] if $rwd_debug + when "vertical", "window", "helpwindow", "tab", "panel" + res << Format % ["AftPre", @subtype] if $rwd_debug if @args.include?("spacing") s = "<tr><td> </td></tr>" * (@args["spacing"].to_i) else @@ -427,7 +426,7 @@ bef = "#{s}<tr #{align} #{valign}><td #{align}>" aft = "</td></tr>" when "horizontal", "row" - res.concat Format % ["AftPre", @subtype] if $rwd_debug + res << Format % ["AftPre", @subtype] if $rwd_debug bef = "<td #{align}>" aft = "</td>" end @@ -438,16 +437,16 @@ def postchildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda) case @subtype - when "vertical", "window", "helpwindow", "tabs", "tab" - res.concat Format % ["BefPost", @subtype] if $rwd_debug + when "vertical", "window", "helpwindow", "tab", "panel" + res << Format % ["BefPost", @subtype] if $rwd_debug if @args.include?("spacing") - res.concat "<tr><td> </td></tr>" * (@args["spacing"].to_i) + res << "<tr><td> </td></tr>" * (@args["spacing"].to_i) end when "horizontal", "row" - res.concat Format % ["BefPost", @subtype] if $rwd_debug + res << Format % ["BefPost", @subtype] if $rwd_debug end - res.concat Format % ["Post", @subtype] if $rwd_debug + res << Format % ["Post", @subtype] if $rwd_debug case @subtype when "application" @@ -456,57 +455,69 @@ args["nohelpbutton"] = (not help) - template = $rwd_html_12 - template = $rwd_html_22 if pda + template = $rwd_html_2 + template = $rwd_html_PDA_2 if pda - res.concat(template(template, args)) - when "p" then res.concat "</p>" - when "pre" then res.concat "</pre>" - when "big" then res.concat "</big></p>" - when "small" then res.concat "</small></p>" - when "list" then res.concat "</ul>" - when "item" then res.concat "</li>" - when "empty" then res.concat "</p>" - when "image" then res.concat "" - when "br" then res.concat "" - when "hr" then res.concat "" - when "b" then res.concat "</b>" - when "i" then res.concat "</i>" - when "a" then res.concat "</a>" - when "vertical" then res.concat "</table>" - when "horizontal" then res.concat "</tr></table>" - when "table" then res.concat "</table>" - when "row" then res.concat "</tr>" - when "hidden" then res.concat "</p>" - when "text" then res.concat "</p>" - when "textarea" then res.concat "</p>" - when "password" then res.concat "</p>" - when "checkbox" then res.concat "</p>" - when "radio" then res.concat "</p>" + res <<(template(template, args)) + when "p" then res << "</p>" + when "pre" then res << "</pre>" + when "big" then res << "</big></p>" + when "small" then res << "</small></p>" + when "list" then res << "</ul>" + when "item" then res << "</li>" + when "empty" then res << "</p>" + when "image" then res << "" + when "br" then res << "" + when "hr" then res << "" + when "b" then res << "</b>" + when "i" then res << "</i>" + when "a" then res << "</a>" + when "vertical" then res << "</table>" + when "horizontal" then res << "</tr></table>" + when "table" then res << "</table>" + when "row" then res << "</tr>" + when "hidden" then res << "</p>" + when "text" then res << "</p>" + when "textarea" then res << "</p>" + when "password" then res << "</p>" + when "checkbox" then res << "</p>" + when "radio" then res << "</p>" when "select" - res.concat "</select>" + res << "</select>" $select = nil - when "option" then res.concat "</option>" - when "button" then res.concat "" - when "back" then res.concat "" - when "help" then res.concat "" - when "quit" then res.concat "" - when "close" then res.concat "" - when "reset" then res.concat "" - when "closewindow" then res.concat "" - when "tabs" then res.concat "</table>" - when "tab" then res.concat "</td></tr></table>" + when "option" then res << "</option>" + when "button" then res << "" + when "back" then res << "" + when "help" then res << "" + when "quit" then res << "" + when "close" then res << "" + when "reset" then res << "" + when "closewindow" then res << "" + when "tabs" + res << " </td>" + res << " </tr>" + res << "</table>" + when "tab" + res << "</table>" + when "panel" + res << " </table>" + res << " </td>" + res << " </tr>" + res << " </table>" + res << " </td>" + res << " </tr>" + res << "</table>" else puts "</#{@subtype}>" - res.concat "</#{@subtype}>" + res << "</#{@subtype}>" end before.pop after.pop aft = after[-1] - res.concat Format % ["After", @subtype] if ($rwd_debug and not aft.nil?) - res.concat aft if not aft.nil? + res << Format % ["After", @subtype] if ($rwd_debug and not aft.nil?) + res << aft if not aft.nil? end def template(html, vars) @@ -560,8 +571,8 @@ class Text def prechildren(res, before, after, varshtml, varsstring, switches, help, oneormorefields, firstaction, tabs, tab, pda) if not @text.scan(/[^ \t\r\n]/).empty? - res.concat Format % ["Text", ""] if $rwd_debug - res.concat "#{@text}" + res << Format % ["Text", ""] if $rwd_debug + res << "#{@text}" end end end @@ -600,7 +611,7 @@ varsstring = Hash.new oneormorefields = "" firstaction = "" - html = "" + html = [] vars.each do |key, value| if not key.empty? @@ -638,6 +649,8 @@ windowobject.parsetree("prechildren", "postchildren", html, [""], [""], varshtml, varsstring, switches, (not @helprwd.empty?), oneormorefields, firstaction, tabs, tab, pda) end + html = html.join("") # ??? + html.gsub!(/%%*[[:alnum:]_\-]+%%*/, "") if not $rwd_debug html.gsub!(/%%/, "%") html.gsub!(/\n\n*/, "\n") @@ -974,7 +987,7 @@ if auth.nil? @localbrowsing = true - if ENV.include?("RWDBROWSER") and not ENV["RWDBROWSER"].empty? + if ENV.include?("RWDBROWSER") and not ENV["RWDBROWSER"].nil? and not ENV["RWDBROWSER"].empty? @browserstarted = true @object.exitbrowser @@ -1161,7 +1174,7 @@ end end -$rwd_html_1 = " +$rwd_html["DEFAULT"] = " <!-- Generated by RubyWebDialog. --> <!-- For more information, please contact Erik Veenstra <rwd@erikveen.dds.nl>. --> <html> @@ -1184,27 +1197,65 @@ background : #AAAAAA; } - td.tabs { - border-color : #000000; - border-width : thin; - border-style : none none solid none; + td.panel1 { + border-color : #888888 #EEEEEE #EEEEEE #888888; + border-width : 1pt; + border-style : solid solid solid solid; } - td.tab { - border-color : #000000; - border-width : thin; - border-style : solid solid none solid; + td.panel2 { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 1pt; + border-style : solid solid solid solid; + } + + td.panel1high { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 1pt; + border-style : solid solid solid solid; } - td.thistab { - border-color : #000000; - border-width : medium; + td.panel2high { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 1pt; + border-style : none none none none; + } + + td.panel1low { + border-color : #888888 #EEEEEE #EEEEEE #888888; + border-width : 1pt; + border-style : solid solid solid solid; + } + + td.panel2low { + border-color : #888888 #EEEEEE #EEEEEE #888888; + border-width : 1pt; + border-style : none none none none; + } + + td.tabblad { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 1pt; + border-style : none solid solid solid; + } + + td.passivetab { + background-color : #BBBBBB; + border-color : #DDDDDD #DDDDDD #EEEEEE #DDDDDD; + border-width : 1pt; + border-style : solid solid solid solid; + } + + td.activetab { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 1pt; border-style : solid solid none solid; } td.notab { - border-width : thin; - border-style : none; + border-color : #EEEEEE #EEEEEE #EEEEEE #EEEEEE; + border-width : 1pt; + border-style : none none solid none; } //--> @@ -1335,15 +1386,12 @@ <tr align=´center´> <td align=´center´ bgcolor=´#CCCCCC´> + <table align=´center´ border=´0´ cellspacing=´3´ cellpadding=´0´> + %BODY% + </table> - <table align=´center´ border=´0´ cellspacing=´3´ cellpadding=´0´> - - %BODY% - - </table> - - <input name=´rwd_action´ value=´$RWD_FIRSTACTION$´ type=´hidden´> - <input name=´rwd_session´ value=´$RWD_SESSION$´ type=´hidden´> + <input name=´rwd_action´ value=´$RWD_FIRSTACTION$´ type=´hidden´> + <input name=´rwd_session´ value=´$RWD_SESSION$´ type=´hidden´> </td> </tr> </table> @@ -1437,7 +1485,172 @@ </html> " -$rwd_html_2 = " +$rwd_html["WINDOWSLOOKALIKE"] = " +<!-- Generated by RubyWebDialog. --> +<!-- For more information, please contact Erik Veenstra <rwd@erikveen.dds.nl>. --> +<html> + <head> + <title>%TITLE%</title> + + <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> + <meta http-equiv=´Content-Style-Type´ content=´text/css´> + + <link rel=´shortcut icon´ href=´%LOGO%´> + + <style type=´text/css´> + <!-- + + a { + text-decoration : none; + } + + a:hover { + background : #AAAAAA; + } + + td.window { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 3pt; + border-style : solid solid solid solid; + } + + td.panel1 { + border-color : #888888 #EEEEEE #EEEEEE #888888; + border-width : 1pt; + border-style : solid solid solid solid; + } + + td.panel2 { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 1pt; + border-style : solid solid solid solid; + } + + td.panel1high { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 1pt; + border-style : solid solid solid solid; + } + + td.panel2high { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 1pt; + border-style : none none none none; + } + + td.panel1low { + border-color : #888888 #EEEEEE #EEEEEE #888888; + border-width : 1pt; + border-style : solid solid solid solid; + } + + td.panel2low { + border-color : #888888 #EEEEEE #EEEEEE #888888; + border-width : 1pt; + border-style : none none none none; + } + + td.tabblad { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 1pt; + border-style : none solid solid solid; + } + + td.passivetab { + background-color : #BBBBBB; + border-color : #DDDDDD #DDDDDD #EEEEEE #DDDDDD; + border-width : 1pt; + border-style : solid solid solid solid; + } + + td.activetab { + border-color : #EEEEEE #888888 #888888 #EEEEEE; + border-width : 1pt; + border-style : solid solid none solid; + } + + td.notab { + border-color : #EEEEEE #EEEEEE #EEEEEE #EEEEEE; + border-width : 1pt; + border-style : none none solid none; + } + + //--> + </style> + + <script type=´text/javascript´> + <!-- + function BodyGo() { + $RWD_FOCUS$ + } + //--> + </script> + </head> + + <body bgcolor=´white´ onload=´BodyGo()´ link=´#000000´ vlink=´#000000´ alink=´#000000´> + <form name=´bodyform´ action=´/´ method=´post´> + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´ width=´100%´ height=´100%´> + <tr align=´center´ valign=´middle´> + <td align=´center´> + + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´> + + <tr align=´center´> + <td align=´center´ class=´window´> + + <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´ %WIDTH1%> + <tr align=´center´> + <td align=´center´ bgcolor=´#444488´> + + <table align=´left´ border=´0´ cellspacing=´1´ cellpadding=´0´> + <tr align=´center´> + <td align=´border´><img src=´%LOGO%´ width=´14´ height=´14´></td> + <td align=´center´><b><small><font color=´#FFFFFF´> %TITLE% </font></small></b></td> + </tr> + </table> + + <table align=´right´ border=´0´ cellspacing=´1´ cellpadding=´0´> + <tr align=´center´> + <!-- %HELPBUTTON% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_help\";document.bodyform.submit();´> ? </a></small></b></td> + <!-- %BACKBUTTONS% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_main\";document.bodyform.submit();´> << </a></small></b></td> + <!-- %BACKBUTTONS% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_back\";document.bodyform.submit();´> < </a></small></b></td> + <!-- %CLOSEBUTTON% --><td align=´center´ bgcolor=´#EEEEEE´><b><small><a href=´javascript:document.bodyform.rwd_action.value=\"rwd_quit\";document.bodyform.submit();´> X </a></small></b></td> + </tr> + </table> + + </td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´%WIDTH2%´></td> + </tr> + + <tr align=´center´> + <td align=´center´ bgcolor=´#CCCCCC´> + <table align=´center´ border=´0´ cellspacing=´3´ cellpadding=´0´> + %BODY% + </table> + + <input name=´rwd_action´ value=´$RWD_FIRSTACTION$´ type=´hidden´> + <input name=´rwd_session´ value=´$RWD_SESSION$´ type=´hidden´> + </td> + </tr> + </table> + + </td> + </tr> + + </table> + + </td> + </tr> + </table> + </form> + </body> +</html> +" + +$rwd_html["PDA"] = " <!-- Generated by RubyWebDialog. --> <!-- For more information, please contact Erik Veenstra <rwd@erikveen.dds.nl>. --> <html> @@ -1493,9 +1706,7 @@ <td align=´center´ bgcolor=´#FFFFFF´> <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´> - %BODY% - </table> <input name=´rwd_action´ value=´$RWD_FIRSTACTION$´ type=´hidden´> @@ -1531,5 +1742,5 @@ CgD/ACwAAAAAAQABAAAIBAD/BQQAOw== ".unpack("m").shift -$rwd_html_11, $rwd_html_12 = $rwd_html_1.split(/^\s*%BODY%\s*\r*$/) -$rwd_html_21, $rwd_html_22 = $rwd_html_2.split(/^\s*%BODY%\s*\r*$/) +$rwd_html_1, $rwd_html_2 = $rwd_html[ENV["RWDTHEME"]].split(/^\s*%BODY%\s*\r*$/) +$rwd_html_PDA_1, $rwd_html_PDA_2 = $rwd_html["PDA"].split(/^\s*%BODY%\s*\r*$/) diff -ur rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/tree.lib.rb rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/tree.lib.rb --- rubywebdialogs-0.0.11.tar.gz/rubywebdialogs/lib/tree.lib.rb 2004-09-03 12:26:26.000000000 +0200 +++ rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/tree.lib.rb 2004-11-28 14:41:35.000000000 +0100 @@ -313,26 +313,28 @@ def path(pad) p1 = self - pad.split(/\//).each do |deel| - tag, voorkomen = deel.split(/:/) + unless pad.nil? + pad.split(/\//).each do |deel| + tag, voorkomen = deel.split(/:/) - if (not tag.nil?) and (not p1.nil?) - voorkomen = 1 if voorkomen.nil? - voorkomen = voorkomen.to_i + if (not tag.nil?) and (not p1.nil?) + voorkomen = 1 if voorkomen.nil? + voorkomen = voorkomen.to_i - teller = 0 - p2 = nil - p1.children.each_index do |i| - #if p1.children[i].upordown == Down - unless p1.children[i].subtype.nil? - if p1.children[i].subtype.noquotes == tag.noquotes - teller += 1 - p2 = p1.children[i] if teller == voorkomen + teller = 0 + p2 = nil + p1.children.each_index do |i| + #if p1.children[i].upordown == Down + unless p1.children[i].subtype.nil? + if p1.children[i].subtype.noquotes == tag.noquotes + teller += 1 + p2 = p1.children[i] if teller == voorkomen + end end - end - #end + #end + end + p1 = p2 end - p1 = p2 end end diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/browser.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/browser.lib.rb --- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/browser.lib.rb 2004-11-28 14:41:35.000000000 +0100 +++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/browser.lib.rb 2004-12-05 13:58:40.000000000 +0100 @@ -12,7 +12,7 @@ def windowsbrowser $stderr.puts "Looking for default browser..." - filetype = nil + filetype = "htmlfile" application = nil begin @@ -71,13 +71,10 @@ end end - catch :once do - HTTPServer.serve([port, io]) do |req, resp| - resp << html - resp.flush + HTTPServer.serve([port, io]) do |req, resp| + resp << html - throw :once - end + resp.stop end end diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ftools.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ftools.lib.rb --- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2004-11-28 14:41:35.000000000 +0100 +++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2004-12-05 13:58:40.000000000 +0100 @@ -86,22 +86,6 @@ res end - - def self.findandchangecontent(entry=nil, mask=nil) - Dir.find(entry, mask).each do |file| - unless File.directory?(file) - data1 = File.open(file){|f| f.read} - - data2 = yield(data1) - - if data2 != data1 - $stderr.puts "Changing #{file} ..." - - File.open(file, "w"){|f| f.write data2} - end - end - end - end end class File diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/net.lib.rb --- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-11-28 14:41:35.000000000 +0100 +++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-12-05 13:58:40.000000000 +0100 @@ -1,8 +1,6 @@ require "ev/ruby" require "ev/ftools" -#alias old_timeout :timeout require "net/http" -#alias timeout :old_timeout require "socket" require "uri" require "cgi" @@ -565,6 +563,8 @@ class Response < Hash attr_writer :response attr_reader :cookies + attr_reader :stop + attr_reader :at_stop def initialize(io) @io = io @@ -572,6 +572,8 @@ @cookies = {} @data = "" @syncd = false + @stop = false + @at_stop = lambda{} end def flush @@ -606,11 +608,21 @@ def inspect "(Response: %s)" % [@response, @data].join(", ") end + + def stop(&block) + @stop = true + @at_stop = block unless block.nil? + end + + def stop? + @stop + end end -class HTTPServer - @@times = {} +class HTTPServerException < Exception +end +class HTTPServer def self.serve(portio=80, remote=false, auth=nil, realm="ev/net") port, server = portio @@ -625,43 +637,85 @@ end if not server.nil? - loop do - io = server.accept + count = 0 - catch :rwd_io_error do - begin - req = Request.new(io) - resp = Response.new(io) - rescue - throw :rwd_io_error - end - - begin - ip = req.peeraddr[3] - com = req.request.to_s.strip + ip - rescue NameError - throw :rwd_io_error - end + at_exit do + $stderr.puts "Received #{count} requests" + end - if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp))) - @@times[com]=Time.new.to_f if not @@times.include?(com) + serverthread = + Thread.new do + mutex = Mutex.new - #$stderr.puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: > #{req.request.to_s.strip}" + Thread.current["threads"] = [] - yield(req, resp) + every(1, Thread.current) do |thread| + mutex.synchronize do + thread["threads"].delete_if{|t| (not t.alive?)} + end + end - $stderr.puts "#{Time.new.strftime("%H:%M:%S")}: #{ip}: #{((Time.new.to_f - @@times[com]).to_s + "0"*4)[0..4]}: < #{req.request.to_s.strip}" + loop do + io = server.accept + count += 1 + + thread = + Thread.new(Thread.current, count) do |parentthread, count2| + stop = false + + begin + begin + req = Request.new(io) + resp = Response.new(io) + rescue + raise HTTPServerException + end + + begin + ip = req.peeraddr[3] + rescue NameError + raise HTTPServerException + end + + if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp))) + $stderr.puts "#{count2}, #{Time.new.strftime("%Y-%m-%d.%H:%M:%S")}, #{ip}, #{req.request.to_s.strip}" + + begin + yield(req, resp) + rescue Exception => e + mutex.synchronize do + $stderr.puts e.class.to_s + ": " + e.message + $stderr.puts e.backtrace.collect{|s| "\t"+s}.join("\n") + end + end + + stop = true if resp.stop? + end + + begin + resp.flush + rescue + raise HTTPServerException + end + rescue HTTPServerException + end - @@times.delete(com) - end + parentthread["stop"] = resp if stop + end - begin - resp.flush - rescue - throw :rwd_io_error - end + mutex.synchronize do + Thread.current["threads"] << thread + end end end + + sleep 0.1 while not serverthread["stop"] + + serverthread["threads"].each {|t| t.join} + + serverthread["stop"].at_stop.call + + serverthread.kill end end diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ruby.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ruby.lib.rb --- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-11-28 14:41:35.000000000 +0100 +++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-12-05 13:58:40.000000000 +0100 @@ -1,5 +1,10 @@ require "cgi" require "rbconfig" +require "thread" + +Thread.abort_on_exception = true + +$DEBUG = ($DEBUG or ENV["RUBYDEBUG"] or false) #tekens = ´\w\~\@\#\$\%\^\&\*\-\+´ tekens = ´^\s\r\n\`\!\(\)\[\]\{\}\<\>\,\.\/\?\\\|\=\;\:\"´ @@ -645,19 +650,19 @@ def after(seconds, *args) if not seconds.nil? and not seconds.zero? - Thread.new(*args) do |*args| + Thread.new(*args) do |*args2| sleep seconds - yield(*args) + yield(*args2) end end end def every(seconds, *args) if not seconds.nil? and not seconds.zero? - Thread.new(*args) do |*args| + Thread.new(*args) do |*args2| loop do sleep seconds - yield(*args) + yield(*args2) end end end @@ -740,38 +745,44 @@ end end - if $bm.nil? - require "ev/bm" + label = label.to_s + res = nil + + $bm_mutex = ($bm_mutex or Mutex.new) + + $bm_mutex.synchronize do + if $bm.nil? + require "ev/bm" + + $bm = {} - $bm = {} + at_exit do + format1 = "%10s %10s %10s %10s %10s %10s %10s" + format2 = "%10s %10.6f %10.6f %10.6f %10.6f %10.6f %10d" - at_exit do - format1 = "%10s %10s %10s %10s %10s %10s %10s" - format2 = "%10s %10.6f %10.6f %10.6f %10.6f %10.6f %10d" - - $stderr.puts format1 % ["LABEL", "USERCPU", "SYSCPU", "CUSERCPU", "CSYSCPU", "ELAPSED", "TIMES"] - $bm.sort{|a, b| [a[1], a[0]] <=> [b[1], b[0]]}.each do |k, v| - $stderr.puts format2 % [k, *v] + $stderr.puts format1 % ["LABEL", "USERCPU", "SYSCPU", "CUSERCPU", "CSYSCPU", "ELAPSED", "TIMES"] + $bm.sort{|a, b| [a[1], a[0]] <=> [b[1], b[0]]}.each do |k, v| + $stderr.puts format2 % [k, *v] + end end end - end - - label = label.to_s - res = nil - $bm[label] = [0.0]*5 + [0] unless $bm.include?(label) + $bm[label] = [0.0]*5 + [0] unless $bm.include?(label) + end if block_given? bm = Benchmark.measure{res = yield} bma = bm.to_a # [dummy label, user CPU time, system CPU time, childrens user CPU time, childrens system CPU time, elapsed real time] - 0.upto(4) do |n| - $bm[label][n] += bma[n+1] + $bm_mutex.synchronize do + 0.upto(4) do |n| + $bm[label][n] += bma[n+1] + end + + $bm[label][5] += 1 end end - $bm[label][5] += 1 - res end diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-11-28 14:41:35.000000000 +0100 +++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-12-05 13:58:40.000000000 +0100 @@ -2,6 +2,7 @@ require "ev/xml" require "ev/net" require "ev/browser" +require "ev/thread" require "md5" require "rbconfig" @@ -20,7 +21,6 @@ $rwd_files = File.expand_path("rwd_files", Dir.pwd) $rwd_html = {} - ARGV.delete_if do |arg| arg =~ /^--rwd-/ end @@ -45,7 +45,7 @@ Hash.file(rcfile).each do |k, v| #$stderr.puts "Setting #{k} to \"#{v}\" ..." - ENV[k] = v + ENV[k] = v unless ENV.include?(k) end end @@ -92,7 +92,7 @@ if emptyline.nil? a = self else - a = [emptyline].concat self + a = [emptyline].concat(self) end a.numsort.collect{|s| "<option>#{s.to_html}</option>" }.join("\n") @@ -202,11 +202,11 @@ values = [] if values.nil? options = {} - if File.file?(oldlocation("constraints.csv")) - table = File.basename(@file).gsub(/\.csv$/, "") + if File.file?(oldlocation("constraints.tsv")) + table = File.basename(@file).gsub(/\.tsv$/, "") - CSVFile.new(oldlocation("constraints.csv")).subset(["Table", "Constraint"], [table, "key"], ["Column", "Value"]).values.each do |column, table2| - options[column] = CSVFile.new(oldlocation("#{table2}.csv")).keys.collect{|a| a.join("\t")} + TSVFile.new(oldlocation("constraints.tsv")).subset(["Table", "Constraint"], [table, "key"], ["Column", "Value"]).values.each do |column, table2| + options[column] = TSVFile.new(oldlocation("#{table2}.tsv")).keys.collect{|a| a.join("\t")} end end @@ -967,11 +967,7 @@ def render(res, path, post, download, downloadfile, pda) done = self["object"].render(res, path, post, download, downloadfile, pda, @sessionid) - if done - res.gsub!(/\$RWD_SESSION\$/, "") - else - res.gsub!(/\$RWD_SESSION\$/, "#{@sessionid}") - end + res.gsub!(/\$RWD_SESSION\$/, done ? "" : "#{@sessionid}") return done end @@ -1000,13 +996,21 @@ #if ENV["RWDBROWSER"].downcase =~ /iexplore/ # ??? #@ie = IE.new("http://localhost:#{port}/") #else - if windows? - system("#{ENV["RWDBROWSER"]} \"http://localhost:#{port}/\"".gsub(/%port%/, port.to_s)) - elsif cygwin? - system("#{ENV["RWDBROWSER"].gsub(/\\/, "/").gsub(/ /, "\ ")} \"http://localhost:#{port}/\"".gsub(/%port%/, port.to_s)) - else - system("#{ENV["RWDBROWSER"]} \"http://localhost:#{port}/\"".gsub(/%port%/, port.to_s)) + browser = ENV["RWDBROWSER"] + url = "http://localhost:%s/" % [port] + + if cygwin? + browser.gsub!(/\\/, "/") + browser.gsub!(/ /, "\ ") end + + re = /[$%]1\b/ + command = "%s \"%s\"" % [browser, url] + command = browser.gsub(re, url) if browser =~ re + + command.gsub!(/%port%/, port.to_s) + + system(command) #end puts "The browser has terminated." @@ -1016,12 +1020,15 @@ # Start server. - catch :rwd_exit do - portio = port - portio = [port, io] unless io.nil? - HTTPServer.serve(portio, (not auth.nil?)) do |req, resp| + portio = port + portio = [port, io] unless io.nil? + threadlimiter = ThreadLimiter.new(1) + + HTTPServer.serve(portio, (not auth.nil?)) do |req, resp| + threadlimiter.wait do + vars = req.vars.dup - pad = req.request.path + pad = (req.request.path or "/") if auth.kind_of? String file = "#{home}/#{auth}" @@ -1034,28 +1041,26 @@ #oldsessionid = vars["rwd_session"] oldsessionid = req.cookies["sessionid"] - # Retrieve session. + # Retrieve session. session = @sessions[oldsessionid] - # Eventually create new session. + # Eventually create new session. if session.nil? + sessionid = MD5.new(req.peeraddr[3].to_s + @object.inspect.to_s + ("%1.6f" % Time.now.to_f)).to_s while (sessionid == nil or @sessions.include?(sessionid)) + session = RWDSession.new(sessionid) + if auth.nil? - sessionid = MD5.new(req.peeraddr[3].to_s + @object.inspect.to_s).to_s - session = RWDSession.new(sessionid) session["object"] = @object else - sessionid = nil - sessionid = MD5.new(Time.new.to_s + req.peeraddr[3].to_s + @object.inspect.to_s).to_s while (sessionid.nil? or @sessions.include?(sessionid)) - session = RWDSession.new(sessionid) session["object"] = @object.clone end if oldsessionid.nil? or oldsessionid.empty? - if not auth.nil? and not auth.empty? and not session.authenticated and pad != "/pixel.gif" + if not auth.nil? and not auth.empty? and not session.authenticated and pad != "/rwd_pixel.gif" - # Check authentication + # Check authentication us = vars["rwd_a"] pa = vars["rwd_b"] @@ -1080,15 +1085,15 @@ vars = {} end - # Avoid timeout. + # Avoid timeout. session.touch if pad == "/" - # Serve methods/callbacks. + # Serve methods/callbacks. - # Build new page. + # Build new page. download = "" downloadfile = "" @@ -1119,29 +1124,29 @@ @sessions.delete(session.sessionid) end - # Eventually delete this session. + # Eventually delete this session. if done @sessions.delete(session.sessionid) if @localbrowsing - resp.flush + resp.stop if @browserstarted and not @browserthread.nil? and @browserthread.alive? - puts "Waiting for the browser to terminate..." + resp.stop do + puts "Waiting for the browser to terminate..." - @browserthread.join + @browserthread.join + end end - - throw :rwd_exit end end else - # Serve files. + # Serve files. - if pad == "/pixel.gif" + if pad == "/rwd_pixel.gif" resp["Cache-Control"] = "max-age=86400" resp["Content-Type"] = "image/gif" resp << $rwd_pixel @@ -1169,6 +1174,7 @@ end end + end end end @@ -1181,7 +1187,7 @@ <head> <title>%TITLE%</title> - <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> + <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> --> <meta http-equiv=´Content-Style-Type´ content=´text/css´> <link rel=´shortcut icon´ href=´%LOGO%´> @@ -1279,81 +1285,81 @@ <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´> @@ -1381,7 +1387,7 @@ </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´%WIDTH2%´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´%WIDTH2%´></td> </tr> <tr align=´center´> @@ -1398,81 +1404,81 @@ </td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´#EEEEEE´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´black´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> </table> @@ -1492,7 +1498,7 @@ <head> <title>%TITLE%</title> - <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> + <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> --> <meta http-equiv=´Content-Style-Type´ content=´text/css´> <link rel=´shortcut icon´ href=´%LOGO%´> @@ -1622,7 +1628,7 @@ </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´pixel.gif´ height=´1´ width=´%WIDTH2%´></td> + <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´%WIDTH2%´></td> </tr> <tr align=´center´> @@ -1657,7 +1663,7 @@ <head> <title>%TITLE%</title> - <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> + <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> --> <link rel=´shortcut icon´ href=´%LOGO%´> diff -ur rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/thread.lib.rb rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/thread.lib.rb --- rubywebdialogs-0.1.0.tar.gz/rubywebdialogs/lib/thread.lib.rb 2005-06-04 14:42:00.080670816 +0200 +++ rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/thread.lib.rb 2004-12-05 13:58:40.000000000 +0100 @@ -0,0 +1,63 @@ +require "ev/ruby" +require "thread" + +class FakeThread + def initialize(*args) + yield(*args) + end + + def join + end +end + +class ThreadLimiter + def initialize(limit) + @limit = limit + @count = 0 + @threads = [] + @mutex = Mutex.new + @cv = ConditionVariable.new + + every(1) do + @mutex.synchronize do + @threads.dup.each do |t| + unless t.alive? + $stderr.puts "Found dead thread." + + @threads.delete(t) + + @count -= 1 + + @cv.signal + end + end + end + end + end + + def wait + if block_given? + self.wait + yield + self.signal + else + @mutex.synchronize do + @threads << Thread.current + + @count += 1 + + @cv.wait(@mutex) if @count > @limit + end + end + end + + def signal + @mutex.synchronize do + @threads.delete(Thread.current) + + @count -= 1 + + @cv.signal + end + end +end diff -ur rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ruby.lib.rb rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/ruby.lib.rb --- rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-12-05 13:58:40.000000000 +0100 +++ rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-12-17 12:40:15.000000000 +0100 @@ -792,6 +792,7 @@ set_trace_func lambda { |event, file, line, id, binding, classname| $stderr.printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname } + if block_given? res = yield diff -ur rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-12-05 13:58:40.000000000 +0100 +++ rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-12-17 12:40:15.000000000 +0100 @@ -40,11 +40,9 @@ Format = "\n<!-- %-10s %-10s -->\t" unless rcfile.nil? - $stderr.puts "Reading #{rcfile} ..." + puts "Reading #{rcfile} ..." Hash.file(rcfile).each do |k, v| - #$stderr.puts "Setting #{k} to \"#{v}\" ..." - ENV[k] = v unless ENV.include?(k) end end @@ -276,7 +274,23 @@ when "list" then res << "<ul #{align}>" when "item" then res << "<li #{align}>" when "empty" then res << "<p><br>" - when "image" then res << "<img src=´#{@args["src"]}´ alt=´#{@args["alt"]}´>" + when "image" + width = "width=´#{@args["width"]}" if @args.include?("width") + height = "height=´#{@args["height"]}´" if @args.include?("height") + + res << "<img src=´#{@args["src"]}´ alt=´#{@args["alt"]}´ #{width} #{height}>" + when "progressbar" + width = 200 + + res << "<table>" + res << " <tr>" + res << " <td colspan=´2´><img src=´rwd_pixel.gif´ height=´1´ width=´#{width+5}´></td>" + res << " </tr>" + res << " <tr>" + res << " <td bgcolor=´#DDDDDD´><img src=´rwd_pixel.gif´ height=´10´ width=´#{(width*@args["value"].to_f).to_i}´></td>" + res << " <td bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´10´ width=´#{(width*(1.0-@args["value"].to_f)).to_i}´></td>" + res << " </tr>" + res << "</table>" when "br" then res << "<br>" when "hr" then res << "<hr>" when "b" then res << "<b>" @@ -344,6 +358,10 @@ res << "<input type=´submit´ value=´Back´ onclick=´document.bodyform.rwd_action.value=\"rwd_back\";´>" firstaction << "rwd_back" if firstaction.empty? oneormorefields << "true" + when "cancel" + res << "<input type=´submit´ value=´Cancel´ onclick=´document.bodyform.rwd_action.value=\"rwd_cancel\";´>" + firstaction << "rwd_cancel" if firstaction.empty? + oneormorefields << "true" when "help" res << "<input type=´submit´ value=´Help´ onclick=´document.bodyform.rwd_action.value=\"rwd_help\";´>" firstaction << "rwd_help" if firstaction.empty? @@ -356,9 +374,13 @@ res << "<input type=´submit´ value=´Close´ onclick=´window.close();´>" firstaction << "rwd_quit" if firstaction.empty? oneormorefields << "true" + when "main" + res << "<input type=´submit´ value=´Main´ onclick=´document.bodyform.rwd_action.value=\"rwd_main\";´>" + firstaction << "rwd_main" if firstaction.empty? + oneormorefields << "true" when "reset" res << "<input type=´reset´ value=´Reset´>" - firstaction << "rwd_quit" if firstaction.empty? + firstaction << "rwd_quit" if firstaction.empty? # ??? oneormorefields << "true" when "closewindow" #res << "<script type=´text/javascript´>\n" # ??? @@ -467,6 +489,7 @@ when "item" then res << "</li>" when "empty" then res << "</p>" when "image" then res << "" + when "progressbar" then res << "" when "br" then res << "" when "hr" then res << "" when "b" then res << "</b>" @@ -488,9 +511,11 @@ when "option" then res << "</option>" when "button" then res << "" when "back" then res << "" + when "cancel" then res << "" when "help" then res << "" when "quit" then res << "" when "close" then res << "" + when "main" then res << "" when "reset" then res << "" when "closewindow" then res << "" when "tabs" @@ -606,7 +631,7 @@ @helprwd = (@@helpwindows[rwd][window] or "").dup end - def render(pda, vars=Hash.new, switches=Hash.new, help=false, tab="") + def render(pda, action=nil, vars=Hash.new, switches=Hash.new, help=false, tab="") varshtml = Hash.new varsstring = Hash.new oneormorefields = "" @@ -661,6 +686,8 @@ focus = "document.bodyform.elements[0].focus();" end + firstaction = action if windowobject.args.keys.include?("refresh") unless action.nil? + html.gsub!(/\$RWD_FIRSTACTION\$/ , firstaction) html.gsub!(/\$RWD_FOCUS\$/ , focus) @@ -670,13 +697,34 @@ class RWDMessage < RWDWindow def initialize(msg) - super("<window title=´RWD Message´ nobackbuttons noclosebutton><vertical><p>#{msg}</p><back/></vertical></window>") + super("<window title=´RWD Message´ nobackbuttons noclosebutton><p>#{msg}</p><back/></window>") end end class RWDError < RWDWindow def initialize(msg) - super("<window title=´RWD Error´ nobackbuttons noclosebutton><vertical><p><b>Error:</b> #{msg}</p><back/></vertical></window>") + super("<window title=´RWD Error´ nobackbuttons noclosebutton><p><b>Error:</b> #{msg}</p><back/></window>") + end +end + +class RWDProgressBar < RWDWindow + def initialize(refresh, progress) + s = "" + s << "<window title=´RWD Progress´ nobackbuttons noclosebutton refresh=´#{refresh}´>" + if progress.length == 1 + progress.each do |caption, value| + s << "<p>#{caption}</p><progressbar value=´#{value}´/><p>#{(100*value).to_i}%%</p>" + end + else + s << "<table>" + progress.each do |caption, value| + s << "<row><p align=´left´>#{caption}</p><progressbar value=´#{value}´/><p align=´right´>#{(100*value).to_i}%%</p></row>" + end + s << "</table>" + end + s << "<cancel/>" + s << "</window>" + super(s) end end @@ -729,7 +777,7 @@ help = false back = false tab = "" - @rwd_msg = nil + @rwd_msgtype = nil @rwd_download = nil @rwd_download_file = nil @@ -751,10 +799,12 @@ # Stack handling for rwd_action, rwd_window and rwd_tab. - @rwd_action = vars["rwd_action"] + @rwd_action = vars["rwd_action"] if vars.include?("rwd_action") @rwd_action, @rwd_args = @rwd_action.split(/\//, 2) unless @rwd_action.nil? @rwd_action, rest = @rwd_action.split(/\?/) unless @rwd_action.nil? + @rwd_refresh_action = (@rwd_action or @rwd_refresh_action or "main") + unless rest.nil? rest.each do |s| k, v = s.split(/=/, 2) @@ -762,6 +812,12 @@ end end + if @rwd_action == "rwd_cancel" + @rwd_progress_thread.kill unless @rwd_progress_thread.nil? + @rwd_progress_thread = nil + @rwd_action = "rwd_back" + end + if @rwd_action =~ /^rwd_tab_/ @rwd_tab = @rwd_action.sub(/^rwd_tab_/, "") @rwd_history[-1][3] = @rwd_tab @@ -820,12 +876,12 @@ # History stuff - @rwd_history = [["main", nil, "main", nil]] if @rwd_action == "main" - @rwd_history = [["main", nil, "main", nil]] if @rwd_history.empty? + @rwd_history = [["main", [], "main", ""]] if @rwd_action == "main" + @rwd_history = [["main", [], "main", ""]] if @rwd_history.empty? a = [@rwd_action, @rwd_args, @rwd_window, @rwd_tab] - @rwd_history.push a if (@rwd_history[-1] != a or not @rwd_msg.nil?) + @rwd_history.push a if (@rwd_history[-1] != a or not @rwd_msgtype.nil?) end end @@ -842,6 +898,7 @@ puts "Pre: #{key} -> #{value.inspect}" if $rwd_debug end + # Answer to browser. if done @@ -853,14 +910,18 @@ download << @rwd_download downloadfile << @rwd_download_file else - if not @rwd_msg.nil? + if not @rwd_msgtype.nil? res << RWDMessage.new(@rwd_msg).render(pda) if @rwd_msgtype == "message" res << RWDError.new(@rwd_msg).render(pda) if @rwd_msgtype == "error" else - puts "Window: #{@rwd_window}" if $rwd_debug - puts "Tab: #{@rwd_tab}" if $rwd_debug + if not @rwd_progress_thread.nil? + res << RWDProgressBar.new(@rwd_progress_refresh, @rwd_progress_progress).render(pda, @rwd_refresh_action) + else + puts "Window: #{@rwd_window}" if $rwd_debug + puts "Tab: #{@rwd_tab}" if $rwd_debug - res << RWDWindow.new(@rwd_xml, @rwd_window).render(pda, vars, @rwd_switches, help, @rwd_tab) + res << RWDWindow.new(@rwd_xml, @rwd_window).render(pda, @rwd_refresh_action, vars, @rwd_switches, help, @rwd_tab) + end end end end @@ -872,16 +933,48 @@ @rwd_history[-1][2] == @rwd_window end - def message(msg) + def message(msg, &block) @rwd_msg = msg @rwd_msgtype = "message" end - def error(msg) + def error(msg, &block) @rwd_msg = msg @rwd_msgtype = "error" end + def progressbar(refresh, *progress) + @rwd_progress_refresh = (refresh or 1) + @rwd_progress_progress = [] + + while not progress.empty? + s = (progress.shift or "") + if s.kind_of?(Array) + caption, value = s + value = (value or 0.0).to_f + else + caption = s + value = (progress.shift or 0.0).to_f + end + + @rwd_progress_progress << [caption, value] + end + + if @rwd_progress_thread.nil? + @rwd_progress_progress.each do |a| + a[1] = 0.0 + end + + @rwd_progress_thread = + Thread.new do + yield + end + Thread.pass + end + + @rwd_progress_thread = nil unless @rwd_progress_thread.alive? + end + def download(data, filename="") @rwd_download = data @rwd_download_file = filename @@ -996,12 +1089,12 @@ #if ENV["RWDBROWSER"].downcase =~ /iexplore/ # ??? #@ie = IE.new("http://localhost:#{port}/") #else - browser = ENV["RWDBROWSER"] + browser = ENV["RWDBROWSER"].dup url = "http://localhost:%s/" % [port] if cygwin? browser.gsub!(/\\/, "/") - browser.gsub!(/ /, "\ ") + browser.gsub!(/ /, "\\ ") end re = /[$%]1\b/ @@ -1010,7 +1103,7 @@ command.gsub!(/%port%/, port.to_s) - system(command) + system(command) or puts "Starting of the browser failed, or the browser terminated abnormally.\nCommand => #{command}" #end puts "The browser has terminated." @@ -1187,8 +1280,9 @@ <head> <title>%TITLE%</title> - <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> --> + <meta http-equiv=´Content-Type´ content=´text/html; charset=%CHARSET%´> <meta http-equiv=´Content-Style-Type´ content=´text/css´> + <meta http-equiv=´Refresh´ content=´%REFRESH%, javascript:document.bodyform.submit();´> <link rel=´shortcut icon´ href=´%LOGO%´> @@ -1498,8 +1592,9 @@ <head> <title>%TITLE%</title> - <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> --> + <meta http-equiv=´Content-Type´ content=´text/html; charset=%CHARSET%´> <meta http-equiv=´Content-Style-Type´ content=´text/css´> + <meta http-equiv=´Refresh´ content=´%REFRESH%, javascript:document.bodyform.submit();´> <link rel=´shortcut icon´ href=´%LOGO%´> @@ -1663,7 +1758,8 @@ <head> <title>%TITLE%</title> - <!-- <meta http-equiv=´Content-Type´ content=´text/html; charset=ISO-8859-15´> --> + <meta http-equiv=´Content-Type´ content=´text/html; charset=%CHARSET%´> + <meta http-equiv=´Refresh´ content=´%REFRESH%, javascript:document.bodyform.submit();´> <link rel=´shortcut icon´ href=´%LOGO%´> diff -ur rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/tree.lib.rb rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/tree.lib.rb --- rubywebdialogs-0.1.1.tar.gz/rubywebdialogs/lib/tree.lib.rb 2004-12-05 13:58:40.000000000 +0100 +++ rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/tree.lib.rb 2004-12-17 12:40:15.000000000 +0100 @@ -65,7 +65,7 @@ attr_writer :parent attr_reader :children attr_writer :children - attr_writer :closed + attr_reader :closed attr_writer :closed attr_reader :text attr_writer :text diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/autorequire.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/autorequire.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/autorequire.rb 2005-06-04 14:42:01.086517904 +0200 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/autorequire.rb 2004-12-30 21:05:56.000000000 +0100 @@ -0,0 +1 @@ +require newlocation("ev/rwd") diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/CHANGELOG rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/CHANGELOG --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/CHANGELOG 2005-06-04 14:42:01.087517752 +0200 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/CHANGELOG 2005-06-04 14:33:00.000000000 +0200 @@ -0,0 +1,157 @@ +---------------------------------------------------------------- + +0.2.0 - 04.06.2005 + +* Added better browser detection on Cygwin. + +* Added mime support for rwd_files/* (hard coded, for now...) + +* RWDialog#serve now stops the application when the application + is being wrapped by RubyScript2Exe. Fixed a bug concerning + the detection of configuration files. + +* Added Array#rwd_table. + +* Added RWDialog#text. + +* Added RWDialog#timeout. + +* I changed a lot of small other things which are probably not + worth mentioning individually, but enhance the total "feel" + of RubyWebDialogs. + +---------------------------------------------------------------- + +0.1.2 - 16.12.2004 + +* Added refresh to <window>. + +* Added width and height to <image>. + +* Added the (experimental) progress bar. + +* Fixed a bug concerning a frozen string ( ENV["RWDBROWSER"]). + +* Fixed the handling of spaces in ENV["RWDBROWSER"] under + Cygwin. + +---------------------------------------------------------------- + +0.1.1 - 05.12.2004 + +* Adding the key/values in the configuration file to ENV is + only done if ENV doesn´t already include the key. + +* Corrected the handling of %1 in ENV["RWDBROWSER"]. + +* Corrected the handling of http://localhost:7701 (no final /). + +* Renamed the embedded pixel.gif to rwd_pixel.gif. + +* Removed the definition of the (western) character set in the + templates. + +---------------------------------------------------------------- + +0.1.0 - 28.11.2004 + +* Added browser detection for Linux. + +* Added theme handling. + +* Added <panel>. + +* Added alt to <image>. + +* Changed the layout of tabs. + +---------------------------------------------------------------- + +0.0.11 - 03.09.2004 + +* Added a different template for PDA´s and the (experimental) + detection of PDA´s. + +* Added filename handling for download. + +---------------------------------------------------------------- + +0.0.10 - 21.08.2004 + +* Session-ids are now stored in cookies, in stead of in hidden + form fields. + +* Added download. + +---------------------------------------------------------------- + +0.0.9 - 15.05.2004 + +* Default port isn´t 1234 anymore, but one in the range + 7701-7709. + +* Created RWDReconnect. + +* Added gsub(/%port%/, port.to_s) to ENV["RWDBROWSER"]. + +* Changed the call to Hash#rwd_table. + +---------------------------------------------------------------- + +0.0.8 - 05.05.2004 + +* Added @rwd_call_after_back. + +---------------------------------------------------------------- + +0.0.7 - 28.04.2004 + +* Corrected some exception handling regarding the IO with the + browser. + +* Added maxlength to text and password. + +* Added network without authentication. + +---------------------------------------------------------------- + +0.0.6 - 24.04.2004 + +* Corrected io-handling. Konqueror could kill the application. + +* Changed some layout ( window and tabs). + +---------------------------------------------------------------- + +0.0.5 - 23.04.2004 + +* Replaced the symlink by a copy in install.rb . It didn´t work + under Linux. + +---------------------------------------------------------------- + +0.0.4 - 22.04.2004 + +* Changed the recently added tab-handling. + +* Corrected some cursor positioning glitches. + +---------------------------------------------------------------- + +0.0.3 - 21.04.2004 + +* A minor change in message. + +---------------------------------------------------------------- + +0.0.2 - 20.04.2004 + +* Added some tab-handling. + +---------------------------------------------------------------- + +0.0.1 - 17.04.2004 + +* Alpha release + +---------------------------------------------------------------- diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/init.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/init.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/init.rb 2004-12-17 12:40:16.000000000 +0100 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/init.rb 2005-06-04 14:41:53.000000000 +0200 @@ -1,37 +1,64 @@ require "rbconfig" +require "ftools" -def mkdirrec(dir) - pdir = File.dirname(dir) +if __FILE__ == $0 - if not pdir.empty? and not File.directory?(pdir) - mkdirrec (pdir) - end + Dir.chdir(File.dirname($0)) - Dir.mkdir(dir) rescue nil -end + FromDirs = [".", "./lib", "./rubylib/lib"] + ToDir = Config::CONFIG["sitelibdir"] + "/ev" + + File.mkpath(ToDir) if not File.directory?(ToDir) + + FromDirs.each do |fromdir| + fromdir = Dir.pwd if fromdir == "." -Dir.chdir(File.dirname($0)) + if File.directory?(fromdir) + Dir.new(fromdir).each do |file| + if file =~ /\.lib\.rb$/ + fromfile = fromdir + "/" + file + tofile = ToDir + "/" + file.sub(/\.lib\.rb/, ".rb") -FromDirs = [".", "./lib", "./rubylib/lib"] -ToDir = Config::CONFIG["sitelibdir"] + "/ev" + printf "%s -> %s\n", fromfile, tofile -mkdirrec(ToDir) if not File.directory?(ToDir) + File.delete(tofile) if File.file?(tofile) + + File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} + end + end + end + end -FromDirs.each do |fromdir| - fromdir = Dir.pwd if fromdir == "." +else - if File.directory?(fromdir) - Dir.new(fromdir).each do |file| - if file =~ /\.lib\.rb$/ - fromfile = fromdir + "/" + file - tofile = ToDir + "/" + file.sub(/\.lib\.rb/, ".rb") + FromDirs = [".", "./lib", "./rubylib/lib"] + ToDir = "./ev" - printf "%s -> %s\n", fromfile, tofile + File.mkpath(ToDir) if not File.directory?(ToDir) - File.delete(tofile) if File.file?(tofile) + FromDirs.each do |fromdir| + fromdir = Dir.pwd if fromdir == "." - File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} + if File.directory?(fromdir) + Dir.new(fromdir).each do |file| + if file =~ /\.lib\.rb$/ + fromfile = fromdir + "/" + file + tofile = ToDir + "/" + file.sub(/\.lib\.rb/, ".rb") + + #printf "%s -> %s\n", fromfile, tofile + + File.delete(tofile) if File.file?(tofile) + + File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} + end end end end + + oldlocation do + file = newlocation("autorequire.rb") + + load file if File.file?(file) + end + end diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/install.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/install.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/install.rb 2004-12-17 12:40:16.000000000 +0100 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/install.rb 2005-06-04 14:41:53.000000000 +0200 @@ -1,37 +1,64 @@ require "rbconfig" +require "ftools" -def mkdirrec(dir) - pdir = File.dirname(dir) +if __FILE__ == $0 - if not pdir.empty? and not File.directory?(pdir) - mkdirrec (pdir) - end + Dir.chdir(File.dirname($0)) - Dir.mkdir(dir) rescue nil -end + FromDirs = [".", "./lib", "./rubylib/lib"] + ToDir = Config::CONFIG["sitelibdir"] + "/ev" + + File.mkpath(ToDir) if not File.directory?(ToDir) + + FromDirs.each do |fromdir| + fromdir = Dir.pwd if fromdir == "." -Dir.chdir(File.dirname($0)) + if File.directory?(fromdir) + Dir.new(fromdir).each do |file| + if file =~ /\.lib\.rb$/ + fromfile = fromdir + "/" + file + tofile = ToDir + "/" + file.sub(/\.lib\.rb/, ".rb") -FromDirs = [".", "./lib", "./rubylib/lib"] -ToDir = Config::CONFIG["sitelibdir"] + "/ev" + printf "%s -> %s\n", fromfile, tofile -mkdirrec(ToDir) if not File.directory?(ToDir) + File.delete(tofile) if File.file?(tofile) + + File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} + end + end + end + end -FromDirs.each do |fromdir| - fromdir = Dir.pwd if fromdir == "." +else - if File.directory?(fromdir) - Dir.new(fromdir).each do |file| - if file =~ /\.lib\.rb$/ - fromfile = fromdir + "/" + file - tofile = ToDir + "/" + file.sub(/\.lib\.rb/, ".rb") + FromDirs = [".", "./lib", "./rubylib/lib"] + ToDir = "./ev" - printf "%s -> %s\n", fromfile, tofile + File.mkpath(ToDir) if not File.directory?(ToDir) - File.delete(tofile) if File.file?(tofile) + FromDirs.each do |fromdir| + fromdir = Dir.pwd if fromdir == "." - File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} + if File.directory?(fromdir) + Dir.new(fromdir).each do |file| + if file =~ /\.lib\.rb$/ + fromfile = fromdir + "/" + file + tofile = ToDir + "/" + file.sub(/\.lib\.rb/, ".rb") + + #printf "%s -> %s\n", fromfile, tofile + + File.delete(tofile) if File.file?(tofile) + + File.open(tofile, "w") {|f| f.puts File.new(fromfile).readlines} + end end end end + + oldlocation do + file = newlocation("autorequire.rb") + + load file if File.file?(file) + end + end diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/browser.lib.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/browser.lib.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/browser.lib.rb 2004-12-17 12:40:15.000000000 +0100 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/browser.lib.rb 2005-06-04 14:41:52.000000000 +0200 @@ -16,20 +16,33 @@ application = nil begin - Win32::Registry::HKEY_CLASSES_ROOT.open(´.html´) do |reg| + Win32::Registry::HKEY_CLASSES_ROOT.open(".html") do |reg| filetype = reg[""] end - Win32::Registry::HKEY_CLASSES_ROOT.open(filetype + ´\shell\open\command´) do |reg| + Win32::Registry::HKEY_CLASSES_ROOT.open(filetype + "\\shell\\open\\command") do |reg| application = reg[""] end rescue NameError - $stderr.puts "Only available for Windows." + $stderr.puts "Only available for Windows and Cygwin." end application end +def cygwinbrowser + browser, *args = windowsbrowser.splitwords + browser = browser.gsub(/\\/, "/") + #browser = browser + + args.collect!{|a| a.gsub(/\\/, "/")} + #args.collect!{|a| "\"%s\"" % [a.gsub(/\\/, "/")]} + #args.collect!{|a| "\"%s\"" % [a]} + + res = "\"%s\" %s" % [browser, args.join(" ")] + res +end + def linuxbrowser application = "" @@ -47,25 +60,26 @@ def defaultbrowser res = nil res = windowsbrowser if windows? + res = cygwinbrowser if cygwin? res = linuxbrowser if linux? res end +def showurlinbrowser(url, browser=defaultbrowser) + command = "#{browser} \"#{url}\"" + + system(command) or $stderr.puts "Starting of the browser failed, or the browser terminated abnormally.\nCommand => #{command}" +end + def showinbrowser(html, browser=defaultbrowser) port, io = TCPServer.freeport(7701, 7709) unless browser.nil? Thread.new do begin - #command = "1234 \"http://localhost:#{port}\"" if linux? - #command = "L:/prog/MozillaFirefox/firefox.exe \"http://localhost:#{port}\"" if cygwin? - #command = Win32::Registry::HKEY_CLASSES_ROOT.open(´htmlfile\shell\open\command´)[0] + " \"http://localhost:#{port}/\"" if windows? - - command = "#{browser} \"http://localhost:#{port}\"" - Thread.pass - system(command) + showurlinbrowser("http://localhost:#{port}/", browser) rescue end end diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/ftools.lib.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/ftools.lib.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2004-12-17 12:40:15.000000000 +0100 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/ftools.lib.rb 2005-06-04 14:41:52.000000000 +0200 @@ -1,22 +1,12 @@ require "ftools" class Dir - def self.mkdirrec(dir) - pdir = File.dirname(dir) - - if not pdir.empty? and not File.directory?(pdir) - Dir.mkdirrec(pdir) - end - - Dir.mkdir(dir) rescue nil - end - def self.copy(from, to) if File.directory?(from) pdir = Dir.pwd todir = File.expand_path(to) - mkdirrec(todir) + File.mkpath(todir) Dir.chdir(from) Dir.new(".").each do |e| @@ -26,7 +16,7 @@ else todir = File.dirname(File.expand_path(to)) - mkdirrec(todir) + File.mkpath(todir) File.copy(from, to) end @@ -38,6 +28,8 @@ end def self.rm_rf(entry) + File.chmod(0755, entry) + if File.ftype(entry) == "directory" pdir = Dir.pwd @@ -47,16 +39,24 @@ end Dir.chdir(pdir) - Dir.delete(entry) + begin + Dir.delete(entry) + rescue => e + $stderr.puts e.message + end else - File.delete(entry) + begin + File.delete(entry) + rescue => e + $stderr.puts e.message + end end end def self.find(entry=nil, mask=nil) entry = "." if entry.nil? - entry = entry.gsub!(/[\/\\]*$/, "") unless entry.nil? + entry = entry.gsub(/[\/\\]*$/, "") unless entry.nil? mask = /^#{mask}$/i if mask.kind_of?(String) @@ -77,8 +77,8 @@ ensure Dir.chdir(pdir) end - rescue Errno::EACCES => error - puts error + rescue Errno::EACCES => e + $stderr.puts e.message end else res += [entry] if mask.nil? or entry =~ mask @@ -99,7 +99,7 @@ # Rollback if File.file?(backupfile) and File.file?(controlfile) - $stdout.puts "Restoring #{file}..." + $stderr.puts "Restoring #{file}..." File.copy(backupfile, file) # Rollback from phase 3 end @@ -139,7 +139,11 @@ end def self.touch(file) - File.open(file, "a"){|f|} + if File.exists?(file) + File.utime(Time.now, File.mtime(file), file) + else + File.open(file, "a"){|f|} + end end def self.which(file) diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/mime.lib.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/mime.lib.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/mime.lib.rb 2005-06-04 14:42:01.091517144 +0200 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/mime.lib.rb 2005-06-04 14:41:52.000000000 +0200 @@ -0,0 +1,328 @@ +module EVMime + MimeType = {} + + MimeType[´123´] = ´application/vnd.lotus-1-2-3´ + MimeType[´3ds´] = ´image/x-3ds´ + MimeType[´a´] = ´application/x-unix-archive´ + MimeType[´abw´] = ´application/x-abiword´ + MimeType[´ac3´] = ´audio/ac3´ + MimeType[´afm´] = ´application/x-font-afm´ + MimeType[´ag´] = ´image/x-applix-graphic´ + MimeType[´aif´] = ´audio/x-aiff´ + MimeType[´aifc´] = ´audio/x-aiff´ + MimeType[´aiff´] = ´audio/x-aiff´ + MimeType[´ap´] = ´application/x-applix-presents´ + MimeType[´ape´] = ´application/x-ape´ + MimeType[´arj´] = ´application/x-arj´ + MimeType[´as´] = ´application/x-applix-spreadsheet´ + MimeType[´asc´] = ´text/plain´ + MimeType[´asf´] = ´video/x-ms-asf´ + MimeType[´asp´] = ´application/x-asp´ + MimeType[´asx´] = ´audio/x-ms-asx´ + MimeType[´au´] = ´audio/x-ulaw´ + MimeType[´avi´] = ´video/x-msvideo´ + MimeType[´aw´] = ´application/x-applix-word´ + MimeType[´bak´] = ´application/x-backup´ + MimeType[´bcpio´] = ´application/x-bcpio´ + MimeType[´bdf´] = ´application/x-font-bdf´ + MimeType[´bib´] = ´text/bib´ + MimeType[´bin´] = ´application/octet-stream´ + MimeType[´blend´] = ´application/x-blender´ + MimeType[´blender´] = ´application/x-blender´ + MimeType[´bmp´] = ´image/bmp´ + MimeType[´bz´] = ´application/x-bzip´ + MimeType[´bz2´] = ´application/x-bzip´ + MimeType[´c´] = ´text/x-c´ + MimeType[´c++´] = ´text/x-c++´ + MimeType[´cc´] = ´text/x-c++´ + MimeType[´cdf´] = ´application/x-netcdf´ + MimeType[´cdr´] = ´application/vnd.corel-draw´ + MimeType[´cgi´] = ´application/x-cgi´ + MimeType[´cgm´] = ´image/cgm´ + MimeType[´class´] = ´application/x-java-byte-code´ + MimeType[´cls´] = ´text/x-tex´ + MimeType[´cpio´] = ´application/x-cpio´ + MimeType[´cpp´] = ´text/x-c++´ + MimeType[´csh´] = ´text/x-csh´ + MimeType[´css´] = ´text/css´ + MimeType[´csv´] = ´text/x-comma-separated-values´ + MimeType[´dat´] = ´video/mpeg´ + MimeType[´dbf´] = ´application/x-xbase´ + MimeType[´dc´] = ´application/x-dc-rom´ + MimeType[´dcl´] = ´text/x-dcl´ + MimeType[´dcm´] = ´image/x-dcm´ + MimeType[´deb´] = ´application/x-deb´ + MimeType[´desktop´] = ´application/x-gnome-app-info´ + MimeType[´dia´] = ´application/x-dia-diagram´ + MimeType[´diff´] = ´text/x-patch´ + MimeType[´djv´] = ´image/vnd.djvu´ + MimeType[´djvu´] = ´image/vnd.djvu´ + MimeType[´doc´] = ´application/msword´ + MimeType[´dsl´] = ´text/x-dsl´ + MimeType[´dtd´] = ´text/x-dtd´ + MimeType[´dvi´] = ´application/x-dvi´ + MimeType[´dwg´] = ´image/vnd.dwg´ + MimeType[´dxf´] = ´image/vnd.dxf´ + MimeType[´el´] = ´text/x-emacs-lisp´ + MimeType[´emf´] = ´image/x-emf´ + MimeType[´eps´] = ´application/postscript´ + MimeType[´etheme´] = ´application/x-e-theme´ + MimeType[´etx´] = ´text/x-setext´ + MimeType[´exe´] = ´application/x-ms-dos-executable´ + MimeType[´ez´] = ´application/andrew-inset´ + MimeType[´f´] = ´text/x-fortran´ + MimeType[´fig´] = ´image/x-xfig´ + MimeType[´fits´] = ´image/x-fits´ + MimeType[´flac´] = ´audio/x-flac´ + MimeType[´flc´] = ´video/x-flc´ + MimeType[´fli´] = ´video/x-fli´ + MimeType[´gb´] = ´application/x-gameboy-rom´ + MimeType[´gchempaint´] = ´application/x-gchempaint´ + MimeType[´gcrd´] = ´text/x-vcard´ + MimeType[´gcrystal´] = ´application/x-gcrystal´ + MimeType[´gem´] = ´text/x-rubygem´ + MimeType[´gen´] = ´application/x-genesis-rom´ + MimeType[´gg´] = ´application/x-sms-rom´ + MimeType[´gif´] = ´image/gif´ + MimeType[´glade´] = ´application/x-glade´ + MimeType[´gnc´] = ´application/x-gnucash´ + MimeType[´gnucash´] = ´application/x-gnucash´ + MimeType[´gnumeric´] = ´application/x-gnumeric´ + MimeType[´gray´] = ´image/x-gray´ + MimeType[´gtar´] = ´application/x-gtar´ + MimeType[´gz´] = ´application/x-gzip´ + MimeType[´h´] = ´text/x-c-header´ + MimeType[´h++´] = ´text/x-c-header´ + MimeType[´hdf´] = ´application/x-hdf´ + MimeType[´hlls´] = ´text/x-hllapiscript´ + MimeType[´hpp´] = ´text/x-c-header´ + MimeType[´hs´] = ´text/x-haskell´ + MimeType[´htm´] = ´text/html´ + MimeType[´html´] = ´text/html´ + MimeType[´icb´] = ´image/x-icb´ + MimeType[´ico´] = ´image/x-ico´ + MimeType[´ics´] = ´text/calendar´ + MimeType[´idl´] = ´text/x-idl´ + MimeType[´ief´] = ´image/ief´ + MimeType[´iff´] = ´image/x-iff´ + MimeType[´ilbm´] = ´image/x-ilbm´ + MimeType[´iso´] = ´application/x-iso-image´ + MimeType[´it´] = ´audio/x-it´ + MimeType[´jar´] = ´application/x-java-archive´ + MimeType[´java´] = ´text/x-java´ + MimeType[´jpe´] = ´image/jpeg´ + MimeType[´jpeg´] = ´image/jpeg´ + MimeType[´jpg´] = ´image/jpeg´ + MimeType[´jpr´] = ´application/x-jbuilder-project´ + MimeType[´jpx´] = ´application/x-jbuilder-project´ + MimeType[´js´] = ´text/x-javascript´ + MimeType[´kdelnk´] = ´application/x-kde-app-info´ + MimeType[´kil´] = ´application/x-killustrator´ + MimeType[´kpr´] = ´application/x-kpresenter´ + MimeType[´ksp´] = ´application/x-kspread´ + MimeType[´kwd´] = ´application/x-kword´ + MimeType[´la´] = ´application/x-shared-library-la´ + MimeType[´lha´] = ´application/x-lha´ + MimeType[´lhs´] = ´text/x-literate-haskell´ + MimeType[´lhz´] = ´application/x-lhz´ + MimeType[´lo´] = ´application/x-object-file´ + MimeType[´ltx´] = ´text/x-tex´ + MimeType[´lwo´] = ´image/x-lwo´ + MimeType[´lwob´] = ´image/x-lwo´ + MimeType[´lws´] = ´image/x-lws´ + MimeType[´lyx´] = ´text/x-lyx´ + MimeType[´m´] = ´text/x-objc´ + MimeType[´m3u´] = ´audio/x-mpegurl´ + MimeType[´m4a´] = ´audio/x-m4a´ + MimeType[´man´] = ´text/x-troff-man´ + MimeType[´md´] = ´application/x-genesis-rom´ + MimeType[´me´] = ´text/x-troff-me´ + MimeType[´mgp´] = ´application/x-magicpoint´ + MimeType[´mid´] = ´audio/x-midi´ + MimeType[´midi´] = ´audio/x-midi´ + MimeType[´mif´] = ´application/x-mif´ + MimeType[´miff´] = ´image/x-miff´ + MimeType[´mm´] = ´text/x-troff-mm´ + MimeType[´mml´] = ´text/mathml´ + MimeType[´mod´] = ´audio/x-mod´ + MimeType[´mov´] = ´video/quicktime´ + MimeType[´movie´] = ´video/x-sgi-movie´ + MimeType[´mp1´] = ´audio/mpeg´ + MimeType[´mp2´] = ´video/mpeg´ + MimeType[´mp3´] = ´audio/mpeg´ + MimeType[´mpe´] = ´video/mpeg´ + MimeType[´mpeg´] = ´video/mpeg´ + MimeType[´mpg´] = ´video/mpeg´ + MimeType[´mrp´] = ´application/x-mrproject´ + MimeType[´mrproject´] = ´application/x-mrproject´ + MimeType[´ms´] = ´text/x-troff-ms´ + MimeType[´msx´] = ´application/x-msx-rom´ + MimeType[´n64´] = ´application/x-n64-rom´ + MimeType[´nc´] = ´application/x-netcdf´ + MimeType[´nes´] = ´application/x-nes-rom´ + MimeType[´nsv´] = ´video/x-nsv´ + MimeType[´o´] = ´application/x-object-file´ + MimeType[´oda´] = ´application/oda´ + MimeType[´ogg´] = ´application/ogg´ + MimeType[´oleo´] = ´application/x-oleo´ + MimeType[´p´] = ´text/x-pascal´ + MimeType[´palm´] = ´image/x-palm´ + MimeType[´pas´] = ´text/x-pascal´ + MimeType[´pascal´] = ´text/x-pascal´ + MimeType[´patch´] = ´text/x-patch´ + MimeType[´pbm´] = ´image/x-portable-bitmap´ + MimeType[´pcd´] = ´image/x-photo-cd´ + MimeType[´pcf´] = ´application/x-font-pcf´ + MimeType[´pct´] = ´image/x-pict´ + MimeType[´pcx´] = ´image/x-pcx´ + MimeType[´pdb´] = ´application/x-palm-database´ + MimeType[´pdf´] = ´application/pdf´ + MimeType[´perl´] = ´text/x-perl´ + MimeType[´pfa´] = ´application/x-font-type1´ + MimeType[´pfb´] = ´application/x-font-type1´ + MimeType[´pgm´] = ´image/x-portable-graymap´ + MimeType[´pgn´] = ´application/x-chess-pgn´ + MimeType[´pgp´] = ´application/pgp´ + MimeType[´php´] = ´application/x-php´ + MimeType[´php3´] = ´application/x-php´ + MimeType[´php4´] = ´application/x-php´ + MimeType[´pict´] = ´image/x-pict´ + MimeType[´pl´] = ´text/x-perl´ + MimeType[´pls´] = ´audio/x-scpls´ + MimeType[´pm´] = ´text/x-perl´ + MimeType[´png´] = ´image/png´ + MimeType[´pnm´] = ´image/x-portable-anymap´ + MimeType[´po´] = ´text/x-po´ + MimeType[´pp´] = ´text/x-pascal´ + MimeType[´ppm´] = ´image/x-portable-pixmap´ + MimeType[´pps´] = ´application/vnd.ms-powerpoint´ + MimeType[´ppt´] = ´application/vnd.ms-powerpoint´ + MimeType[´ps´] = ´application/postscript´ + MimeType[´psd´] = ´image/x-psd´ + MimeType[´psf´] = ´application/x-font-linux-psf´ + MimeType[´psid´] = ´audio/prs.sid´ + MimeType[´py´] = ´text/x-python´ + MimeType[´pyc´] = ´application/x-python-byte-code´ + MimeType[´qif´] = ´application/qif´ + MimeType[´qt´] = ´video/quicktime´ + MimeType[´ra´] = ´audio/x-real-audio´ + MimeType[´ram´] = ´audio/x-pn-realaudio´ + MimeType[´rar´] = ´application/x-rar´ + MimeType[´ras´] = ´image/x-cmu-raster´ + MimeType[´rb´] = ´text/x-ruby´ + MimeType[´rba´] = ´text/x-ruby´ + MimeType[´rbw´] = ´text/x-ruby´ + MimeType[´rej´] = ´application/x-reject´ + MimeType[´rgb´] = ´image/x-rgb´ + MimeType[´rm´] = ´audio/x-real-audio´ + MimeType[´roff´] = ´text/x-troff´ + MimeType[´rpm´] = ´application/x-rpm´ + MimeType[´rtf´] = ´application/rtf´ + MimeType[´rtx´] = ´text/richtext´ + MimeType[´ruby´] = ´text/x-ruby´ + MimeType[´rubyw´] = ´text/x-ruby´ + MimeType[´rv´] = ´audio/x-real-audio´ + MimeType[´s´] = ´text/x-asm´ + MimeType[´s3m´] = ´audio/x-s3m´ + MimeType[´scm´] = ´text/x-scheme´ + MimeType[´sda´] = ´application/vnd.stardivision.draw´ + MimeType[´sdc´] = ´application/vnd.stardivision.calc´ + MimeType[´sdd´] = ´application/vnd.stardivision.impress´ + MimeType[´sdp´] = ´application/vnd.stardivision.impress´ + MimeType[´sds´] = ´application/vnd.stardivision.chart´ + MimeType[´sdw´] = ´application/vnd.stardivision.writer´ + MimeType[´sgi´] = ´image/x-sgi´ + MimeType[´sgl´] = ´application/vnd.stardivision.writer´ + MimeType[´sgm´] = ´text/sgml´ + MimeType[´sgml´] = ´text/sgml´ + MimeType[´sh´] = ´text/x-sh´ + MimeType[´shar´] = ´application/x-shar´ + MimeType[´sid´] = ´audio/prs.sid´ + MimeType[´slk´] = ´text/spreadsheet´ + MimeType[´smd´] = ´application/vnd.stardivision.mail´ + MimeType[´smf´] = ´application/vnd.stardivision.math´ + MimeType[´smi´] = ´application/x-smil´ + MimeType[´smil´] = ´application/x-smil´ + MimeType[´sml´] = ´application/x-smil´ + MimeType[´sms´] = ´application/x-sms-rom´ + MimeType[´snd´] = ´audio/basic´ + MimeType[´so´] = ´application/x-shared-library´ + MimeType[´spd´] = ´application/x-font-speedo´ + MimeType[´sql´] = ´text/x-sql´ + MimeType[´src´] = ´application/x-wais-source´ + MimeType[´stc´] = ´application/vnd.sun.xml.calc.template´ + MimeType[´std´] = ´application/vnd.sun.xml.draw.template´ + MimeType[´sti´] = ´application/vnd.sun.xml.impress.template´ + MimeType[´stm´] = ´audio/x-stm´ + MimeType[´stw´] = ´application/vnd.sun.xml.writer.template´ + MimeType[´sty´] = ´text/x-tex´ + MimeType[´sun´] = ´image/x-sun-raster´ + MimeType[´sv4cpio´] = ´application/x-sv4cpio´ + MimeType[´sv4crc´] = ´application/x-sv4crc´ + MimeType[´svg´] = ´image/svg+xml´ + MimeType[´svgz´] = ´image/svg+xml´ + MimeType[´swf´] = ´application/x-shockwave-flash´ + MimeType[´sxc´] = ´application/vnd.sun.xml.calc´ + MimeType[´sxd´] = ´application/vnd.sun.xml.draw´ + MimeType[´sxg´] = ´application/vnd.sun.xml.writer.global´ + MimeType[´sxi´] = ´application/vnd.sun.xml.impress´ + MimeType[´sxm´] = ´application/vnd.sun.xml.math´ + MimeType[´sxw´] = ´application/vnd.sun.xml.writer´ + MimeType[´sylk´] = ´text/spreadsheet´ + MimeType[´t´] = ´text/x-troff´ + MimeType[´tar´] = ´application/x-tar´ + MimeType[´tcl´] = ´text/x-tcl´ + MimeType[´tex´] = ´text/x-tex´ + MimeType[´texi´] = ´text/x-texinfo´ + MimeType[´texinfo´] = ´text/x-texinfo´ + MimeType[´tga´] = ´image/x-tga´ + MimeType[´tgz´] = ´application/x-compressed-tar´ + MimeType[´theme´] = ´application/x-theme´ + MimeType[´tif´] = ´image/tiff´ + MimeType[´tiff´] = ´image/tiff´ + MimeType[´torrent´] = ´application/x-bittorrent´ + MimeType[´tr´] = ´text/x-troff´ + MimeType[´tsv´] = ´text/tab-separated-values´ + MimeType[´ttc´] = ´application/x-font-ttf´ + MimeType[´ttf´] = ´application/x-font-ttf´ + MimeType[´txt´] = ´text/plain´ + MimeType[´ustar´] = ´application/x-ustar´ + MimeType[´vcf´] = ´text/x-vcalendar´ + MimeType[´vcs´] = ´text/x-vcalendar´ + MimeType[´vi´] = ´text/x-vi´ + MimeType[´vim´] = ´text/x-vi´ + MimeType[´viv´] = ´video/vnd.vivo´ + MimeType[´vivo´] = ´video/vnd.vivo´ + MimeType[´vob´] = ´video/mpeg´ + MimeType[´voc´] = ´audio/x-voc´ + MimeType[´vor´] = ´application/vnd.stardivision.writer´ + MimeType[´wav´] = ´audio/x-wav´ + MimeType[´wax´] = ´audio/x-ms-asx´ + MimeType[´wk1´] = ´application/vnd.lotus-1-2-3´ + MimeType[´wk3´] = ´application/vnd.lotus-1-2-3´ + MimeType[´wk4´] = ´application/vnd.lotus-1-2-3´ + MimeType[´wks´] = ´application/vnd.lotus-1-2-3´ + MimeType[´wmf´] = ´image/x-wmf´ + MimeType[´wmv´] = ´video/x-ms-wmv´ + MimeType[´wrl´] = ´model/vrml´ + MimeType[´wvx´] = ´video/x-ms-wvx´ + MimeType[´xac´] = ´application/x-gnucash´ + MimeType[´xbel´] = ´application/xbel´ + MimeType[´xbm´] = ´image/x-xbitmap´ + MimeType[´xcf´] = ´image/x-xcf´ + MimeType[´xi´] = ´audio/x-xi´ + MimeType[´xla´] = ´application/vnd.ms-excel´ + MimeType[´xlc´] = ´application/vnd.ms-excel´ + MimeType[´xld´] = ´application/vnd.ms-excel´ + MimeType[´xls´] = ´application/vnd.ms-excel´ + MimeType[´xlt´] = ´application/vnd.ms-excel´ + MimeType[´xm´] = ´audio/x-xm´ + MimeType[´xml´] = ´text/xml´ + MimeType[´xpm´] = ´image/x-xpixmap´ + MimeType[´xwd´] = ´image/x-xwindowdump´ + MimeType[´y´] = ´text/x-yacc´ + MimeType[´yacc´] = ´text/x-yacc´ + MimeType[´z´] = ´application/x-compress´ + MimeType[´zip´] = ´application/zip´ + MimeType[´zoo´] = ´application/x-zoo´ +end diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/net.lib.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/net.lib.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/net.lib.rb 2004-12-17 12:40:15.000000000 +0100 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/net.lib.rb 2005-06-04 14:41:52.000000000 +0200 @@ -1,5 +1,6 @@ require "ev/ruby" require "ev/ftools" +require "ev/mime" require "net/http" require "socket" require "uri" @@ -13,11 +14,11 @@ if File.file?(file) Hash.file(file).each do |k, v| eval "$#{k} = ´#{v}´" unless k=~ /^\#/ - #$proxy_auth = [$proxy_auth].pack("m").chomp if k == "proxy_auth" end end def uri2txt(s) + # ??? Werkt niet goed i = s.index(/%[[:digit:]]{2}/) while not i.nil? s = s[0..(i-1)] + s[(i+1)..(i+2)].unpack(´H2´).shift.to_i.chr + s[(i+3)..-1] @@ -147,6 +148,8 @@ rescue end + @path = "/" if (not @path.nil? and @path.empty? and @protocol == "http") + @protocol = "" if @protocol.nil? @userpass = "" if @userpass.nil? @host = "" if @host.nil? @@ -163,7 +166,7 @@ @port = @port.to_i end - def + (url2) + def +(url2) url1 = self.to_s url2 = url2.to_s if url2.kind_of?(self.class) @@ -174,7 +177,7 @@ protocol = @protocol userpass = @userpass host = @host - port = @port.to_s + port = @port path = @path vars = varstring anchor = @anchor @@ -196,6 +199,33 @@ return res end + def localname + protocol = @protocol + userpass = @userpass + host = @host + port = @port + path = @path + vars = varstring + anchor = @anchor + + protocol = nil if @protocol.empty? + userpass = nil if @userpass.empty? + host = nil if @host.empty? + port = nil if @port.zero? + path = nil if @path.empty? + vars = nil if @vars.empty? + anchor = nil if @anchor.empty? + + path = "#{path}." if path =~ /[\/\\]$/ + + f = MD5.new(protocol.to_s + userpass.to_s + host.to_s + port.to_s + File.dirname(path.to_s) + vars.to_s).to_s + e = File.basename(path.to_s).gsub(/[^\w\.\-]/, "_").gsub(/_+/, "_") + res = f + "." + e + res.gsub!(/[^\w]+$/, "") + + return res + end + def varstring res = [] vars = @vars.dup @@ -281,36 +311,52 @@ end end + class NoAddressException < StandardError + end + + def self.getaddress(host) + if not @@hosts.include?(host) + @@hosts[host] = "" + evtimeout(5) do # ??? Doet ´ut niet?... + @@hosts[host] = IPSocket.getaddress(host) + end + end + + raise NoAddressException, host if @@hosts[host].empty? + + @@hosts[host] + end + def self.head(uri, form={}, recursive=true) header = Header.new(nil) begin while not uri.nil? - if $proxy.nil? or $proxy.empty? - uri = EVURI.new(uri) if uri.kind_of? String - host = uri.host - port = uri.port + uri = EVURI.new(uri) if uri.kind_of? String + host = uri.host + port = uri.port + + if $proxy.nil? or $proxy.empty? or host == "localhost" io = nil @@mutex.synchronize do - @@hosts[host] = IPSocket.getaddress(host) if not @@hosts.include?(host) - io = TCPSocket.new(@@hosts[host], port.zero? ? 80 : port) + io = TCPSocket.new(getaddress(host), port.zero? ? 80 : port) end io.write("HEAD #{uri.path or ´/´}#{uri.varstring.empty? ? ´´ : ´?´ + uri.varstring} HTTP/1.0\r\nHost: #{host}\r\n\r\n") else proxy = EVURI.new($proxy) - host = proxy.host - port = proxy.port - - io = TCPSocket.new(host, port.zero? ? 8080 : port) + io = TCPSocket.new(proxy.host, proxy.port.zero? ? 8080 : proxy.port) io.write("HEAD #{uri} HTTP/1.0\r\n#{"Proxy-Authorization: Basic "+$proxy_auth+"\r\n" if not $proxy_auth.nil?}\r\n\r\n") end io.close_write - res = io.read + res = io.read + + io.close_read + header, data = nil, nil header, data = res.split(/\r*\n\r*\n/, 2) if not res.nil? header = Header.new(header) @@ -321,14 +367,23 @@ uri = nil end end - rescue + rescue Errno::ECONNRESET, Errno::EHOSTUNREACH => e + $stderr.puts e.message + sleep 1 + retry + rescue Errno::ECONNREFUSED => e + data = nil + rescue NoAddressException => e + $stderr.puts e.message header = Header.new(nil) end + GC.start + return header end - def self.get(uri, form={}) + def self.get(uri, httpheader={}, form={}) post = Array.new form.each_pair do |var, value| post << "#{var.to_html}=#{value.to_html}" @@ -339,15 +394,14 @@ begin while not uri.nil? - if $proxy.nil? or $proxy.empty? - uri = EVURI.new(uri) if uri.kind_of? String - host = uri.host - port = uri.port + uri = EVURI.new(uri) if uri.kind_of? String + host = uri.host + port = uri.port + if $proxy.nil? or $proxy.empty? or host == "localhost" io = nil @@mutex.synchronize do - @@hosts[host] = IPSocket.getaddress(host) if not @@hosts.include?(host) - io = TCPSocket.new(@@hosts[host], port.zero? ? 80 : port) + io = TCPSocket.new(getaddress(host), port.zero? ? 80 : port) end if post.empty? @@ -357,10 +411,7 @@ end else proxy = EVURI.new($proxy) - host = proxy.host - port = proxy.port - - io = TCPSocket.new(host, port.zero? ? 8080 : port) + io = TCPSocket.new(proxy.host, proxy.port.zero? ? 8080 : proxy.port) if post.empty? io.write "GET %s HTTP/1.0\r\n" % uri @@ -370,22 +421,32 @@ end io.write "Host: %s\r\n" % host - io.write "User-Agent: evwget\r\n" - io.write "Proxy-Authorization: Basic %s\r\n" % $proxy_auth unless $proxy_auth.nil? + io.write "User-Agent: xyz\r\n" + io.write "Proxy-Authorization: Basic %s\r\n" % $proxy_auth unless $proxy_auth.nil? #io.write "Accept-Encoding: deflate\r\n" - #io.write "Connection: close\r\n" + #io.write "Accept-Charset: ISO-8859-1\r\n" + io.write "Connection: close\r\n" io.write "Content-Type: application/x-www-form-urlencoded\r\n" unless post.empty? io.write "Content-Length: %s\r\n" % post.length unless post.empty? + httpheader.each do |k, v| + $stderr.puts "%s: %s\r\n" % [k, v] + io.write "%s: %s\r\n" % [k, v] + end io.write "\r\n" io.write post unless post.empty? io.close_write res = io.read + + io.close_read + header, data = nil, nil header, data = res.split(/\r*\n\r*\n/, 2) if not res.nil? header = Header.new(header) + length = header.header["content-length"] + data = "" if length == "0" if header.header["location"] != uri.to_s uri = EVURI.new(uri) + header.header["location"] @@ -397,12 +458,25 @@ data = Chunk.new(data).to_s if not data.nil? end + #if header.header["content-encoding"] == "gzip" + #data = "gzip -d".exec(data) if not data.nil? + #end + data = nil unless header.code == 200 end - rescue + rescue Errno::ECONNRESET, Errno::EHOSTUNREACH => e + $stderr.puts e.message + sleep 1 + retry + rescue Errno::ECONNREFUSED => e + data = nil + rescue NoAddressException, Errno::ECONNREFUSED => e + $stderr.puts e.message data = nil end + GC.start + return data end @@ -422,7 +496,7 @@ file = "#{dir}/#{hash}" data = nil - Dir.mkdirrec(dir) + File.mkpath(dir) expire = 356*24*60*60 @@ -447,7 +521,7 @@ class RequestGet < Hash def initialize(data) CGI.parse(data).each do |k, v| - self[k] = v.join(" ") + self[k] = v end end end @@ -455,7 +529,7 @@ class RequestPost < Hash def initialize(data) CGI.parse(data).each do |k, v| - self[k] = v.join(" ") + self[k] = v end end end @@ -493,6 +567,8 @@ attr_reader :request attr_reader :cookies attr_reader :vars + attr_reader :user + attr_writer :user def initialize(io) @io = io @@ -562,6 +638,7 @@ class Response < Hash attr_writer :response + attr_writer :file attr_reader :cookies attr_reader :stop attr_reader :at_stop @@ -574,10 +651,20 @@ @syncd = false @stop = false @at_stop = lambda{} + @file = nil end def flush sync + + if @file + File.open(@file, "rb") do |f| + while data = f.read(10_000) + @io.write data + end + end + end + @io.close end @@ -595,6 +682,21 @@ end def sync + size = (@data or "").length + + if @file + ext = @file.scan(/\.[^\.]*$/) + ext = ext.shift + ext = ext[1..-1] unless ext.nil? + mimetype = EVMime::MimeType[ext] + + self["Content-Type"] = mimetype unless mimetype.nil? + + size += File.size(@file) if File.file?(@file) + end + + self["Content-Length"] = size + @io.write("#{to_s}\r\n") unless @syncd @io.write(@data) @data = "" @@ -605,6 +707,10 @@ @data << s end + def clean + @data = "" + end + def inspect "(Response: %s)" % [@response, @data].join(", ") end @@ -640,7 +746,7 @@ count = 0 at_exit do - $stderr.puts "Received #{count} requests" + #$stderr.puts "Received #{count} requests" end serverthread = @@ -678,7 +784,7 @@ end if (not remote) or (remote and (auth.nil? or auth.empty? or authenticate(auth, realm, req, resp))) - $stderr.puts "#{count2}, #{Time.new.strftime("%Y-%m-%d.%H:%M:%S")}, #{ip}, #{req.request.to_s.strip}" + $stderr.puts "#{count2} #{Time.new.strftime("%Y-%m-%d %H:%M:%S")} #{ip} #{req.user} #{req.request.to_s.strip}" begin yield(req, resp) @@ -687,6 +793,16 @@ $stderr.puts e.class.to_s + ": " + e.message $stderr.puts e.backtrace.collect{|s| "\t"+s}.join("\n") end + resp["Content-Type"] = "text/plain" + resp.response = "HTTP/1.0 200 ???" + resp.clean + resp << e.class.to_s + ": " + e.message + resp << "\n" + resp << "\n" + resp << e.backtrace.collect{|s| "\t"+s}.join("\n") + resp << "\n" + resp << "\n" + resp << "(You can use the back button and stop the application properly, if appropriate.)" end stop = true if resp.stop? @@ -738,13 +854,13 @@ ok = (auths.include?(u) and auths[u] == p) - if ok - - else + unless ok resp["WWW-Authenticate"] = "Basic realm=\"#{realm}\"" resp.response = "HTTP/1.0 401 Unauthorized" end + req.user = u + return ok end end diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/ruby.lib.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/ruby.lib.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2004-12-17 12:40:15.000000000 +0100 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/ruby.lib.rb 2005-06-04 14:41:52.000000000 +0200 @@ -18,14 +18,16 @@ tekens31 = ´\w\s\r\n´ -RegExpStringWord = "([#{tekens11}]+)" ; RegExpWord = Regexp.new(RegExpStringWord) -RegExpStringWord2 = "([#{tekens21}]([#{tekens22}]*[#{tekens23}])?)" ; RegExpWord2 = Regexp.new(RegExpStringWord2) -RegExpStringText = "([#{tekens31}]+)" ; RegExpText = Regexp.new(RegExpStringText) -RegExpStringFile = ´(\w[\w\.\-]*)´ ; RegExpFile = Regexp.new(RegExpStringFile) -RegExpStringEmail = ´([\w\-\.]+@[\w\-\.]+)´ ; RegExpEmail = Regexp.new(RegExpStringEmail) -RegExpStringURL = ´(\w+:\/\/[\w\.\-]+(:\d*)?\/[\w\.\-\/\#\?\=\%]*)´ ; RegExpURL = Regexp.new(RegExpStringURL) -RegExpStringPrint = ´([\w \t\r\n\`\~\!\@\#\$\%\^\&\*\(\)\-\+\=\[\]\{\}\;\:\´\"\,\.\/\<\>\?\\\|]+)´ ; RegExpPrint = Regexp.new(RegExpStringPrint) -RegExpStringDiff = ´(^[\-\+]([^\-\+].*)?)´ ; RegExpDiff = Regexp.new(RegExpStringDiff) +RegExpStringWord = "([#{tekens11}]+)" ; RegExpWord = Regexp.new(RegExpStringWord) +RegExpStringWord2 = "([#{tekens21}]([#{tekens22}]*[#{tekens23}])?)" ; RegExpWord2 = Regexp.new(RegExpStringWord2) +RegExpStringText = "([#{tekens31}]+)" ; RegExpText = Regexp.new(RegExpStringText) +RegExpStringFile = ´(\w[\w\.\-]*)´ ; RegExpFile = Regexp.new(RegExpStringFile) +RegExpStringEmail = ´([\w\-\.]+@[\w\-\.]+)´ ; RegExpEmail = Regexp.new(RegExpStringEmail) +RegExpStringURL = ´(\w+:\/\/[\w\.\-]+(:\d*)?\/[\w\.\-\/\#\?\=\%]*)´ ; RegExpURL = Regexp.new(RegExpStringURL) +RegExpStringPrint = ´([\w \t\r\n\`\~\!\@\#\$\%\^\&\*\(\)\-\+\=\[\]\{\}\;\:\´\"\,\.\/\<\>\?\\\|]+)´ ; RegExpPrint = Regexp.new(RegExpStringPrint) +RegExpStringDiff = ´(^[\-\+]([^\-\+].*)?)´ ; RegExpDiff = Regexp.new(RegExpStringDiff) +RegExpStringHTHLink = ´(`[\w\,]*\ba\b[^`]*`)´ ; RegExpHTHLink = Regexp.new(RegExpStringHTHLink) +RegExpStringHTHSpecial = ´(`[^`]*`)´ ; RegExpHTHSpecial = Regexp.new(RegExpStringHTHSpecial) module Enumerable def deep_dup @@ -64,6 +66,10 @@ def to_fs to_f end + + def to_html(eolconversion=true) + self.to_s.to_html(eolconversion) + end end class Integer @@ -211,8 +217,8 @@ end def splitwords(tokens=[]) - tokens = [tokens] unless tokens.kind_of?(Array) - res = [] + tokens = [tokens] unless tokens.kind_of?(Array) + res = [] self.splitblocks(["´", "´"], [´"´, ´"´]).each do |type, s| case type @@ -437,13 +443,14 @@ end def format(format) + format = format.gsub(/\s/, "") res = [] [format.length, self.length].min.times do |n| - case format[n].chr - when "i" then res << self[n].to_i - when "s" then res << self[n].to_s - when "x" then res << self[n] + case format[n].chr.downcase + when "i" then res << self[n].to_i + when "s" then res << self[n].to_s + else res << self[n] end end @@ -540,6 +547,36 @@ def ids collect{|e| e.ids} end + + def rotate + raise "Array has to be 2D (An Array of Arrays)." unless self.dup.delete_if{|a| a.kind_of?(Array)}.empty? + + res = [] + + self[0].length.times do |x| + a = [] + + self.length.times do |y| + a << self[y][x] + end + + res << a + end + + res + end + + def to_h + raise "Array has to be 2D (An Array of Arrays)." unless self.dup.delete_if{|a| a.kind_of?(Array)}.empty? + + res = {} + + self.each do |k, v, *rest| + res[k] = v + end + + res + end end class Hash @@ -699,7 +736,11 @@ end def linux? - not windows? and not cygwin? + not (target_os.downcase =~ /linux/).nil? +end + +def darwin? + not (target_os.downcase =~ /darwin/).nil? end def windows? @@ -727,8 +768,9 @@ end def stdtmp - $stderr = $stdout = File.new("#{temp}/ruby.#{Process.pid}.log", "a") unless ARGV.include?("--rwd-exit") + $stderr = $stdout = File.new("#{temp}/ruby.#{Process.pid}.log", "a") end +stdtmp if defined?(RUBYSCRIPT2EXE) and (RUBYSCRIPT2EXE =~ /rubyw/i) $nobm = false @@ -745,7 +787,7 @@ end end - label = label.to_s + label = label.inspect #unless label.kind_of?(String) res = nil $bm_mutex = ($bm_mutex or Mutex.new) @@ -757,29 +799,41 @@ $bm = {} at_exit do - format1 = "%10s %10s %10s %10s %10s %10s %10s" - format2 = "%10s %10.6f %10.6f %10.6f %10.6f %10.6f %10d" - - $stderr.puts format1 % ["LABEL", "USERCPU", "SYSCPU", "CUSERCPU", "CSYSCPU", "ELAPSED", "TIMES"] - $bm.sort{|a, b| [a[1], a[0]] <=> [b[1], b[0]]}.each do |k, v| - $stderr.puts format2 % [k, *v] + l = $bm.keys.collect{|s| s.length}.max + #format1 = "%10s %10s %10s %10s %10s %10s %s" + #format2 = "%10.6f %10.6f %10.6f %10.6f %10.6f %10d %s" + #$stderr.puts format1 % ["USERCPU", "SYSCPU", "CUSERCPU", "CSYSCPU", "ELAPSED", "COUNT", "LABEL"] + #$bm.sort{|a, b| [b[1], b[0]] <=> [a[1], a[0]]}.each do |k, v| + #$stderr.puts format2 % (v + [k]) + #end + + format1 = "%10s %10s %10s %s" + format2 = "%10.6f %10.6f %10d %s" + $bm.each do |k, v| + $bm[k] = [v[0]+v[1], v[4], v[5]] + end + $stderr.puts format1 % ["CPU", "ELAPSED", "COUNT", "LABEL"] + $bm.sort{|a, b| [b[1], b[0]] <=> [a[1], a[0]]}.each do |k, v| + $stderr.puts format2 % (v + [k]) end end end $bm[label] = [0.0]*5 + [0] unless $bm.include?(label) + $bm[label][5] += 1 end if block_given? bm = Benchmark.measure{res = yield} bma = bm.to_a # [dummy label, user CPU time, system CPU time, childrens user CPU time, childrens system CPU time, elapsed real time] + $bm_last = bma + $bm_mutex.synchronize do + e = $bm[label] 0.upto(4) do |n| - $bm[label][n] += bma[n+1] + e[n] += bma[n+1] end - - $bm[label][5] += 1 end end @@ -817,3 +871,19 @@ res end end + +def ask(options, text=false) + i = 0 + $stderr.puts "" + options.each do |s| + $stderr.puts " %d %s" % [i+=1, s] + end + $stderr.puts "" + $stderr.print "? " + res = $stdin.gets + unless res.nil? + res = res.strip + res = options[res.to_i-1] if text and not res.empty? + end + res +end diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/rwd.lib.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/rwd.lib.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2004-12-17 12:40:15.000000000 +0100 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/rwd.lib.rb 2005-06-04 14:41:52.000000000 +0200 @@ -15,6 +15,7 @@ end $rwd_exit = ARGV.include?("--rwd-exit") # Hack ??? +$rwd_exit = true if defined?(REQUIRE2LIB) $rwd_debug = ($rwd_debug or $DEBUG or false) $rwd_border = ($rwd_border or 0) $rwd_dir = Dir.pwd @@ -27,10 +28,12 @@ RWDEmptyline = "..." +#module RWD + rcfile = nil -s = ENV["HOME"] ; s = s + "/.rwdrc" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and File.file?(s)) -s = ENV["USERPROFILE"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and File.file?(s)) -s = ENV["windir"] ; s = s + "/rwd.cfg" if not s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and File.file?(s)) +s = ENV["HOME"] ; s = File.expand_path(".rwdrc", s) unless s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and File.file?(s)) +s = ENV["USERPROFILE"] ; s = File.expand_path("rwd.cfg", s) unless s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and File.file?(s)) +s = ENV["windir"] ; s = File.expand_path("rwd.cfg", s) unless s.nil? ; rcfile = s if (not s.nil? and rcfile.nil? and File.file?(s)) AL = "align=´left´" AC = "align=´center´" @@ -51,7 +54,7 @@ ENV["RWDPORTS"] = (ENV["RWDPORTS"] or "7701-7709") ENV["RWDTHEME"] = (ENV["RWDTHEME"] or "DEFAULT") -trap("INT") {puts "Terminating..." ; exit} +#trap("INT") {puts "Terminating..." ; exit} $SAFE = 2 @@ -93,7 +96,7 @@ a = [emptyline].concat(self) end - a.numsort.collect{|s| "<option>#{s.to_html}</option>" }.join("\n") + a.numsort.collect{|s| "<option>#{s.to_s.to_html}</option>" }.join("\n") end def rwd_method(method) @@ -109,17 +112,32 @@ return res end - def rwd_row(key=nil, value=nil) + def rwd_row(key=nil, value=nil, bold=false) res = "" res = res + "<row valign=´top´>" res = res + "<radio name=´#{key.to_html}´ value=´#{value.to_html}´/>" unless key.nil? - res = res + self.collect{|s| "<p align=´left´>#{s.to_html}</p>"}.join("") + res = res + self.collect{|s| "<p align=´#{(s.kind_of?(Numeric) or s =~ /^\d+\.\d+$/) ? "right" : "left"}´>#{"<b>" if bold}#{s.to_s.to_html}#{"</b>" if bold}</p>"}.join("") res = res + "</row>" return res end + def rwd_table(headers=nil, highlightrows=[]) + res = "" + + highlightrows = [highlightrows].flatten + + n = -1 + + res = res + "<table>" + res = res + headers.rwd_row(nil, nil, true) unless headers.nil? + res = res + self.collect{|a| a.rwd_row(nil, nil, highlightrows.include?(n+=1))}.join("") + res = res + "</table>" + + return res + end + def rwd_headers(emptyfield=false) res = "" @@ -131,7 +149,7 @@ return res end - def rwd_form(prefix, values, twoparts=0, options={}) + def rwd_form(prefix, values=[], twoparts=0, options={}) res = [] res << "<table>" @@ -151,7 +169,7 @@ s = "" s << "<text name=´#{name}´" - s << " value=´#{values[n].to_html}´" if n < values.length + s << " value=´#{values[n].to_s.to_html}´" if n < values.length s << "/>" res << s @@ -266,7 +284,7 @@ template = $rwd_html_1 template = $rwd_html_PDA_1 if pda - res <<(template(template, args)) + res << (template(template, args)) when "p" then res << "<p #{align}>" when "pre" then res << "<pre #{align}>" when "big" then res << "<p #{align}><big>" @@ -310,6 +328,7 @@ maxlength = "" maxlength = "maxlength=´%s´" % @args["maxlength"] if @args.include?("maxlength") size = "" + size = "size=´%s´" % @args["size"] if @args.include?("size") size = "size=´%s´" % 10 if pda res << "<p #{align}><input name=´#{@args["name"]}´ value=´#{value1}´ type=´text´ #{maxlength} #{size}>" oneormorefields << "true" @@ -340,7 +359,7 @@ end oneormorefields << "true" when "select" - res << "<select #{align} name=´#{@args["name"]}´ width=´#{@args["width"]}´>" + res << "<select #{align} name=´#{@args["name"]}´ width=´#{@args["width"]} size=´#{@args["size"]}´>" # ??? Misschien nog iets met ´multiple´? name = @args["name"] $select = varshtml[name] oneormorefields << "true" @@ -480,7 +499,7 @@ template = $rwd_html_2 template = $rwd_html_PDA_2 if pda - res <<(template(template, args)) + res << (template(template, args)) when "p" then res << "</p>" when "pre" then res << "</pre>" when "big" then res << "</big></p>" @@ -555,10 +574,15 @@ end logo = nil - logo = File.expand_path(vars["logo"], $rwd_files) if vars.include?("logo") - logo = nil unless logo.nil? or File.file?(logo) + logo = File.expand_path(vars["logo"], $rwd_files) if vars.include?("logo") + logo = nil unless logo.nil? or File.file?(logo) + + watermark = nil + watermark = File.expand_path(vars["watermark"], $rwd_files) if vars.include?("watermark") + watermark = nil unless watermark.nil? or File.file?(watermark) a["LOGO"] = "" unless not logo.nil? + a["WATERMARK"] = "" unless not watermark.nil? a["HELPBUTTON"] = (not (vars["nohelpbutton"])) a["BACKBUTTONS"] = (not (vars["nobackbuttons"])) @@ -619,10 +643,12 @@ tree = XML.new(rwd) tree.parse(OpenTag, "window") do |type, obj| + $rwd_appvars.each{|k, v| obj.args[k] = v} @@windows[rwd][obj.args["name"]] = obj.to_h end tree.parse(OpenTag, "helpwindow") do |type, obj| + $rwd_appvars.each{|k, v| obj.args[k] = v} @@helpwindows[rwd][obj.args["name"]] = obj.to_h end end @@ -638,6 +664,8 @@ firstaction = "" html = [] + vars = vars.deep_dup + vars.each do |key, value| if not key.empty? if value.respond_to? "to_s" @@ -730,7 +758,7 @@ class RWDDone < RWDWindow def initialize(exitbrowser) - super("<window title=´RWD Message´ nobackbuttons noclosebutton><p>Done.</p><horizontal><close/>#{exitbrowser ? "" : "<button caption=´Again´/>"}</horizontal>#{exitbrowser ? "<closewindow/>" : ""}</window>") + super("<window title=´RWD Message´ nobackbuttons noclosebutton><p>Done.</p><i>(Some browsers don´t close,<br>because of security reasons.)</i><horizontal><close/>#{exitbrowser ? "" : "<button caption=´Again´/>"}</horizontal>#{exitbrowser ? "<closewindow/>" : ""}</window>") end end @@ -741,6 +769,14 @@ @rwd_history = [] @rwd_ignore_vars = [] @rwd_call_after_back = [] + @rwd_time = Time.now + + $rwd_appvars = {} if $rwd_appvars.nil? + XML.new(xml).parse(OpenTag, "application") do |type, obj| + obj.args.deep_dup.each do |k, v| + $rwd_appvars[k] = v + end + end end def self.file(rwdfile, *args) @@ -764,9 +800,14 @@ port = port.to_i @rwd_server = RWDServer.new(self, port, io, auth, realm) + + self end def render(res, path, post, download, downloadfile, pda, sessionid) + # Avoid a timeout. + + @rwd_time = Time.now # Initialize some vars. @@ -777,7 +818,7 @@ help = false back = false tab = "" - @rwd_msgtype = nil + @rwd_msgtype = nil if @rwd_progress_thread.nil? @rwd_download = nil @rwd_download_file = nil @@ -818,6 +859,8 @@ @rwd_action = "rwd_back" end + @rwd_history = [["main", [], "main", ""]] if @rwd_history.empty? + if @rwd_action =~ /^rwd_tab_/ @rwd_tab = @rwd_action.sub(/^rwd_tab_/, "") @rwd_history[-1][3] = @rwd_tab @@ -839,6 +882,7 @@ @rwd_history = [] when "rwd_quit" done = true + else end # History stuff @@ -882,6 +926,15 @@ a = [@rwd_action, @rwd_args, @rwd_window, @rwd_tab] @rwd_history.push a if (@rwd_history[-1] != a or not @rwd_msgtype.nil?) + + if @rwd_window == "rwd_back" + @rwd_history.pop + @rwd_history.pop + @rwd_action = (@rwd_history[-1] or [nil, nil, nil])[0] + @rwd_args = (@rwd_history[-1] or [nil, nil, nil])[1] + @rwd_window = (@rwd_history[-1] or [nil, nil, nil])[2] + @rwd_tab = (@rwd_history[-1] or [nil, nil, nil])[3] + end end end @@ -910,12 +963,13 @@ download << @rwd_download downloadfile << @rwd_download_file else - if not @rwd_msgtype.nil? - res << RWDMessage.new(@rwd_msg).render(pda) if @rwd_msgtype == "message" - res << RWDError.new(@rwd_msg).render(pda) if @rwd_msgtype == "error" + if not @rwd_progress_thread.nil? + res << RWDProgressBar.new(@rwd_progress_refresh, @rwd_progress_progress).render(pda, @rwd_refresh_action) else - if not @rwd_progress_thread.nil? - res << RWDProgressBar.new(@rwd_progress_refresh, @rwd_progress_progress).render(pda, @rwd_refresh_action) + if not @rwd_msgtype.nil? + res << RWDMessage.new(@rwd_msg).render(pda) if @rwd_msgtype == "message" + res << RWDError.new(@rwd_msg).render(pda) if @rwd_msgtype == "error" + res << @rwd_msg if @rwd_msgtype == "text" else puts "Window: #{@rwd_window}" if $rwd_debug puts "Tab: #{@rwd_tab}" if $rwd_debug @@ -943,6 +997,11 @@ @rwd_msgtype = "error" end + def text(msg) + @rwd_msg = "<html><body><pre>#{msg}</pre></body></html>" + @rwd_msgtype = "text" + end + def progressbar(refresh, *progress) @rwd_progress_refresh = (refresh or 1) @rwd_progress_progress = [] @@ -983,6 +1042,23 @@ def exitbrowser @rwd_exitbrowser = true end + + def timeout(timeout, interval=1) + @rwd_timeout = timeout + + unless @rwd_timeout_thread + @rwd_timeout_thread = + Thread.new do + loop do + if Time.now - @rwd_time > @rwd_timeout + $stderr.puts "Exiting due to timeout (#{@rwd_timeout} seconds)." + exit 1 + end + sleep interval + end + end + end + end end class RWDLogin < RWDialog @@ -1039,7 +1115,7 @@ end end -class Session < Hash +class RWDSession < Hash attr_reader :sessionid attr_reader :lastaccess attr_reader :authenticated @@ -1054,9 +1130,7 @@ def touch @lastaccess = Time.now end -end -class RWDSession < Session def render(res, path, post, download, downloadfile, pda) done = self["object"].render(res, path, post, download, downloadfile, pda, @sessionid) @@ -1092,18 +1166,13 @@ browser = ENV["RWDBROWSER"].dup url = "http://localhost:%s/" % [port] - if cygwin? - browser.gsub!(/\\/, "/") - browser.gsub!(/ /, "\\ ") - end - re = /[$%]1\b/ command = "%s \"%s\"" % [browser, url] command = browser.gsub(re, url) if browser =~ re command.gsub!(/%port%/, port.to_s) - system(command) or puts "Starting of the browser failed, or the browser terminated abnormally.\nCommand => #{command}" + system(command) or $stderr.puts "Starting of the browser failed, or the browser terminated abnormally.\nCommand => #{command}" #end puts "The browser has terminated." @@ -1119,8 +1188,10 @@ HTTPServer.serve(portio, (not auth.nil?)) do |req, resp| threadlimiter.wait do - - vars = req.vars.dup + vars = {} + req.vars.each do |k, v| + vars[k] = v.join("\t") + end pad = (req.request.path or "/") if auth.kind_of? String @@ -1151,7 +1222,7 @@ end if oldsessionid.nil? or oldsessionid.empty? - if not auth.nil? and not auth.empty? and not session.authenticated and pad != "/rwd_pixel.gif" + if not auth.nil? and not auth.empty? and not session.authenticated and pad !~ /^\/rwd_/ # Check authentication @@ -1289,6 +1360,10 @@ <style type=´text/css´> <!-- + body { + background : url(%WATERMARK%) white center center no-repeat fixed; + } + a { text-decoration : none; } @@ -1379,22 +1454,22 @@ <table align=´center´ border=´0´ cellspacing=´0´ cellpadding=´0´> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> @@ -1402,12 +1477,12 @@ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> @@ -1417,11 +1492,11 @@ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> @@ -1431,7 +1506,7 @@ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> @@ -1520,7 +1595,7 @@ </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> @@ -1530,11 +1605,11 @@ <td align=´center´ bgcolor=´#EEEEEE´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> @@ -1544,12 +1619,12 @@ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> @@ -1557,22 +1632,22 @@ <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> <tr align=´center´> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> <td align=´center´ bgcolor=´black´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> - <td align=´center´ bgcolor=´white´><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> + <td align=´center´ ><img src=´rwd_pixel.gif´ height=´1´ width=´1´></td> </tr> </table> @@ -1601,6 +1676,10 @@ <style type=´text/css´> <!-- + body { + background : url(%WATERMARK%) white center center no-repeat fixed; + } + a { text-decoration : none; } @@ -1823,26 +1902,21 @@ " $rwd_pixel = " -R0lGODlhAQABAOcAAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoK -CgsLCwwMDA0NDQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZ -GRoaGhsbGxwcHB0dHR4eHh8fHyAgICEhISIiIiMjIyQkJCUlJSYmJicnJygo -KCkpKSoqKisrKywsLC0tLS4uLi8vLzAwMDExMTIyMjMzMzQ0NDU1NTY2Njc3 -Nzg4ODk5OTo6Ojs7Ozw8PD09PT4+Pj8/P0BAQEFBQUJCQkNDQ0REREVFRUZG -RkdHR0hISElJSUpKSktLS0xMTE1NTU5OTk9PT1BQUFFRUVJSUlNTU1RUVFVV -VVZWVldXV1hYWFlZWVpaWltbW1xcXF1dXV5eXl9fX2BgYGFhYWJiYmNjY2Rk -ZGVlZWZmZmdnZ2hoaGlpaWpqamtra2xsbG1tbW5ubm9vb3BwcHFxcXJycnNz -c3R0dHV1dXZ2dnd3d3h4eHl5eXp6ent7e3x8fH19fX5+fn9/f4CAgIGBgYKC -goODg4SEhIWFhYaGhoeHh4iIiImJiYqKiouLi4yMjI2NjY6Ojo+Pj5CQkJGR -kZKSkpOTk5SUlJWVlZaWlpeXl5iYmJmZmZqampubm5ycnJ2dnZ6enp+fn6Cg -oKGhoaKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq6ysrK2tra6urq+v -r7CwsLGxsbKysrOzs7S0tLW1tba2tre3t7i4uLm5ubq6uru7u7y8vL29vb6+ -vr+/v8DAwMHBwcLCwsPDw8TExMXFxcbGxsfHx8jIyMnJycrKysvLy8zMzM3N -zc7Ozs/Pz9DQ0NHR0dLS0tPT09TU1NXV1dbW1tfX19jY2NnZ2dra2tvb29zc -3N3d3d7e3t/f3+Dg4OHh4eLi4uPj4+Tk5OXl5ebm5ufn5+jo6Onp6erq6uvr -6+zs7O3t7e7u7u/v7/Dw8PHx8fLy8vPz8/T09PX19fb29vf39/j4+Pn5+fr6 -+vv7+/z8/P39/f7+/v///yH+FUNyZWF0ZWQgd2l0aCBUaGUgR0lNUAAh+QQB -CgD/ACwAAAAAAQABAAAIBAD/BQQAOw== +R0lGODlhAQABAMIAAAAAAP///+7u7kREiP///////////////yH5BAEKAAMA +LAAAAAABAAEAAAMCOAkAOw== ".unpack("m").shift +$rwd_logo = " +R0lGODlhEAAQAMIAAAAAAP///+7u7kREiP///////////////yH5BAEKAAQA +LAAAAAAQABAAAANCSErQ/k21QKulrIrNu8heuAGUcJ0BuQVD676DasK0zNKv +jefB+oo6l6AxBAx7M2HRePQph5xga0RsJqfELPI2DSUAADs= +".unpack("m").shift + + $rwd_html_1, $rwd_html_2 = $rwd_html[ENV["RWDTHEME"]].split(/^\s*%BODY%\s*\r*$/) $rwd_html_PDA_1, $rwd_html_PDA_2 = $rwd_html["PDA"].split(/^\s*%BODY%\s*\r*$/) + +#end +# +#class RWDialog < RWD::RWDialog +#end diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/sgml.lib.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/sgml.lib.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/sgml.lib.rb 2004-12-17 12:40:15.000000000 +0100 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/sgml.lib.rb 2005-06-04 14:41:52.000000000 +0200 @@ -88,7 +88,7 @@ def prechildren_to_sgml(res) a = [@subtype] - @args.each do |k, v| + @args.sort.each do |k, v| if not v.include?("´") a << "#{k}=´#{v}´" else diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/tree.lib.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/tree.lib.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/tree.lib.rb 2004-12-17 12:40:15.000000000 +0100 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/tree.lib.rb 2005-06-04 14:41:52.000000000 +0200 @@ -88,7 +88,7 @@ def inspect parent, children = @parent, @children - @parent, @children = parent.id, children.collect{|obj| obj.id} + @parent, @children = parent.object_id, children.collect{|obj| obj.object_id} res = " " * (level-1) + "#{self.class}(#{@subtype}) #{super}" @@ -96,6 +96,34 @@ res end + + def previous(klass=[], skip=[]) + klass = [klass].flatten + skip = [skip].flatten + + po = @parent + return nil if po.nil? + + ch = po.children + return nil if ch.nil? + + n = ch.index(self) + return nil if n.nil? + + res = nil + if klass.nil? + n -= 1 + res = ch[n] + else + begin + n -= 1 + res = ch[n] + end while (klass.empty? or klass.collect{|k| ch[n-1].kind_of?(k)}.sort.uniq == [true]) \ + and (skip.empty? or skip.collect{|k| ch[n-1].kind_of?(k)}.sort.uniq == [false]) + end + + res + end end class Tree @@ -138,7 +166,7 @@ end def self.location(url, form=Hash.new) - s = HTTPClient.get(url, form) + s = HTTPClient.get(url, {}, form) s = "" if s.nil? new(s) end @@ -155,7 +183,7 @@ tree = nil - Dir.mkdirrec(dir) + File.mkpath(dir) if File.file?(file) @@mutex.synchronize do @@ -227,7 +255,7 @@ end def markclosed - ([self].concat @objects).each do |obj| + ([self] + @objects).each do |obj| obj.children.each_index do |i| co1 = obj.children[i] co2 = obj.children[i+1] @@ -238,7 +266,7 @@ end def deletedummies - ([self].concat @objects).each do |obj| + ([self] + @objects).each do |obj| obj.children.delete_if do |obj2| obj2.upordown == Dummy end diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/xml.lib.rb rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/xml.lib.rb --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/lib/xml.lib.rb 2004-12-17 12:40:15.000000000 +0100 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/lib/xml.lib.rb 2005-06-04 14:41:52.000000000 +0200 @@ -1,4 +1,101 @@ require "ev/sgml" +class SGMLObject + def to_x(closetags=true) + res = "" + + parsetree("prechildren_to_x", "postchildren_to_x", res, closetags) + + res + end +end + +class Text < SGMLObject + def prechildren_to_x(res, closetags) + res << @text.strip unless @text.strip.empty? + end +end + +class Comment < SGMLObject + def prechildren_to_x(res, closetags) + res << "\n" if not previous([], [Text]).kind_of?(Comment) + lines = @text.gsub(/(<!--|-->)/, "").lf.split(/\n/) + if lines.length == 1 + res << " "*(@level-1) + "<!-- " + lines[0].strip + " -->" + "\n" + else + res << " "*(@level-1) + "<!--" + "\n" + res << lines.collect{|s| " "*(@level-1) + s.strip}.delete_if{|s| s.compress.empty?}.join("\n") + res << "\n" + res << " "*(@level-1) + "-->" + "\n" + res << "\n" + end + end +end + +class Special < SGMLObject + def prechildren_to_x(res, closetags) + res << " "*(@level-1) + @text.compress + "\n" + end +end + +class Instruction < SGMLObject + def prechildren_to_x(res, closetags) + res << " "*(@level-1) + @text.compress + "\n" + end +end + +class OpenTag < Tag + def prechildren_to_x(res, closetags) + a = [@subtype] + + args = @args.dup + args.delete("id") + args.delete("name") + args = args.sort + args.unshift(["id", @args["id"]]) if @args.include?("id") + args.unshift(["name", @args["name"]]) if @args.include?("name") + + args.each do |k, v| + if not v.include?("´") + a << "#{k}=´#{v}´" + else + if not v.include?(´"´) + a << "#{k}=\"#{v}\"" + else + a << "#{k}=´#{v.gsub(/\´/, ´"´)}´" + end + end + end + + if @children.length == 0 or (@children.length == 1 and @children[0].kind_of?(Text) and @children[0].text.compress.empty?) + res << " "*(@level-1) + "<#{a.join(" ")}/>" + "\n" + else + if @children.length == 1 and @children[0].kind_of?(Text) and @children[0].text.lf.split(/\n/).length == 1 + res << " "*(@level-1) + "<#{a.join(" ")}>" + else + res << " "*(@level-1) + "<#{a.join(" ")}>" + "\n" + end + end + end + + def postchildren_to_x(res, closetags) + if closetags + unless @children.length == 0 or (@children.length == 1 and @children[0].kind_of?(Text) and @children[0].text.compress.empty?) + res << "\n" if @children.length == 1 and @children[0].kind_of?(Text) and @children[0].text.lf.split(/\n/).length > 1 + res << " "*(@level-1) unless @children.length == 1 and @children[0].kind_of?(Text) and @children[0].text.lf.split(/\n/).length == 1 + res << "</#{@subtype}>" + res << "\n" + end + end + end +end + class XML < SGML + def to_x(closetags=true) + res = "" + + parsetree("prechildren_to_x", "postchildren_to_x", res, closetags) + + res + end end diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/SUMMARY rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/SUMMARY --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/SUMMARY 2005-06-04 14:42:01.089517448 +0200 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/SUMMARY 2005-06-04 14:41:52.000000000 +0200 @@ -0,0 +1 @@ +The Web Browser as a Graphical User Interface for Ruby Applications diff -ur rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/VERSION rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/VERSION --- rubywebdialogs-0.1.2.tar.gz/rubywebdialogs/VERSION 2005-06-04 14:42:01.088517600 +0200 +++ rubywebdialogs-0.2.0.tar.gz/rubywebdialogs/VERSION 2005-06-04 14:41:52.000000000 +0200 @@ -0,0 +1 @@ +0.2.0