diff options
author | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2009-06-14 22:29:43 +0200 |
---|---|---|
committer | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2009-06-14 22:29:43 +0200 |
commit | c933e165e5e76fbc5b44336bd88a3e930c8d2e48 (patch) | |
tree | a0a4eca9e62f5b988f050a1ff12db6ac4b162292 | |
parent | 7c7e469f898ce63c10d4725fa86a37622c584552 (diff) |
put historynav to poll class
-rwxr-xr-x | config.cgi | 31 | ||||
-rw-r--r-- | participate.rb | 74 | ||||
-rw-r--r-- | poll.rb | 19 |
3 files changed, 65 insertions, 59 deletions
@@ -32,7 +32,16 @@ require "poll" require "datepoll" Dir.chdir(olddir) -table = YAML::load_file("data.yaml") +if $cgi.include?("revision") + REVISION=$cgi["revision"].to_i + table = YAML::load(VCS.cat(REVISION, "data.yaml")) +else + table = YAML::load_file("data.yaml") + + table.invite_delete($cgi["invite_delete"]) if $cgi.include?("invite_delete") and $cgi["invite_delete"] != "" + table.add_remove_column($cgi["add_remove_column"],$cgi["columndescription"]) if $cgi.include?("add_remove_column") + table.toggle_hidden if $cgi.include?("toggle_hidden") +end $htmlout += <<HTMLHEAD <head> @@ -42,20 +51,18 @@ $htmlout += <<HTMLHEAD <link rel="stylesheet" type="text/css" href="../dudle.css" title="default"/> </head> <body> - <div id='backlink'> - <a href='.' style='text-decoration:none'>#{BACK}</a> + <div> + <small> + <a href='.' style='text-decoration:none'>#{BACK}</a> + history:#{table.history_to_html} + </small> </div> - <h1>#{table.name}</h1> HTMLHEAD -table.invite_delete($cgi["invite_delete"]) if $cgi.include?("invite_delete") and $cgi["invite_delete"] != "" - -if $cgi.include?("add_remove_column") - $htmlout += "Could not add/remove column #{$cgi["add_remove_column"]}" unless table.add_remove_column($cgi["add_remove_column"],$cgi["columndescription"]) -end -table.toggle_hidden if $cgi.include?("toggle_hidden") - -$htmlout += table.to_html(config = true) +$htmlout += <<TABLE + <h1>#{table.name}</h1> +#{table.to_html(config = true)} +TABLE $htmlout += <<INVITEDELETE <div id='invite_delete'> diff --git a/participate.rb b/participate.rb index 6cb0a3c..feca58f 100644 --- a/participate.rb +++ b/participate.rb @@ -15,6 +15,20 @@ if $cgi.include?("revision") table = YAML::load(VCS.cat(REVISION, "data.yaml")) else table = YAML::load_file("data.yaml") + + if $cgi.include?("add_participant") + agreed = {} + $cgi.params.each{|k,v| + if k =~ /^add_participant_checked_/ + agreed[k.gsub(/^add_participant_checked_/,"")] = v[0] + end + } + + table.add_participant($cgi["add_participant"],agreed) + end + + table.add_comment($cgi["commentname"],$cgi["comment"]) if $cgi["comment"] != "" + table.delete_comment($cgi["delete_comment"].to_i) if $cgi.include?("delete_comment") end $htmlout += <<HEAD @@ -28,60 +42,26 @@ $htmlout += <<HEAD <link rel="alternate" type="application/atom+xml" href="atom.cgi" /> </head> <body> -<div> - <small> - <a href='..' style='text-decoration:none'>#{BACK}</a> - <a href='config.cgi' style='text-decoration:none'>config</a> + <div> + <small> + <a href='..' style='text-decoration:none'>#{BACK}</a> + <a href='config.cgi' style='text-decoration:none'>config</a> + history:#{table.history_to_html} + </small> + </div> HEAD - -# HISTORY -MAXREV=VCS.revno -REVISION=MAXREV unless defined?(REVISION) -log = VCS.history -log.shift -log.collect!{|s| s.scan(/\nrevno:.*\ncommitter.*\n.*\ntimestamp: (.*)\nmessage:\n (.*)/).flatten} -log.collect!{|t,c| [DateTime.parse(t),c]} - -$htmlout +=" history:" - -((REVISION-2)..(REVISION+2)).each do |i| - if i >0 && i<=MAXREV - $htmlout += " " - $htmlout += "<a href='?revision=#{i}' >" if REVISION != i - $htmlout += "<span title=\"#{log[i-1][0].strftime('%d.%m, %H:%M')}: #{CGI.escapeHTML(log[i-1][1])}\">#{i}</span>" - $htmlout += "</a>" if REVISION != i - end -end -$htmlout += "</small></div>" - # TABLE -$htmlout += "<h1>#{table.name}</h1>" -if $cgi.include?("add_participant") - agreed = {} - $cgi.params.each{|k,v| - if k =~ /^add_participant_checked_/ - agreed[k.gsub(/^add_participant_checked_/,"")] = v[0] - end - } - - table.add_participant($cgi["add_participant"],agreed) -end - -table.add_comment($cgi["commentname"],$cgi["comment"]) if $cgi["comment"] != "" -table.delete_comment($cgi["delete_comment"].to_i) if $cgi.include?("delete_comment") - -# POLL -$htmlout += <<POLLTABLE +$htmlout += <<TABLE +<h1>#{table.name}</h1> <div id='polltable'> -<form method='post' action='.'> -#{table.to_html} -</form> + <form method='post' action='.'> + #{table.to_html} + </form> </div> -POLLTABLE +TABLE $htmlout += table.comment_to_html - $htmlout += "</body>" @@ -201,6 +201,25 @@ ADDCOMMENT ret += "</div>\n" ret end + def history_to_html + ret = "" + maxrev=VCS.revno + revision= defined?(REVISION) ? REVISION : maxrev + log = VCS.history + log.shift + log.collect!{|s| s.scan(/\nrevno:.*\ncommitter.*\n.*\ntimestamp: (.*)\nmessage:\n (.*)/).flatten} + log.collect!{|t,c| [DateTime.parse(t),c]} + + ((revision-2)..(revision+2)).each do |i| + if i >0 && i<=maxrev + ret += " " + ret += "<a href='?revision=#{i}' >" if revision != i + ret += "<span title=\"#{log[i-1][0].strftime('%d.%m, %H:%M')}: #{CGI.escapeHTML(log[i-1][1])}\">#{i}</span>" + ret += "</a>" if revision != i + end + end + ret + end def add_remove_column_htmlform if $cgi.include?("editcolumn") title = $cgi["editcolumn"] |