diff options
-rw-r--r-- | config_sample.rb | 12 | ||||
-rwxr-xr-x | example.cgi | 31 | ||||
-rw-r--r-- | git.rb | 5 |
3 files changed, 34 insertions, 14 deletions
diff --git a/config_sample.rb b/config_sample.rb index d8a3993..69263c8 100644 --- a/config_sample.rb +++ b/config_sample.rb @@ -61,10 +61,16 @@ AUTO_SEND_REPORT = false EXAMPLES = [ { :url => "coffeebreak", - :description => _("Event Schedule Poll") + :description => _("Event Schedule Poll"), + :new_environment => true, },{ :url => "coffee", - :description => _("Normal Poll") + :description => _("Normal Poll"), + :revno => 34 + },{ + :url => "Cheater", + :description => "Cheater", + :hidden => true } ] @@ -81,7 +87,7 @@ Dir.glob("*/data.yaml").sort_by{|f| File.new(f).mtime }.reverse.collect{|f| f.gsub(/\/data\.yaml$/,'') }.each{|site| notice += <<NOTICE -<tr> +<tr class='participantrow'> <td class='polls'><a href='./#{CGI.escapeHTML(site).gsub("'","%27")}/'>#{CGI.escapeHTML(site)}</a></td> <td class='mtime'>#{File.new(site + "/data.yaml").mtime.strftime('%d.%m, %H:%M')}</td> </tr> diff --git a/example.cgi b/example.cgi index 4c7a970..388fa87 100755 --- a/example.cgi +++ b/example.cgi @@ -26,23 +26,32 @@ def _(string) end require "config" -source = nil -EXAMPLES.each{|poll| - source = poll[:url] if $cgi["poll"] == poll[:url] +poll = nil +EXAMPLES.each{|p| + poll = p if $cgi["poll"] == p[:url] } -raise "Example not found" unless source -target = "#{source}_#{Time.now.to_i}" +raise "Example not found" unless poll -while (File.exists?(target)) - target += "I" +targeturl = poll[:url] + +if poll[:new_environment] + targeturl += "_#{Time.now.to_i}" + + while (File.exists?(targeturl)) + targeturl += "I" + end + VCS.branch(poll[:url],targeturl) +end + +if poll[:revno] + Dir.chdir(targeturl) + VCS.revert(poll[:revno]) + Dir.chdir("..") end -VCS.branch(source,target) -`rm #{target}/.htaccess` -`rm #{target}/.htdigest` $cgi.out({ "status" => "REDIRECT", "Cache-Control" => "no-cache", - "Location" => SITEURL + target + "Location" => SITEURL + targeturl }){""} @@ -67,6 +67,11 @@ class VCS `#{GITCMD} clone #{source} #{target}` end + def VCS.revert revno + revhash = `#{GITCMD} log --format="%H"`.split("\n").reverse[revno-1] + `#{GITCMD} checkout #{revhash} .` + VCS.commit("Reverted Poll to version #{revno}") + end end |