diff options
-rw-r--r-- | README | 2 | ||||
-rwxr-xr-x | atom.cgi | 10 | ||||
-rw-r--r-- | bzr.rb | 23 | ||||
-rw-r--r-- | config.rb | 7 | ||||
-rwxr-xr-x | index.cgi | 9 | ||||
-rw-r--r-- | overview.rb | 6 | ||||
-rw-r--r-- | participate.rb | 6 | ||||
-rw-r--r-- | poll.rb | 7 |
8 files changed, 52 insertions, 18 deletions
@@ -7,3 +7,5 @@ Requirements: Just place this application into a directory where cgi-scripts are evaluated. The webserver needs the permission to write into the directory! +You may look at config.rb to configure dudle. +However, in most cases it should run out-of-the-box. @@ -4,6 +4,10 @@ require "atom" require "yaml" require "cgi" +$cgi = CGI.new + +load "config.rb" + def readhistory dir log = `export LC_ALL=de_DE.UTF-8; bzr log -r -10.. "#{dir}"`.split("-"*60) log.collect!{|s| s.scan(/\nrevno: (.*)\ncommitter.*\n.*\ntimestamp: (.*)\nmessage:\n (.*)/).flatten} @@ -11,10 +15,6 @@ def readhistory dir log.collect!{|r,t,c| [r.to_i,DateTime.parse(t),c]} end -cgi = CGI.new - -SITEURL = "http://#{cgi.server_name}#{cgi.script_name.gsub(/atom.cgi$/,"")}" - feed = Atom::Feed.new if File.exist?("data.yaml") olddir = File.expand_path(".") @@ -75,4 +75,4 @@ else end -cgi.out("type" => "application/atom+xml"){ feed.to_xml } +$cgi.out("type" => "application/atom+xml"){ feed.to_xml } @@ -0,0 +1,23 @@ +def vcs_init + `bzr init` +end + +def vcs_add(file) + `bzr add #{file}` +end + +def vcs_revno + `bzr revno`.to_i +end + +def vcs_cat revision, file + `export LC_ALL=de_DE.UTF-8;bzr cat -r #{revision} #{file}` +end + +def vcs_history + `export LC_ALL=de_DE.UTF-8; bzr log --forward`.split("-"*60) +end + +def vcs_commit comment + `export LC_ALL=de_DE.UTF-8; bzr commit -m '#{comment}'` +end diff --git a/config.rb b/config.rb new file mode 100644 index 0000000..3e2916b --- /dev/null +++ b/config.rb @@ -0,0 +1,7 @@ +# Choose your favorite version control system +load "bzr.rb" + +# Change this if the url is not determined correctly +SITEURL = "http://#{$cgi.server_name}#{$cgi.script_name.gsub(/[^\/]*$/,"")}" + + @@ -2,14 +2,12 @@ require "yaml" require "cgi" +load "config.rb" + if __FILE__ == $0 $cgi = CGI.new -TYPE = "text/html" -CHARSET = "utf-8" -#CONTENTTYPE = "application/xhtml+xml; charset=utf-8" - utfcookie = CGI::Cookie.new("utf", "true") utfcookie.path = "/" if ($cgi.include?("utf") || $cgi.cookies["utf"][0]) && !$cgi.include?("ascii") @@ -54,6 +52,9 @@ else load "overview.rb" end +TYPE = "text/html" +#TYPE = "application/xhtml+xml" +CHARSET = "utf-8" $cgi.out("type" => TYPE ,"charset" => CHARSET,"cookie" => utfcookie, "Cache-Control" => "no-cache"){$htmlout} end diff --git a/overview.rb b/overview.rb index a9b8709..6990bda 100644 --- a/overview.rb +++ b/overview.rb @@ -14,11 +14,11 @@ if $cgi.include?("create_poll") unless File.exist?(SITE) Dir.mkdir(SITE) Dir.chdir(SITE) - `bzr init` + vcs_init File.symlink("../index.cgi","index.cgi") File.symlink("../atom.cgi","atom.cgi") File.open("data.yaml","w").close - `bzr add data.yaml` + vcs_add("data.yaml") hidden = ($cgi["hidden"] == "true") case $cgi["poll_type"] when "Poll" @@ -33,7 +33,7 @@ if $cgi.include?("create_poll") <legend>Info</legend> Poll #{SITE} created successfull! <br /> -Please remember the url (<a href="#{SITE}">#{$cgi.server_name}#{$cgi.script_name.gsub(/index.cgi$/,"")}#{SITE}</a>) while it will not be visible here. +Please remember the url (<a href="#{SITE}">#{SITEURL}#{SITE}</a>) while it will not be visible here. </fieldset> HIDDENINFO end diff --git a/participate.rb b/participate.rb index 7022cc7..fc48e0a 100644 --- a/participate.rb +++ b/participate.rb @@ -6,7 +6,7 @@ Dir.chdir(olddir) if $cgi.include?("revision") REVISION=$cgi["revision"].to_i - table = YAML::load(`export LC_ALL=de_DE.UTF-8; bzr cat -r #{REVISION} data.yaml`) + table = YAML::load(vcs_cat(REVISION, "data.yaml")) else table = YAML::load_file("data.yaml") end @@ -50,9 +50,9 @@ table.delete_comment($cgi["delete_comment"].to_i) if $cgi.include?("delete_comme $htmlout += table.to_html -MAXREV=`bzr revno`.to_i +MAXREV=vcs_revno REVISION=MAXREV unless defined?(REVISION) -log = `export LC_ALL=de_DE.UTF-8; bzr log --forward`.split("-"*60) +log = vcs_history log.collect!{|s| s.scan(/\nrevno:.*\ncommitter.*\n.*\ntimestamp: (.*)\nmessage:\n (.*)/).flatten} log.shift log.collect!{|t,c| [DateTime.parse(t),c]} @@ -43,10 +43,11 @@ class Poll ret += "<tr>\n" ret += "<td class='name'>#{participant}</td>\n" @head.sort.each{|columntitle,columndescription| - klasse = poll[columntitle].nil? ? "undecided" : poll[columntitle] - case poll[columntitle] + klasse = poll[columntitle] + case klasse when nil value = UNKNOWN + klasse = "undecided" when "yes" value = YES when "no" @@ -188,7 +189,7 @@ END out << self.to_yaml out.chmod(0660) end - `export LC_ALL=de_DE.UTF-8; bzr commit -m '#{CGI.escapeHTML(comment)}'` + vcs_commit(CGI.escapeHTML(comment)) end def add_comment name, comment @comment << [Time.now, CGI.escapeHTML(name.strip), CGI.escapeHTML(comment.strip).gsub("\r\n","<br />")] |