diff options
-rwxr-xr-x | index.cgi | 18 | ||||
-rw-r--r-- | overview.rb | 28 | ||||
-rw-r--r-- | participate.rb | 38 |
3 files changed, 43 insertions, 41 deletions
@@ -8,14 +8,14 @@ if __FILE__ == $0 $cgi = CGI.new -CONTENTTYPE = "text/html; charset=utf-8" +TYPE = "text/html" +CHARSET = "utf-8" #CONTENTTYPE = "application/xhtml+xml; charset=utf-8" -puts "Content-type: #{CONTENTTYPE}" -puts "Cache-Control: no-cache" - +utfcookie = CGI::Cookie.new("utf", "true") +utfcookie.path = "/" if ($cgi.include?("utf") || $cgi.cookies["utf"][0]) && !$cgi.include?("ascii") - puts "Set-Cookie: utf=true; path=/; expires=#{(Time.now+1*60*60*24*365).getgm.strftime("%a, %d %b %Y %H:%M:%S %Z")}" + utfcookie.expires = Time.now+1*60*60*24*365 UTFASCII = "<a href='?ascii' style='text-decoration:none'>ASCII</a>" BACK = CGI.escapeHTML("↩") @@ -29,7 +29,7 @@ if ($cgi.include?("utf") || $cgi.cookies["utf"][0]) && !$cgi.include?("ascii") MONTHFORWARD = CGI.escapeHTML("→") YEARFORWARD = CGI.escapeHTML("↠") else - puts "Set-Cookie: utf=true; path=/; expires=#{(Time.now-1*60*60*24*365).getgm.strftime("%a, %d %b %Y %H:%M:%S %Z")}" + utfcookie.expires = Time.now-1*60*60*24*36 UTFASCII = "<a href='?utf' style='text-decoration:none'>#{CGI.escapeHTML('↩✔✘?–↞←→↠')}</a>" BACK = CGI.escapeHTML("<-") @@ -44,8 +44,7 @@ else YEARFORWARD = CGI.escapeHTML(">>") end -puts <<HEAD - +$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"> @@ -56,4 +55,7 @@ if File.exist?("data.yaml") else load "overview.rb" end + +$cgi.out("type" => TYPE ,"charset" => CHARSET,"cookie" => utfcookie, "Cache-Control" => "no-cache"){$htmlout} end + diff --git a/overview.rb b/overview.rb index e8e7f0c..dc890d1 100644 --- a/overview.rb +++ b/overview.rb @@ -6,7 +6,7 @@ require "cgi" require "poll" require "datepoll" -puts <<HEAD +$htmlout += <<HEAD <head> <title>dudle</title> <link rel="alternate" type="application/atom+xml" href="atom.cgi" /> @@ -33,7 +33,7 @@ if $cgi.include?("create_poll") end Dir.chdir("..") if hidden - puts <<HIDDENINFO + $htmlout += <<HIDDENINFO <fieldset> <legend>Info</legend> Poll #{SITE} created successfull! @@ -43,34 +43,34 @@ Please remember the url (<a href="#{SITE}">#{$cgi.server_name}#{$cgi.script_name HIDDENINFO end else - puts "<fieldset><legend>Error</legend>This poll already exists!</fieldset>" + $htmlout += "<fieldset><legend>Error</legend>This poll already exists!</fieldset>" end end -puts "<fieldset><legend>Available Polls</legend>" -puts "<table><tr><th>Poll</th><th>Last change</th></tr>" +$htmlout += "<fieldset><legend>Available Polls</legend>" +$htmlout += "<table><tr><th>Poll</th><th>Last change</th></tr>" Dir.glob("*/data.yaml").sort_by{|f| File.new(f).mtime }.reverse.collect{|f| f.gsub(/\/data\.yaml$/,'') }.each{|site| unless YAML::load_file("#{site}/data.yaml").hidden - puts "<tr>" - puts "<td class='site'><a href='#{site}'>#{site}</a></td>" - puts "<td class='mtime'>#{File.new(site + "/data.yaml").mtime.strftime('%d.%m, %H:%M')}</td>" - puts "</tr>" + $htmlout += "<tr>" + $htmlout += "<td class='site'><a href='#{site}'>#{site}</a></td>" + $htmlout += "<td class='mtime'>#{File.new(site + "/data.yaml").mtime.strftime('%d.%m, %H:%M')}</td>" + $htmlout += "</tr>" end } -puts "</table>" -puts "</fieldset>" +$htmlout += "</table>" +$htmlout += "</fieldset>" -puts <<CHARSET +$htmlout += <<CHARSET <fieldset><legend>change charset</legend> #{UTFASCII} </fieldset> CHARSET -puts <<CREATE +$htmlout += <<CREATE <fieldset><legend>Create new Poll</legend> <form method='post' action='.'> <table> @@ -99,5 +99,5 @@ puts <<CREATE </fieldset> CREATE -puts "</body></html>" +$htmlout += "</body></html>" diff --git a/participate.rb b/participate.rb index ad70651..7022cc7 100644 --- a/participate.rb +++ b/participate.rb @@ -11,9 +11,9 @@ else table = YAML::load_file("data.yaml") end -puts <<HEAD +$htmlout += <<HEAD <head> - <meta http-equiv="Content-Type" content="#{CONTENTTYPE}" /> + <meta http-equiv="Content-Type" content="#{TYPE}"; charset="#{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"/> @@ -42,13 +42,13 @@ end table.invite_delete($cgi["invite_delete"]) if $cgi.include?("invite_delete") if $cgi.include?("add_remove_column") - puts "Could not add/remove column #{$cgi["add_remove_column"]}" unless table.add_remove_column($cgi["add_remove_column"],$cgi["columndescription"]) + $htmlout += "Could not add/remove column #{$cgi["add_remove_column"]}" unless table.add_remove_column($cgi["add_remove_column"],$cgi["columndescription"]) end table.add_comment($cgi["commentname"],$cgi["comment"]) if $cgi.include?("comment") table.delete_comment($cgi["delete_comment"].to_i) if $cgi.include?("delete_comment") -puts table.to_html +$htmlout += table.to_html MAXREV=`bzr revno`.to_i REVISION=MAXREV unless defined?(REVISION) @@ -56,7 +56,7 @@ log = `export LC_ALL=de_DE.UTF-8; bzr log --forward`.split("-"*60) log.collect!{|s| s.scan(/\nrevno:.*\ncommitter.*\n.*\ntimestamp: (.*)\nmessage:\n (.*)/).flatten} log.shift log.collect!{|t,c| [DateTime.parse(t),c]} -puts <<HISTORY +$htmlout += <<HISTORY <div id='history'> <fieldset><legend>browse history</legend> <table> @@ -70,22 +70,22 @@ HISTORY ((REVISION-2)..(REVISION+2)).each do |i| if i >0 && i<=MAXREV if REVISION == i - puts "<tr id='displayed_revision'><td>#{i}" + $htmlout += "<tr id='displayed_revision'><td>#{i}" else - puts "<tr><td>" - puts "<a href='?revision=#{i}'>#{i}</a>" + $htmlout += "<tr><td>" + $htmlout += "<a href='?revision=#{i}'>#{i}</a>" end - puts "</td>" - puts "<td>#{log[i-1][0].strftime('%d.%m, %H:%M')}</td>" - puts "<td>#{log[i-1][1]}</td>" - puts "</tr>" + $htmlout += "</td>" + $htmlout += "<td>#{log[i-1][0].strftime('%d.%m, %H:%M')}</td>" + $htmlout += "<td>#{log[i-1][1]}</td>" + $htmlout += "</tr>" end end -puts "</table>" -puts "</fieldset>" -puts "</div>" +$htmlout += "</table>" +$htmlout += "</fieldset>" +$htmlout += "</div>" -puts <<INVITEDELETE +$htmlout += <<INVITEDELETE <div id='invite_delete'> <fieldset> <legend>invite/delete participant</legend> @@ -99,9 +99,9 @@ puts <<INVITEDELETE </div> INVITEDELETE -puts table.add_remove_column_htmlform +$htmlout += table.add_remove_column_htmlform -puts <<ADDCOMMENT +$htmlout += <<ADDCOMMENT <div id='add_comment'> <fieldset> <legend>Comment</legend> @@ -119,4 +119,4 @@ puts <<ADDCOMMENT </div> ADDCOMMENT -puts "</body></html>" +$htmlout += "</body></html>" |