From a426a6ca80e633fbf5e548ec78979d9d35e9dcfb Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Mon, 27 Sep 2010 00:00:16 +0200 Subject: error pages have unified look --- authorization_required.cgi | 30 +++++++++--------------------- dudle.rb | 27 +++++++++++++++------------ edit_columns.rb | 2 +- error.cgi | 35 +++++------------------------------ history.rb | 2 +- not_found.cgi | 17 ++++------------- 6 files changed, 35 insertions(+), 78 deletions(-) diff --git a/authorization_required.cgi b/authorization_required.cgi index a251fdb..0511251 100755 --- a/authorization_required.cgi +++ b/authorization_required.cgi @@ -21,12 +21,11 @@ require "dudle" - if $cgi.include?("poll") Dir.chdir($cgi["poll"]) $is_poll = true - $d = Dudle.new + $d = Dudle.new(:hide_lang_chooser => true) $d << "

" + _("Authorization Required") + "

" case $cgi["user"] @@ -39,29 +38,18 @@ if $cgi.include?("poll") $d.out else - GetText.bindtextdomain("dudle",:path => "./locale/") - title = _("Authorization Required") - $h = HTML.new(title) - $h.add_css("/#{DEFAULT_CSS}","default",true) + $d = Dudle.new(:title => _("Authorization Required"), :hide_lang_chooser => true) returnstr = _("Return to dudle home and Schedule a new Poll") authstr = _("You have to authorize in order to request this page!") - $h << < -
-
-
-
-

#{title}

-

#{authstr}

- -

-
-
+ $d << <#{authstr}

+ +

END - $h.out($cgi) + $d.out end diff --git a/dudle.rb b/dudle.rb index adc01b7..bc2eca9 100644 --- a/dudle.rb +++ b/dudle.rb @@ -32,10 +32,10 @@ require "locale" if File.exists?("data.yaml") && !File.stat("data.yaml").directory? $is_poll = true - GetText.bindtextdomain("dudle",:path => "../locale/") + GetText.bindtextdomain("dudle", :path => Dir.pwd + "/../locale/") else $is_poll = false - GetText.bindtextdomain("dudle",:path => "./locale/") + GetText.bindtextdomain("dudle", :path => Dir.pwd + "/locale/") end $:.push("..") @@ -101,8 +101,9 @@ class Dudle @requested_revision || VCS.revno end - def initialize(revision=nil) - @requested_revision = revision + def initialize(params = {:revision => nil, :title => nil, :hide_lang_chooser => nil}) + @requested_revision = params[:revision] + @hide_lang_chooser = params[:hide_lang_chooser] @cgi = $cgi @tab = File.basename($0) @tab = "." if @tab == "index.cgi" @@ -128,7 +129,7 @@ class Dudle else @basedir = "." inittabs - @title = "dudle" + @title = params[:title] || "dudle" @html = HTML.new(@title) end @@ -223,13 +224,15 @@ READY ["cs", "Česky"], ["sv", "Svenska"] ] - lang.each{|short,long| - if short == GetText.locale.language - @html << long - else - @html << "#{long}" - end - } + unless @hide_lang_chooser + lang.each{|short,long| + if short == GetText.locale.language + @html << long + else + @html << "#{long}" + end + } + end @html << "" # languageChooser @html << "" # content diff --git a/edit_columns.rb b/edit_columns.rb index 7369311..10aaebb 100755 --- a/edit_columns.rb +++ b/edit_columns.rb @@ -27,7 +27,7 @@ revbeforeedit = VCS.revno if $cgi.include?("undo_revision") && $cgi["undo_revision"].to_i < revbeforeedit undorevision = $cgi["undo_revision"].to_i - $d = Dudle.new(undorevision) + $d = Dudle.new(:revision => undorevision) comment = $cgi.include?("redo") ? "Redo changes" : "Reverted Poll" $d.table.store("#{comment} to version #{undorevision}") else diff --git a/error.cgi b/error.cgi index dabac02..d6ee9c3 100755 --- a/error.cgi +++ b/error.cgi @@ -19,32 +19,8 @@ # along with dudle. If not, see . # ############################################################################ -require "cgi" -$cgi = CGI.new -require 'gettext' -require 'gettext/cgi' -include GetText -GetText.cgi=$cgi -GetText.output_charset = 'utf-8' -require "locale" - -GetText.bindtextdomain("dudle",:path => "./locale/") - -require "config" - -require "html" - -title = _("Error") -$h = HTML.new(title) -$h.add_css("/#{DEFAULT_CSS}","default",true) -$h << < -
-
-
-
-

#{title}

-END +require "dudle" +$d = Dudle.new(:title => _("Error"), :hide_lang_chooser => true) def urlescape(str) CGI.escapeHTML(CGI.escape(str).gsub("+","%20")) @@ -69,19 +45,18 @@ end errormessagebody = _("Hi!\n\nI found a bug in your application at %{urlofsite}.\nI did the following:\n\n\n\n\nI am using \n%{errormessage}\nYours,\n") % {:errormessage => errormessage, :urlofsite => SITEURL} subject = _("Bug in dudle") - $h << _("An error occured while executing dudle.
Please send an error report, including your browser, operating system, and what you did to %{admin}.") % {:admin => "#{BUGREPORTMAIL}"} + $d << _("An error occured while executing dudle.
Please send an error report, including your browser, operating system, and what you did to %{admin}.") % {:admin => "#{BUGREPORTMAIL}"} if (errorstr) errorheadstr = _("Please include the following as well:") - $h << < #{errorheadstr}
#{CGI.escapeHTML(errorstr)}
ERROR end -$h << "
" -$h.out($cgi) +$d.out if AUTO_SEND_REPORT diff --git a/history.rb b/history.rb index e087467..3fa06c0 100755 --- a/history.rb +++ b/history.rb @@ -24,7 +24,7 @@ load "../dudle.rb" if $cgi.include?("revision") revno=$cgi["revision"].to_i - $d = Dudle.new(revno) + $d = Dudle.new(:revision => revno) versiontitle = _("Poll of Version %{revisionnumber}") % {:revisionnumber => revno} else revno = VCS.revno diff --git a/not_found.cgi b/not_found.cgi index a22d081..7241210 100755 --- a/not_found.cgi +++ b/not_found.cgi @@ -20,12 +20,11 @@ ############################################################################ require "dudle" -GetText.bindtextdomain("dudle",:path => "./locale/") +$d = Dudle.new(:title => "foo", :hide_lang_chooser => true) title = _("Poll Not Found") -$h = HTML.new(title) -$h.add_css("/#{DEFAULT_CSS}","default",true) + str = [_("The requested Poll was not found."), _("There are several reasons, why a Poll is deleted:"), _("Somebody klicked on “Delete Poll” and deleted the poll manually."), @@ -33,13 +32,7 @@ str = [_("The requested Poll was not found."), _("If you think, the deletion was done by error, please contact the adminsistrator of the system."), _("Return to dudle home and Schedule a new Poll")] -$h << < -
-
-
-
-

#{title}

+$d << < #{str[0]}

@@ -54,9 +47,7 @@ $h << <#{str[5]}

-
-
END -$h.out($cgi) +$d.out#($cgi) -- cgit v1.2.3