aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-06-14 22:29:43 +0200
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2009-06-14 22:29:43 +0200
commitc933e165e5e76fbc5b44336bd88a3e930c8d2e48 (patch)
treea0a4eca9e62f5b988f050a1ff12db6ac4b162292
parent7c7e469f898ce63c10d4725fa86a37622c584552 (diff)
put historynav to poll class
-rwxr-xr-xconfig.cgi31
-rw-r--r--participate.rb74
-rw-r--r--poll.rb19
3 files changed, 65 insertions, 59 deletions
diff --git a/config.cgi b/config.cgi
index 528d075..bbfb0fd 100755
--- a/config.cgi
+++ b/config.cgi
@@ -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>"
diff --git a/poll.rb b/poll.rb
index 7c98356..3e634e1 100644
--- a/poll.rb
+++ b/poll.rb
@@ -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"]