diff options
-rwxr-xr-x | authorization_required.cgi | 30 | ||||
-rw-r--r-- | dudle.rb | 27 | ||||
-rwxr-xr-x | edit_columns.rb | 2 | ||||
-rwxr-xr-x | error.cgi | 35 | ||||
-rwxr-xr-x | history.rb | 2 | ||||
-rwxr-xr-x | 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 << "<h2>" + _("Authorization Required") + "</h2>" 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 << <<END - <div id='header1'></div> - <div id='header2'></div> - <div id='header3'></div> - <div id='main'> - <div id='content'> - <h1>#{title}</h1> - <p>#{authstr}</p> - <ul> - <li><a href='#{SITEURL}'>#{returnstr}</a></li> - </ul> - </p> - </div> - </div> + $d << <<END + <p>#{authstr}</p> + <ul> + <li><a href='#{SITEURL}'>#{returnstr}</a></li> + </ul> + </p> END - $h.out($cgi) + $d.out end @@ -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 << "<a href='?lang=#{short}'>#{long}</a>" - end - } + unless @hide_lang_chooser + lang.each{|short,long| + if short == GetText.locale.language + @html << long + else + @html << "<a href='?lang=#{short}'>#{long}</a>" + end + } + end @html << "</div>" # languageChooser @html << "</div>" # 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 @@ -19,32 +19,8 @@ # along with dudle. If not, see <http://www.gnu.org/licenses/>. # ############################################################################ -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 << <<END -<div id='header1'></div> -<div id='header2'></div> -<div id='header3'></div> -<div id='main'> -<div id='content'> -<h1>#{title}</h1> -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<please describe what you did>\n<e.g., I wanted to sent a comment to the poll.>\n\nI am using <please state your browser and operating system>\n%{errormessage}\nYours,\n") % {:errormessage => errormessage, :urlofsite => SITEURL} subject = _("Bug in dudle") - $h << _("An error occured while executing dudle.<br/>Please send an error report, including your browser, operating system, and what you did to %{admin}.") % {:admin => "<a href='mailto:#{BUGREPORTMAIL}?subject=#{urlescape(subject)}&body=#{urlescape(errormessagebody)}'>#{BUGREPORTMAIL}</a>"} + $d << _("An error occured while executing dudle.<br/>Please send an error report, including your browser, operating system, and what you did to %{admin}.") % {:admin => "<a href='mailto:#{BUGREPORTMAIL}?subject=#{urlescape(subject)}&body=#{urlescape(errormessagebody)}'>#{BUGREPORTMAIL}</a>"} if (errorstr) errorheadstr = _("Please include the following as well:") - $h << <<ERROR + $d << <<ERROR <br/> #{errorheadstr} <pre style='background:#DDD;padding : 1em'>#{CGI.escapeHTML(errorstr)}</pre> ERROR end -$h << "</div></div>" -$h.out($cgi) +$d.out if AUTO_SEND_REPORT @@ -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 << <<END -<div id='header1'></div> -<div id='header2'></div> -<div id='header3'></div> -<div id='main'> - <div id='content'> - <h1>#{title}</h1> +$d << <<END <p> #{str[0]} </p> @@ -54,9 +47,7 @@ $h << <<END <li><a href='#{SITEURL}'>#{str[5]}</a></li> </ul> </p> - </div> -</div> END -$h.out($cgi) +$d.out#($cgi) |