From e8c76151d9435c454c311477bc0bb233a32d7f90 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Fri, 20 May 2016 09:57:47 +0200 Subject: do not raise an exception if example is not found --- example.cgi | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) (limited to 'example.cgi') diff --git a/example.cgi b/example.cgi index d9a0f5e..2137514 100755 --- a/example.cgi +++ b/example.cgi @@ -32,30 +32,37 @@ if $cgi.include?("poll") poll = p if $cgi["poll"] == p[:url] } - raise "Example not found: '#{$cgi["poll"]}'" unless poll + if 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 - VCS.branch(poll[:url],targeturl) - end - if poll[:revno] - Dir.chdir(targeturl) - VCS.revert(poll[:revno]) - Dir.chdir("..") - end + if poll[:revno] + Dir.chdir(targeturl) + VCS.revert(poll[:revno]) + Dir.chdir("..") + end - $d.html.header["status"] = "REDIRECT" - $d.html.header["Cache-Control"] = "no-cache" - $d.html.header["Location"] = $conf.siteurl + targeturl + $d.html.header["status"] = "REDIRECT" + $d.html.header["Cache-Control"] = "no-cache" + $d.html.header["Location"] = $conf.siteurl + targeturl + + else + $d << "
" + $d << _("Example not found: %{example}") % { :example => CGI.escapeHTML($cgi["poll"])} + $d << "
" + end +end -else +unless $d.html.header["status"] == "REDIRECT" unless $conf.examples.empty? $d << "

" + _("Examples") + "

" $d << _("If you want to play with the application, you may want to take a look at these example polls:") -- cgit v1.2.3