diff options
-rw-r--r-- | charset.rb | 2 | ||||
-rwxr-xr-x | config_poll.rb | 4 | ||||
-rw-r--r-- | html.rb | 53 | ||||
-rwxr-xr-x | participate.rb | 59 |
4 files changed, 76 insertions, 42 deletions
@@ -39,4 +39,4 @@ else EDIT = CGI.escapeHTML("edit") DELETE = CGI.escapeHTML("delete") end -$header["cookie"] = utfcookie +$html.header["cookie"] = utfcookie diff --git a/config_poll.rb b/config_poll.rb index 336b444..e2529bc 100755 --- a/config_poll.rb +++ b/config_poll.rb @@ -142,14 +142,14 @@ $htmlout += <<HTMLHEAD <head> <meta http-equiv="Content-Type" content="#{$header["type"]}; charset=#{$header["charset"]}" /> <meta http-equiv="Content-Style-Type" content="text/css" /> - <title>dudle - config - #{table.name}</title> + <title>dudle - Administration - #{table.name}</title> <link rel="stylesheet" type="text/css" href="../dudle.css" title="default"/> </head> <body> <div id='tabs'> <ul> <li class='nonactive_tab'><a href='.'> poll </a></li> - <li id='active_tab'> config </li> + <li id='active_tab'> admin </li> </ul> </div> HTMLHEAD @@ -0,0 +1,53 @@ + +class HTML + attr_accessor :title, :htmlout, :header + def initialize + @header = {} + @header["type"] = "text/html" +# @header["type"] = "application/xhtml+xml" + @header["charset"] = "utf-8" + + @htmlout = <<HEAD +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" + "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> +HEAD + @css = {} + @atom = [] + end + def add_head(title) + @htmlout += <<HEAD +<head> + <meta http-equiv="Content-Type" content="#{@header["type"]}; charset=#{@header["charset"]}" /> + <meta http-equiv="Content-Style-Type" content="text/css" /> + <title>#{title}</title> +HEAD + @css.each{|title,href| + @htmlout += "<link rel='stylesheet' type='text/css' href='#{href}' title='#{title}'/>" + @htmlout += "<link rel='stylesheet' type='text/css' href='#{href}' title='print' media='print' />" if title == "print" + } + + @atom.each{|href| + @htmlout += "<link rel='alternate' type='application/atom+xml' href='#{href}' />" + } + + @htmlout += "</head>" + end + def add_css(href, title = "default") + @css[title] ||= [] + @css[title] << href + end + def add_atom(href) + @atom << href + end + def add_tabs + @htmlout += <<HEAD + <div id='tabs'> + <ul> + <li id='active_tab' > poll </li> + <li class='nonactive_tab'><a href='config.cgi'> admin </a></li> + </ul> + </div> +HEAD + end +end diff --git a/participate.rb b/participate.rb index d13ea7d..7f8dce2 100755 --- a/participate.rb +++ b/participate.rb @@ -7,26 +7,18 @@ ################################ require "yaml" -require "cgi" - if __FILE__ == $0 +require "cgi" + $cgi = CGI.new -$header = {} -$header["type"] = "text/html" -#$header["type"] = "application/xhtml+xml" -$header["charset"] = "utf-8" - -$htmlout = <<HEAD -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" - "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> -HEAD olddir = File.expand_path(".") Dir.chdir("..") +require "html" +$html = HTML.new require "poll" load "charset.rb" load "config.rb" @@ -56,34 +48,23 @@ else table.add_comment($cgi["commentname"],$cgi["comment"]) if $cgi["comment"] != "" table.delete_comment($cgi["delete_comment"].to_i) if $cgi.include?("delete_comment") end +$html.add_css("../dudle.css") +$html.add_css("../print.css","print") -$htmlout += <<HEAD -<head> - <meta http-equiv="Content-Type" content="#{$header["type"]}; charset=#{$header["charset"]}" /> - <meta http-equiv="Content-Style-Type" content="text/css" /> - <title>dudle - #{table.name}</title> - <link rel="stylesheet" type="text/css" href="../dudle.css" title="default"/> - <link rel="stylesheet" type="text/css" href="../print.css" title="print" media="print" /> - <link rel="stylesheet" type="text/css" href="../print.css" title="print" /> -HEAD +$html.add_atom("atom.cgi") if File.exists?("../atom.rb") +$html.add_head("dudle - #{table.name}") + +$html.htmlout += "<body>" + +$html.add_tabs -$htmlout += '<link rel="alternate" type="application/atom+xml" href="atom.cgi" />' if File.exists?("../atom_single.rb") - -$htmlout += <<HEAD -</head> -<body> - <div id='tabs'> - <ul> - <li id='active_tab' > poll </li> - <li class='nonactive_tab'><a href='config.cgi'> config </a></li> - </ul> - </div> +$html.htmlout += <<HEAD <div id='main'> HEAD # TABLE if VCS.revno == 1 - $htmlout += <<HINT + $html.htmlout += <<HINT <h1>#{table.name}</h1> <pre id='configwarning'> . @@ -104,7 +85,7 @@ if VCS.revno == 1 </pre> HINT else - $htmlout += <<TABLE + $html.htmlout += <<TABLE <p id='history'>history:#{table.history_to_html}</p> <h1>#{table.name}</h1> <div id='polltable'> @@ -114,13 +95,13 @@ else </div> TABLE - $htmlout += table.comment_to_html + $html.htmlout += table.comment_to_html end -$htmlout += "</div></body>" +$html.htmlout += "</div></body>" -$htmlout += "</html>" +$html.htmlout += "</html>" -$header["Cache-Control"] = "no-cache" -$cgi.out($header){$htmlout} +$html.header["Cache-Control"] = "no-cache" +$cgi.out($html.header){$html.htmlout} end |