From bf302820595fad3ab235a6caed617ab669d2849f Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Mon, 25 Oct 2010 14:41:23 +0200 Subject: more clean main page, new example tab --- example.cgi | 73 ++++++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 27 deletions(-) (limited to 'example.cgi') diff --git a/example.cgi b/example.cgi index 6ba9b02..d2bf9cd 100755 --- a/example.cgi +++ b/example.cgi @@ -19,39 +19,58 @@ # along with dudle. If not, see . # ############################################################################ -require "cgi" -$cgi = CGI.new -def _(string) - string -end -require "config" +if __FILE__ == $0 + +require "dudle" + +$d = Dudle.new + +if $cgi.include?("poll") -poll = nil -EXAMPLES.each{|p| - poll = p if $cgi["poll"] == p[:url] -} + poll = nil + EXAMPLES.each{|p| + poll = p if $cgi["poll"] == p[:url] + } -raise "Example not found: '#{$cgi["poll"]}'" unless poll + raise "Example not found: '#{$cgi["poll"]}'" unless poll -targeturl = poll[:url] + targeturl = poll[:url] -if poll[:new_environment] - targeturl += "_#{Time.now.to_i}" + if poll[:new_environment] + targeturl += "_#{Time.now.to_i}" - while (File.exists?(targeturl)) - targeturl += "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(poll[:url],targeturl) -end -if poll[:revno] - Dir.chdir(targeturl) - VCS.revert(poll[:revno]) - Dir.chdir("..") + $d.html.header["status"] = "REDIRECT" + $d.html.header["Cache-Control"] = "no-cache" + $d.html.header["Location"] = SITEURL + targeturl + +else + if defined?(EXAMPLES) + $d << "

" + _("Examples") + "

" + $d << _("If you want to play with the application, you may want to take a look at these example polls:") + $d << "
" + end + + $d << EXAMPLENOTICE end -$cgi.out({ - "status" => "REDIRECT", - "Cache-Control" => "no-cache", - "Location" => SITEURL + targeturl -}){""} + +$d.out + + +end -- cgit v1.2.3