aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bzr.rb4
-rw-r--r--config_sample.rb18
-rw-r--r--dudle.rb21
-rwxr-xr-xerror.cgi3
-rwxr-xr-xexample.cgi48
-rw-r--r--git.rb5
-rwxr-xr-xindex.cgi5
7 files changed, 89 insertions, 15 deletions
diff --git a/bzr.rb b/bzr.rb
index 83a4e4b..f2fe2db 100644
--- a/bzr.rb
+++ b/bzr.rb
@@ -62,4 +62,8 @@ class VCS
File.delete(tmpfile)
ret
end
+
+ def VCS.branch source, target
+ `#{BZRCMD} branch #{source} #{target}`
+ end
end
diff --git a/config_sample.rb b/config_sample.rb
index 0441d8c..d8a3993 100644
--- a/config_sample.rb
+++ b/config_sample.rb
@@ -53,10 +53,20 @@ BUGREPORTMAIL = "Benjamin.Kellermann@tu-dresden.de"
AUTO_SEND_REPORT = false
# Add some Example Polls to the start page
-EXAMPLES = {
- "event_schedule_example" => "coffeebreak",
- "normal_example" => "coffee"
-}
+# you may create those using the normal interface
+# and make them password protected afterwards
+# .htaccess and .htdigest are deleted after
+# example creation (defining password protected
+# examples is not possible therefore)
+EXAMPLES = [
+ {
+ :url => "coffeebreak",
+ :description => _("Event Schedule Poll")
+ },{
+ :url => "coffee",
+ :description => _("Normal Poll")
+ }
+]
# add the htmlcode in the Variable NOTICE to the startpage
# Example: displays all available Polls
diff --git a/dudle.rb b/dudle.rb
index 7cf1dc0..adc01b7 100644
--- a/dudle.rb
+++ b/dudle.rb
@@ -30,6 +30,14 @@ GetText.cgi=$cgi
GetText.output_charset = 'utf-8'
require "locale"
+if File.exists?("data.yaml") && !File.stat("data.yaml").directory?
+ $is_poll = true
+ GetText.bindtextdomain("dudle",:path => "../locale/")
+else
+ $is_poll = false
+ GetText.bindtextdomain("dudle",:path => "./locale/")
+end
+
$:.push("..")
require "date_locale"
@@ -41,13 +49,13 @@ require "charset"
class Dudle
attr_reader :html, :table, :urlsuffix, :css, :user_css, :title, :tab
def is_poll?
- @is_poll
+ $is_poll
end
def tabs(active_tab)
ret = "<div id='tabs'><ul id='tablist'>"
tabs = []
tabs << [_("Home"),@basedir]
- if @is_poll
+ if $is_poll
tabs << ["",""]
tabs += @usertabs
tabs << ["",""]
@@ -74,7 +82,7 @@ class Dudle
def inittabs
@customizetab = [_("Customize"),"customize.cgi"]
- if @is_poll
+ if $is_poll
# set-up tabs
@usertabs = [
[_("Poll"),"."],
@@ -99,12 +107,11 @@ class Dudle
@tab = File.basename($0)
@tab = "." if @tab == "index.cgi"
- if File.exists?("data.yaml") && !File.stat("data.yaml").directory?
+ if $is_poll
# log last read acces manually (no need to grep server logfiles)
File.open("last_read_access","w").close
- @is_poll = true
+ $is_poll = true
@basedir = ".."
- GetText.bindtextdomain("dudle",:path => "#{@basedir}/locale/")
@table = YAML::load(VCS.cat(self.revision, "data.yaml"))
@urlsuffix = File.basename(File.expand_path("."))
@title = @table.name
@@ -119,9 +126,7 @@ class Dudle
@html = HTML.new("dudle - #{@title} - #{@tabtitle}")
@html.header["Cache-Control"] = "no-cache"
else
- @is_poll = false
@basedir = "."
- GetText.bindtextdomain("dudle",:path => "#{@basedir}/locale/")
inittabs
@title = "dudle"
@html = HTML.new(@title)
diff --git a/error.cgi b/error.cgi
index 772a22d..dabac02 100755
--- a/error.cgi
+++ b/error.cgi
@@ -21,7 +21,6 @@
require "cgi"
$cgi = CGI.new
-require "config"
require 'gettext'
require 'gettext/cgi'
include GetText
@@ -31,6 +30,8 @@ require "locale"
GetText.bindtextdomain("dudle",:path => "./locale/")
+require "config"
+
require "html"
title = _("Error")
diff --git a/example.cgi b/example.cgi
new file mode 100755
index 0000000..4c7a970
--- /dev/null
+++ b/example.cgi
@@ -0,0 +1,48 @@
+#!/usr/bin/env ruby
+
+############################################################################
+# Copyright 2010 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 <http://www.gnu.org/licenses/>. #
+############################################################################
+
+require "cgi"
+$cgi = CGI.new
+def _(string)
+ string
+end
+require "config"
+
+source = nil
+EXAMPLES.each{|poll|
+ source = poll[:url] if $cgi["poll"] == poll[:url]
+}
+
+raise "Example not found" unless source
+target = "#{source}_#{Time.now.to_i}"
+
+while (File.exists?(target))
+ target += "I"
+end
+VCS.branch(source,target)
+`rm #{target}/.htaccess`
+`rm #{target}/.htdigest`
+
+$cgi.out({
+ "status" => "REDIRECT",
+ "Cache-Control" => "no-cache",
+ "Location" => SITEURL + target
+}){""}
diff --git a/git.rb b/git.rb
index 8777eae..a6b65fa 100644
--- a/git.rb
+++ b/git.rb
@@ -62,6 +62,11 @@ class VCS
File.delete(tmpfile)
ret
end
+
+ def VCS.branch source, target
+ `#{GITCMD} clone #{source} #{target}`
+ end
+
end
diff --git a/index.cgi b/index.cgi
index 59d24bd..99620a9 100755
--- a/index.cgi
+++ b/index.cgi
@@ -136,8 +136,9 @@ CREATE
$d << "<div class='textcolumn'><h2>" + _("Examples") + "</h2>"
$d << _("If you want to play around with the Tool, you may want to take a look at these Example Polls:")
$d << "<ul>"
- $d << "<li><a href='#{EXAMPLES["event_schedule_example"]}'>" + _("Event Schedule Poll") + "</a></li>" if EXAMPLES["event_schedule_example"]
- $d << "<li><a href='#{EXAMPLES["normal_example"]}'>" + _("Normal Poll") + "</a></li>" if EXAMPLES["normal_example"]
+ EXAMPLES.each{|poll|
+ $d << "<li><a href='example.cgi?poll=#{poll[:url]}'>#{poll[:description]}</a></li>" unless poll[:hidden]
+ }
$d << "</ul></div>"
end