aboutsummaryrefslogtreecommitdiff
path: root/example.cgi
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2016-05-20 09:57:47 +0200
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2016-05-20 09:57:47 +0200
commite8c76151d9435c454c311477bc0bb233a32d7f90 (patch)
tree73d6efab7af521947e90d60561c626467267e050 /example.cgi
parenta26bc5eda992e7262d9be0eb4fa204ea674e0eed (diff)
do not raise an exception if example is not found
Diffstat (limited to 'example.cgi')
-rwxr-xr-xexample.cgi41
1 files changed, 24 insertions, 17 deletions
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 << "<div class='error'>"
+ $d << _("Example not found: %{example}") % { :example => CGI.escapeHTML($cgi["poll"])}
+ $d << "</div>"
+ end
+end
-else
+unless $d.html.header["status"] == "REDIRECT"
unless $conf.examples.empty?
$d << "<div class='textcolumn'><h2>" + _("Examples") + "</h2>"
$d << _("If you want to play with the application, you may want to take a look at these example polls:")