aboutsummaryrefslogtreecommitdiff
path: root/example.cgi
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2010-10-25 14:41:23 +0200
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2010-10-25 14:41:23 +0200
commitbf302820595fad3ab235a6caed617ab669d2849f (patch)
tree79f3589b8039da92cb3a0638b64e1211a912e6fe /example.cgi
parent3cdd4c38782236482074322168adfa1e98870960 (diff)
more clean main page, new example tab
Diffstat (limited to 'example.cgi')
-rwxr-xr-xexample.cgi73
1 files changed, 46 insertions, 27 deletions
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 <http://www.gnu.org/licenses/>. #
############################################################################
-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 << "<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:")
+ $d << "<ul>"
+ EXAMPLES.each{|poll|
+ $d << "<li><a href='example.cgi?poll=#{poll[:url]}'>#{poll[:description]}</a></li>" unless poll[:hidden]
+ }
+ $d << "</ul></div>"
+ end
+
+ $d << EXAMPLENOTICE
end
-$cgi.out({
- "status" => "REDIRECT",
- "Cache-Control" => "no-cache",
- "Location" => SITEURL + targeturl
-}){""}
+
+$d.out
+
+
+end