From 1a748a02a0ce3c7dd0cde2851d7e1460698482c0 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Wed, 22 Sep 2010 23:48:52 +0200 Subject: even better example approach (possibility to specify revision number) --- example.cgi | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'example.cgi') 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 }){""} -- cgit v1.2.3