#!/usr/bin/env ruby
################################
# Author: Benjamin Kellermann #
# Licence: CC-by-sa 3.0 #
# see Licence #
################################
require "yaml"
require "cgi"
if __FILE__ == $0
$cgi = CGI.new
TYPE = "text/html"
#TYPE = "application/xhtml+xml"
CHARSET = "utf-8"
$htmlout = <
HEAD
if File.exist?("data.yaml")
olddir = File.expand_path(".")
Dir.chdir("..")
load "charset.rb"
load "config.rb"
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 - config - #{table.name}
#{table.name}
HTMLHEAD
table.invite_delete($cgi["invite_delete"]) if $cgi.include?("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 += <
INVITEDELETE
# ADD/REMOVE COLUMN
$htmlout +=<
ADD_REMOVE
$htmlout +=<
HIDDEN
$htmlout += ""
else
load "charset.rb"
load "config.rb"
load "overview.rb"
end
$htmlout += ""
$cgi.out("type" => TYPE ,"charset" => CHARSET,"cookie" => $utfcookie, "Cache-Control" => "no-cache"){$htmlout}
end