#!/usr/bin/env ruby ############################################################################ # Copyright 2009 Benjamin Kellermann # # # # This file is part of dudle. # # # # Dudle is free software: you can redistribute it and/or modify it under # # the terms of the GNU Affero General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # Dudle is distributed in the hope that it will be useful, but WITHOUT ANY # # WARRANTY; without even the implied warranty of MERCHANTABILITY or # # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public # # License for more details. # # # # You should have received a copy of the GNU Affero General Public License # # along with dudle. If not, see . # ############################################################################ require "yaml" require "cgi" if __FILE__ == $0 $cgi = CGI.new if File.exists?("config.rb") load "config.rb" else puts "\nPlease configure me in the file config.rb" exit end require "poll" require "html" $html = HTML.new("dudle") load "charset.rb" $html.add_css("dudle.css") $htlm.add_atom("atom.cgi") if File.exists?("atom.cgi") $html << "

dudle

" if $cgi.include?("create_poll") SITE=$cgi["create_poll"] if SITE.include?("/") createnotice = "
Error: The character '/' is not allowed.
" elsif File.exist?(SITE) createnotice = "
Error: This poll already exists!
" else Dir.mkdir(SITE) Dir.chdir(SITE) VCS.init File.symlink("../participate.rb","index.cgi") VCS.add("index.cgi") ["atom","customize", "history", "edit_columns","access_control", "delete_poll"].each{|f| File.symlink("../#{f}.rb","#{f}.cgi") VCS.add("#{f}.cgi") } ["data.yaml",".htaccess",".htdigest"].each{|f| File.open(f,"w").close VCS.add(f) } Poll.new(SITE,$cgi["poll_type"]) Dir.chdir("..") escapedsite = SITEURL + CGI.escapeHTML(CGI.escape(SITE)) + "/edit_columns.cgi" escapedsite.gsub!("+"," ") $html.header["status"] = "REDIRECT" $html.header["Location"] = escapedsite $html << "The poll was created successfully. The link to your new poll is:
#{escapedsite}" end end unless $html.header["status"] == "REDIRECT" $html << <Create New Poll
Type:
CREATE $html << NOTICE end $html.out($cgi) end