aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2010-01-28 13:47:30 +0100
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2010-01-28 13:47:30 +0100
commitf6974add6878b95b592865c3ad640bdc48cc78ec (patch)
tree7c1de88ea7eca1f7d72b43b54367674e9f949273
parent90a6b261d9c7f1d6dd1a7007a213d4426436b99a (diff)
Page included for error reporting
-rw-r--r--.htaccess2
-rw-r--r--config_sample.rb12
-rwxr-xr-xerror.cgi81
3 files changed, 95 insertions, 0 deletions
diff --git a/.htaccess b/.htaccess
index 01447f6..b47916b 100644
--- a/.htaccess
+++ b/.htaccess
@@ -3,3 +3,5 @@
satisfy all
ErrorDocument 403 "You are not allowed to access .ht* files!"
</Files>
+
+ErrorDocument 500 /error.cgi
diff --git a/config_sample.rb b/config_sample.rb
index 1dc518d..ed52300 100644
--- a/config_sample.rb
+++ b/config_sample.rb
@@ -26,6 +26,18 @@ load "git.rb"
# Change this if the url is not determined correctly
SITEURL = "http://#{$cgi.server_name}#{$cgi.script_name.gsub(/[^\/]*$/,"")}"
+# If you want to encourage the user to send bug reports, state the errorlog,
+# which you have configured in your apache conf with the ErrorLog directive.
+# In addition, you can change the email address to yours, if you want to
+# receive the mails instead of me (the developer).
+# You would do me a favor, if you configure this with my address, however,
+# if you do not want people to read parts of your error log, leave the
+# ERRORLOG variable unset!
+# Make sure, that your apache can read this file
+# (which usually is not the case for /var/log/apache2/*)
+#ERRORLOG = "/var/log/dudle_error.log"
+BUGREPORTMAIL = "Benjamin.Kellermann@tu-dresden.de"
+
# Add some Example Polls to the start page
EXAMPLES = {
"event_schedule_example" => "coffeebreak",
diff --git a/error.cgi b/error.cgi
new file mode 100755
index 0000000..c74e80b
--- /dev/null
+++ b/error.cgi
@@ -0,0 +1,81 @@
+#!/usr/bin/env ruby
+
+############################################################################
+# Copyright 2009,2010 Benjamin Kellermann #
+# #
+# This file is part of dudle. #
+# #
+# Dudle is free software: you can redistribute it and/or modify it under #
+# the terms of the GNU Affero General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# Dudle is distributed in the hope that it will be useful, but WITHOUT ANY #
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public #
+# License for more details. #
+# #
+# You should have received a copy of the GNU Affero General Public License #
+# along with dudle. If not, see <http://www.gnu.org/licenses/>. #
+############################################################################
+
+require "dudle"
+
+$d = Dudle.new
+
+def urlescape(str)
+ CGI.escapeHTML(CGI.escape(str).gsub("+","%20"))
+end
+
+errormessagebody = <<MESSAGE
+Hi!
+
+I found a bug in your application at #{SITEURL}.
+I did the following:
+
+<please describe what you did>
+<e.g., I wanted to sent a comment to the poll.>
+
+I am using <please state your browser and operating system>
+MESSAGE
+
+if defined?(ERRORLOG)
+ begin
+ a = File.open(ERRORLOG,"r").to_a
+ rescue Exception => e
+ errorstr = "Exception while opening #{ERRORLOG}:\n#{e}"
+ else
+ s = [a.pop]
+ s << a.pop while s.last.scan(/^\[([^\]]*)\] \[/).flatten[0] == a.last.scan(/^\[([^\]]*)\] \[/).flatten[0]
+ errorstr = s.reverse.join
+ end
+
+ errormessagebody += <<MESSAGE
+
+The following error was printed:
+#{errorstr}
+MESSAGE
+
+end
+errormessagebody += <<MESSAGE
+
+Yours,
+
+MESSAGE
+
+ $d << <<ERROR
+An error occured while executing dudle.<br/>
+Please report you browser, operating system, and what you did to
+<a href='mailto:#{BUGREPORTMAIL}?subject=#{urlescape("Bug in dudle")}&amp;body=#{urlescape(errormessagebody)}'>#{BUGREPORTMAIL}</a>.
+ERROR
+
+if (errorstr)
+
+ $d << <<ERROR
+<br/>
+Please include the following as well:
+<pre style='background:#DDD;padding : 1em'>#{errorstr}</pre>
+ERROR
+end
+
+$d.out