#!/usr/bin/env ruby ################################ # Author: Benjamin Kellermann # # License: CC-by-sa 3.0 # # see License # ################################ require "yaml" require "cgi" if __FILE__ == $0 $cgi = CGI.new TYPE = "text/html" #TYPE = "application/xhtml+xml" CHARSET = "utf-8" $htmlout = < HEAD olddir = File.expand_path(".") Dir.chdir("..") load "charset.rb" load "config.rb" require "poll" require "datepoll" require "timepoll" Dir.chdir(olddir) # BUGFIX for Time.parse, which handles the zone indeterministically class << Time alias_method :old_parse, :parse def Time.parse(date, now=self.now) Time.old_parse("2009-10-25 00:30") Time.old_parse(date) end end acusers = {} if $cgi.include?("revision") REVISION=$cgi["revision"].to_i table = YAML::load(VCS.cat(REVISION, "data.yaml")) VCS.cat(REVISION,".htdigest").each_line{|l| v,k = l.scan(/^(.*):(.*):.*$/).flatten acusers[k] = v } else table = YAML::load_file("data.yaml") File.open(".htdigest","r").each_line{|l| v,k = l.scan(/^(.*):(.*):.*$/).flatten acusers[k] = v } table.invite_delete($cgi["invite_delete"]) if $cgi.include?("invite_delete") and $cgi["invite_delete"] != "" table.edit_column($cgi["new_columnname"],$cgi["columndescription"],$cgi["old_columnname"]) if $cgi.include?("new_columnname") table.delete_column($cgi["delete_column"]) if $cgi.include?("delete_column") table.toggle_hidden if $cgi.include?("toggle_hidden") def writehtaccess(acusers) File.open(".htaccess","w"){|htaccess| if acusers["admin"] htaccess << < AuthType digest AuthName "admin" AuthUserFile #{File.expand_path(".")}/.htdigest Require valid-user HTACCESS end if acusers["participant"] htaccess << < dudle - config - #{table.name}
#{BACK} history:#{table.history_to_html}
HTMLHEAD $htmlout += <#{table.name} #{table.to_html("",true,$cgi["editcolumn"])} TABLE $htmlout += <
invite/delete participant
INVITEDELETE # ADD/REMOVE COLUMN $htmlout +=< #{table.edit_column_htmlform($cgi["editcolumn"])} ADD_EDIT $htmlout +=<
Change Access Control settings If you want to restrict the poll, add the participant user. If you want to restrict the configuration interface seperately, please add an admin user!
ACL acusers.each{|action,user| $htmlout += < USER } $htmlout += <
NamePassword
#{user} *****************
ACL $htmlout +=<
Toggle Hidden flag
HIDDEN $htmlout +=<
Remove the whole poll
Warning: This is an irreversible action!
REMOVE $htmlout += "" $htmlout += "" $cgi.out("type" => TYPE ,"charset" => CHARSET,"cookie" => $utfcookie, "Cache-Control" => "no-cache"){$htmlout} end