From 0e8d1d9d28d127704897bb9fb4ea06105a1d0f84 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Thu, 19 Nov 2009 20:00:05 +0100 Subject: startet to use html element for output --- charset.rb | 2 +- config_poll.rb | 4 ++-- html.rb | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ participate.rb | 59 ++++++++++++++++++++-------------------------------------- 4 files changed, 76 insertions(+), 42 deletions(-) create mode 100644 html.rb diff --git a/charset.rb b/charset.rb index 5535844..ad6c836 100644 --- a/charset.rb +++ b/charset.rb @@ -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 += < - dudle - config - #{table.name} + dudle - Administration - #{table.name}
HTMLHEAD diff --git a/html.rb b/html.rb new file mode 100644 index 0000000..93739ba --- /dev/null +++ b/html.rb @@ -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 + @css = {} + @atom = [] + end + def add_head(title) + @htmlout += < + + + #{title} +HEAD + @css.each{|title,href| + @htmlout += "" + @htmlout += "" if title == "print" + } + + @atom.each{|href| + @htmlout += "" + } + + @htmlout += "" + 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 + 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 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 += < - - - dudle - #{table.name} - - - -HEAD +$html.add_atom("atom.cgi") if File.exists?("../atom.rb") +$html.add_head("dudle - #{table.name}") + +$html.htmlout += "" + +$html.add_tabs -$htmlout += '' if File.exists?("../atom_single.rb") - -$htmlout += < - -
- -
+$html.htmlout += < HEAD # TABLE if VCS.revno == 1 - $htmlout += <#{table.name}
     .
@@ -104,7 +85,7 @@ if VCS.revno == 1
 
HINT else - $htmlout += <history:#{table.history_to_html}

#{table.name}

@@ -114,13 +95,13 @@ else
TABLE - $htmlout += table.comment_to_html + $html.htmlout += table.comment_to_html end -$htmlout += "" +$html.htmlout += "" -$htmlout += "" +$html.htmlout += "" -$header["Cache-Control"] = "no-cache" -$cgi.out($header){$htmlout} +$html.header["Cache-Control"] = "no-cache" +$cgi.out($html.header){$html.htmlout} end -- cgit v1.2.3