#!/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 . # ############################################################################ if __FILE__ == $0 if File.exists?("config.rb") require "dudle" else puts "\nPlease configure me in the file config.rb" exit end $d = Dudle.new("Home") if $cgi.include?("create_poll") && $cgi.include?("poll_url") POLLNAME=$cgi["create_poll"] if $cgi["poll_url"] == "" POLLURL = `pwgen -1`.chomp else POLLURL=$cgi["poll_url"] end if !(POLLURL =~ /^[\w\-_]*$/) createnotice = "Custom address may only contain letters, numbers, and dashes." elsif File.exist?(POLLURL) createnotice = "A Poll with this address already exists." else Dir.mkdir(POLLURL) Dir.chdir(POLLURL) VCS.init File.symlink("../participate.rb","index.cgi") VCS.add("index.cgi") ["atom","customize", "history", "help", "edit_columns","access_control", "delete_poll", "invite_participants"].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(POLLNAME,$cgi["poll_type"]) Dir.chdir("..") $d.html.header["status"] = "REDIRECT" $d.html.header["Cache-Control"] = "no-cache" $d.html.header["Location"] = SITEURL + POLLURL+ "/edit_columns.cgi" $d << "The poll was created successfully. The link to your new poll is:
#{POLLURL}" end end unless $d.html.header["status"] == "REDIRECT" $d << <Create New Poll
CREATE if defined?(createnotice) $d << < NOTICE end $d << < CREATE $d << NOTICE end $d.out($cgi) end
Type:
Custom address (optional): May contain letters, numbers, and dashes.
#{createnotice}