################################
# Author: Benjamin Kellermann #
# Licence: CC-by-sa 3.0 #
# see Licence #
################################
olddir = File.expand_path(".")
Dir.chdir("..")
require "poll"
require "datepoll"
Dir.chdir(olddir)
if $cgi.include?("revision")
REVISION=$cgi["revision"].to_i
table = YAML::load(VCS.cat(REVISION, "data.yaml"))
else
table = YAML::load_file("data.yaml")
end
$htmlout += <
dudle - #{table.name}
#{BACK}config
HEAD
# HISTORY
MAXREV=VCS.revno
REVISION=MAXREV unless defined?(REVISION)
log = VCS.history
log.collect!{|s| s.scan(/\nrevno:.*\ncommitter.*\n.*\ntimestamp: (.*)\nmessage:\n (.*)/).flatten}
log.shift
log.collect!{|t,c| [DateTime.parse(t),c]}
$htmlout +=" history:"
((REVISION-2)..(REVISION+2)).each do |i|
if i >0 && i<=MAXREV
$htmlout += " "
$htmlout += "" if REVISION != i
$htmlout += "#{i}"
$htmlout += "" if REVISION != i
end
end
$htmlout += "
"
# TABLE
$htmlout += "
#{table.name}
"
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.comment_to_html
$htmlout += ""