################################
# Author: Benjamin Kellermann #
# License: CC-by-sa 3.0 #
# see License #
################################
class HTML
attr_accessor :body, :header
def initialize(title)
@title = title
@header = {}
@header["type"] = "text/html"
# @header["type"] = "application/xhtml+xml"
@header["charset"] = "utf-8"
@body = ""
@css = {}
@atom = []
end
def head
ret = <
#{@title}
HEAD
@css.each{|title,href|
ret += ""
ret += "" if title == "print"
}
@atom.each{|href|
ret += ""
}
ret += ""
ret
end
def add_css(href, title = "default")
@css[title] ||= []
@css[title] << href
end
def add_atom(href)
@atom << href
end
def add_cookie(key,value,path,expiretime)
c = CGI::Cookie.new(key, value)
c.path = path
c.expires = expiretime
@header["cookie"] = c
end
def << (bodycontent)
@body += bodycontent
end
def out(cgi)
cgi.out(@header){
<
#{head}
#{@body}
HEAD
}
end
end
module Dudle
def Dudle.tabs(active_tab)
ret = "
"
[["Poll","."],
["Admin","config.cgi"]].each{|tab,file|
if tab == active_tab
ret += "