#!/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 load "charset.rb" load "config.rb" require "poll" require "datepoll" require "timepoll" $htmlout += < dudle HEAD if $cgi.include?("create_poll") SITE=$cgi["create_poll"] unless File.exist?(SITE) Dir.mkdir(SITE) Dir.chdir(SITE) VCS.init File.symlink("../participate.rb","index.cgi") File.symlink("../atom_single.rb","atom.cgi") File.symlink("../config_poll.rb","config.cgi") File.open("data.yaml","w").close VCS.add("data.yaml") case $cgi["poll_type"] when "Poll" Poll.new SITE when "TimePoll" TimePoll.new SITE end Dir.chdir("..") else $htmlout += "
ErrorThis poll already exists!
" end end $htmlout += "
Available Polls" $htmlout += "" Dir.glob("*/data.yaml").sort_by{|f| File.new(f).mtime }.reverse.collect{|f| f.gsub(/\/data\.yaml$/,'') }.each{|site| unless YAML::load_file("#{site}/data.yaml").hidden $htmlout += "" $htmlout += "" $htmlout += "" $htmlout += "" end } $htmlout += "
PollLast change
#{site}#{File.new(site + "/data.yaml").mtime.strftime('%d.%m, %H:%M')}
" $htmlout += "
" $htmlout += <change charset #{UTFASCII} CHARSET $htmlout += <Create new Poll
CREATE $htmlout += NOTICE $htmlout += "" $htmlout += "" $cgi.out("type" => TYPE ,"charset" => CHARSET,"cookie" => $utfcookie, "Cache-Control" => "no-cache"){$htmlout} end