diff options
author | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2019-01-07 18:44:03 +0100 |
---|---|---|
committer | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2019-01-07 18:44:03 +0100 |
commit | eabdbd545ed474ebcf63c3e839f2e50e40ddb379 (patch) | |
tree | 196694c2ca3482ac0381a0bd0e9462fe9168e9a3 | |
parent | 571d02b554a615397adc7f66b1a2e1fd8202c58d (diff) |
remove useless space
-rw-r--r-- | README.md | 2 | ||||
-rwxr-xr-x | access_control.rb | 6 | ||||
-rwxr-xr-x | atom.rb | 6 | ||||
-rw-r--r-- | charset.rb | 2 | ||||
-rw-r--r-- | classic.css | 28 | ||||
-rw-r--r-- | config_defaults.rb | 2 | ||||
-rw-r--r-- | config_sample.rb | 10 | ||||
-rwxr-xr-x[l---------] | customize.cgi | 133 | ||||
-rwxr-xr-x | customize.rb | 2 | ||||
-rw-r--r-- | date_locale.rb | 600 | ||||
-rw-r--r-- | default.css | 34 | ||||
-rwxr-xr-x | delete_poll.rb | 2 | ||||
-rw-r--r-- | dudle.rb | 6 | ||||
-rwxr-xr-x | edit_columns.rb | 8 | ||||
-rwxr-xr-x | error.cgi | 2 | ||||
-rwxr-xr-x | example.cgi | 4 | ||||
-rw-r--r-- | hash.rb | 2 | ||||
-rw-r--r-- | html.rb | 4 | ||||
-rwxr-xr-x | index.cgi | 2 | ||||
-rw-r--r-- | log.rb | 20 | ||||
-rwxr-xr-x | participate.rb | 4 | ||||
-rw-r--r-- | poll.rb | 34 | ||||
-rw-r--r-- | pollhead.rb | 4 | ||||
-rw-r--r-- | print.css | 14 | ||||
-rw-r--r-- | vcs_test.rb | 4 |
25 files changed, 533 insertions, 402 deletions
@@ -111,7 +111,7 @@ make # will launch poedit if new french strings are to be translated ``` * To add a new translation - - first add a new folder for your language under $DUDLE_HOME_FOLDER/locale, + - first add a new folder for your language under $DUDLE_HOME_FOLDER/locale, - copy the dudle.pot file into your folder and name it dudle.po - translate sentences and phrases in your dudle.po file - add an entry for your language in dudle/dudle.rb at line 245 diff --git a/access_control.rb b/access_control.rb index 62a6c38..6063324 100755 --- a/access_control.rb +++ b/access_control.rb @@ -29,7 +29,7 @@ $d = Dudle.new acusers = {} -File.open(".htdigest","r").each_line{|l| +File.open(".htdigest","r").each_line{|l| user,realm = l.scan(/^(.*):(.*):.*$/).flatten acusers[user] = realm } @@ -142,7 +142,7 @@ if $cgi.include?("ac_user") else if $cgi.include?("ac_create") add_to_htdigest(user,$cgi["ac_password0"]) - acusers[user] = true + acusers[user] = true write_htaccess(acusers) end @@ -220,7 +220,7 @@ $d.html << <<AC <tr> <td></td> <td> - #{acswitchbutton} + #{acswitchbutton} </td> </tr> </table> @@ -28,7 +28,7 @@ require "time" $cgi = CGI.new -feed = Atom::Feed.new +feed = Atom::Feed.new olddir = File.expand_path(".") Dir.chdir("..") def _(string) @@ -47,8 +47,8 @@ feed.authors << Atom::Person.new(:name => 'dudle automatic notificator') feed.links << Atom::Link.new(:href => $conf.siteurl + "atom.cgi", :rel => "self") log = VCS.history -log.reverse_each {|l| - feed.entries << Atom::Entry.new do |e| +log.reverse_each {|l| + feed.entries << Atom::Entry.new do |e| e.title = l.comment # e.content = Atom::Content::Xhtml.new("<p><a href=\"#{$conf.siteurl}history.cgi?revision=#{l.rev}\">permalink</a>, <a href='#{$conf.siteurl}' >current version</a></p>") e.links << Atom::Link.new(:href => "#{$conf.siteurl}history.cgi?revision=#{l.rev}") @@ -22,7 +22,7 @@ $USEUTF = true $USEUTF = false if $cgi.user_agent =~ /.*MSIE [56]\..*/ $USEUTF = false if $cgi.cookies["ascii"][0] $USEUTF = true if $cgi.include?("utf") -$USEUTF = false if $cgi.include?("ascii") +$USEUTF = false if $cgi.include?("ascii") if $USEUTF NOSORT = CGI.escapeHTML('▾▴') diff --git a/classic.css b/classic.css index f9ecdd7..1054541 100644 --- a/classic.css +++ b/classic.css @@ -57,7 +57,7 @@ td.name { } input.delete, input.toggle{ - border: none; + border: none; padding: 0px; cursor: pointer; background-color: #000; @@ -75,7 +75,7 @@ th.weekday{ input.chosen { background-color:#0F0; } input.navigation, input.disabled, input.chosen, input.notchosen { - border-width: 1px; + border-width: 1px; border-style: solid; border-color: black; padding: 0px; @@ -84,7 +84,7 @@ input.navigation, input.disabled, input.chosen, input.notchosen { } input.navigation { - color: white; + color: white; background-color: black; } .navigation, .delete, .toggle{ @@ -94,8 +94,8 @@ input.navigation { input.disabled { background-color:#DDD;color:#BBB} -table { - border: none; +table { + border: none; } table.calendarday { @@ -143,7 +143,7 @@ td { overflow: auto; } -tr.participantrow, tr#add_participant, tr#summary { +tr.participantrow, tr#add_participant, tr#summary { background-color:Silver; } @@ -155,7 +155,7 @@ tr.participantrow:hover { background: #AAA; } -th { +th { padding-left: 3px; padding-right: 3px; color: white; @@ -168,7 +168,7 @@ th a{ text-decoration: none; } -td.date { +td.date { color: Gray; } @@ -178,7 +178,7 @@ html { } #main{ margin-left: auto; - margin-right:auto; + margin-right:auto; } #content { background: white; @@ -236,15 +236,15 @@ div#tabs a{ } li.active_tab{ - border-style: solid solid none; + border-style: solid solid none; padding-bottom: 1px; } -li.nonactive_tab{ +li.nonactive_tab{ border-style: solid; } -li.nonactive_tab a:hover { +li.nonactive_tab a:hover { background: #CCC; } @@ -267,8 +267,8 @@ h1 { text-align: center; } -div.comment { - margin-top: 1ex; +div.comment { + margin-top: 1ex; line-height: 1.4em; } diff --git a/config_defaults.rb b/config_defaults.rb index e09003c..532231b 100644 --- a/config_defaults.rb +++ b/config_defaults.rb @@ -39,7 +39,7 @@ $conf.siteurl = "#{protocol}://#{$cgi.server_name}#{port}#{$cgi.script_name.gsub $conf.breadcrumbs = [] $conf.header = [] $conf.footer = [] -6.times{|i| +6.times{|i| $conf.header << "<div id='header#{i}'></div>" $conf.footer << "<div id='footer#{i}'></div>" } diff --git a/config_sample.rb b/config_sample.rb index 7221b26..0000e15 100644 --- a/config_sample.rb +++ b/config_sample.rb @@ -44,11 +44,11 @@ # 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 +# if you do not want people to read parts of your error log, leave the # $conf.errorlog unset! -# Make sure, that your apache can read this file +# Make sure, that your apache can read this file # (which usually is not the case for /var/log/apache2/*) -# You have 2 Options: +# You have 2 Options: # 1. change logrotate to allow /var/log/apache2/* to be read by apache # (=> change the line »create 640 root adm«) # 2. change $conf.errorlog to another file and create a new rule for logrotate. @@ -87,8 +87,8 @@ # Add some Example Polls to the example page. # You may create those using the normal interface # and make them password protected afterwards -# .htaccess and .htdigest are deleted after -# example creation (defining password protected +# .htaccess and .htdigest are deleted after +# example creation (defining password protected # examples is not possible therefore) #$conf.examples = [ # { diff --git a/customize.cgi b/customize.cgi index 26de213..bbcd8d9 120000..100755 --- a/customize.cgi +++ b/customize.cgi @@ -1 +1,132 @@ -customize.rb
\ No newline at end of file +#!/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/>. # +############################################################################ + + +if __FILE__ == $0 + +$:.push("..") +require_relative "dudle" + +$d = Dudle.new + + +$d << "<h2>" + _("Customize personal settings") + "</h2>" +$d << _("You need <a href='https://en.wikipedia.org/wiki/HTTP_cookie'>cookies</a> enabled in order to personalize your settings.") + +def choosetable(options, cursetting) + ret = <<HEAD +<table> + <tr> +HEAD + ret += "<th>" + _("Current setting") + "</th>" + ret += "<th>" + _("Description") + "</th>" + ret += "</tr>" + options.each{|description,href,title| + selected = href == cursetting + ret += "<tr><td>" + ret += YES if selected + ret += "</td><td class='settingstable' title='#{title}'>" + ret += "<a href='?#{href}'>" unless selected + ret += description + ret += "</a>" unless selected + ret += "</td></tr>" + } + ret += "</table>" + ret +end + + +a = [[_("Use special characters") + " (#{UTFCHARS})","utf", _("Use this option if you see the characters in the parenthesis.")], + [_("Use only normal strings"),"ascii",_("Use this option if you have problems with some characters.")]] +$d.html.add_cookie("ascii","true","/",Time.now + (1*60*60*24*365 * ($USEUTF ? -1 : 1 ))) +$d << "<div id='charset'>" +$d << "<h3>" + _("Charset")+ "</h3>" +$d << choosetable(a,$USEUTF ? "utf" : "ascii") +$d << "</div>" + +$d << "<div id='config_stylesheet'>" +$d << "<h3>" + _("Stylesheet") + "</h3>" +$d << choosetable($d.css.collect{|href| [href.scan(/([^\/]*)\.css/).flatten[0],"css=#{href}"]},"css=#{$d.user_css}") +$d << "</div>" + + +username = $cgi.cookies["username"][0] +if $cgi.include?("delete_username") + $d.html.add_cookie("username","","/",Time.now - 1*60*60*24*365) + username = "" +elsif $cgi.include?("username") && $cgi["username"] != "" + $d.html.add_cookie("username",$cgi["username"],"/",Time.now + 1*60*60*24*365) +end + + + +defaultuserstr = _("Default Username") +usernamestr = _("Username:") +$d << <<CHARSET +<div id='config_user'> +<h3>#{defaultuserstr}</h3> +<form method='get' action='' accept-charset='utf-8'> + <table> + <tr id='usernamesetting'> + <td> + <label for='username'>#{usernamestr} </label> + </td> + <td class='settingstable'> +CHARSET + +if username && !$cgi.include?("edit") + $d << <<CHARSET + <span>#{CGI.escapeHTML(username)}</span> + <input type='hidden' value="#{CGI.escapeHTML(username)}" name='username' /> + <input type='hidden' value="true" name='edit' /> + </td> + </tr> + <tr> + <td></td> + <td class='settingstable'> +CHARSET + $d << "<input id='username' type='submit' value='" + _("Edit") + "' />" +else + $d << <<CHARSET + <input id='username' type='text' value="#{CGI.escapeHTML(username.to_s)}" name='username' /> + </td> + </tr> + <tr> + <td></td> + <td class='settingstable'> +CHARSET + $d << "<input type='submit' value='" + _("Save") + "' />" +end + +$d.html << "<input type='submit' name='delete_username' value='" + _("Delete") + "' />" if username + +$d << <<CHARSET + </td> + </tr> + </table> +</form> +</div> +CHARSET + +$d.out +end + + diff --git a/customize.rb b/customize.rb index 564346c..bbcd8d9 100755 --- a/customize.rb +++ b/customize.rb @@ -32,7 +32,7 @@ $d << "<h2>" + _("Customize personal settings") + "</h2>" $d << _("You need <a href='https://en.wikipedia.org/wiki/HTTP_cookie'>cookies</a> enabled in order to personalize your settings.") def choosetable(options, cursetting) - ret = <<HEAD + ret = <<HEAD <table> <tr> HEAD diff --git a/date_locale.rb b/date_locale.rb index 168b1d1..1b02b0a 100644 --- a/date_locale.rb +++ b/date_locale.rb @@ -1,300 +1,300 @@ -# coding: utf-8
-#Make a 'localization' for Date, DateTime and Time.
-#
-#This is not using locale, but if you use locale, it is detected and locale sensitive.
-#
-#The output is in iso-8859-1, other encodings can be set with Date_locale.set_target_encoding.
-#
-
-
-require 'date'
-
-#
-#Adaption for a localized Date-class
-#
-#Solution based on discussion at ruby-forum.de
-#-http://forum.ruby-portal.de/viewtopic.php?f=1&t=10527&start=0
-#
-module Date_locale
-
- #Constant/Hash with the supported languages.
- #
- #Initial definitions are taken from localization_simplified.
- #
- #Changes:
- #* added de_at
- #* adapted :pt to pt_br (original :pt was French).
- DATE_TEXTS = {
- :ca => {
- :monthnames => [nil] + %w{gener febrer març abril maig juny juliol agost setembre octubre novembre desembre},
- :abbr_monthnames => [nil] + %w{gen feb mar abr mai jun jul ago set oct nov des},
- :daynames => %w{diumenge dilluns dimarts dimecres dijous divendres dissabte},
- :abbr_daynames => %w{dg dl dt dc dj dv ds},
- },
- :cf => {
- :monthnames => [nil] + %w{Janvier Février Mars Avril Mai Juin Juillet Août Septembre Octobre Novembre Décembre},
- :abbr_monthnames => [nil] + %w{Jan Fev Mar Avr Mai Jun Jui Aou Sep Oct Nov Dec},
- :daynames => %w{Dimanche Lundi Mardi Mercredi Jeudi Vendredi Samedi},
- :abbr_daynames => %w{Dim Lun Mar Mer Jeu Ven Sam},
- },
- :cs => {
- :monthnames => [nil] + %w{Leden Únor Březen Duben Květen Červen Červenec Srpen Září Říjen Listopad Prosinec},
- :abbr_monthnames => [nil] + %w{Led Úno Bře Dub Kvě Čvn Čvc Srp Zář Říj Lis Pro},
- :daynames => %w{Neděle Pondělí Úterý Středa Čtvrtek Pátek Sobota},
- :abbr_daynames => %w{Ne Po Út St Čt Pá So},
- },
- :da => {
- :monthnames => [nil] + %w{januar februar marts april maj juni juli august september oktober november december},
- :abbr_monthnames => [nil] + %w{jan feb mar apr maj jun jul aug sep okt nov dec},
- :daynames => %w{søndag mandag tirsdag onsdag torsdag fredag lørdag},
- :abbr_daynames => %w{søn man tir ons tors fre lør},
- },
- :de => {
- :monthnames => [nil] + %w{Januar Februar März April Mai Juni Juli August September Oktober November Dezember},
- :abbr_monthnames => [nil] + %w{Jan Feb Mrz Apr Mai Jun Jul Aug Sep Okt Nov Dez},
- :daynames => %w{Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag},
- :abbr_daynames => %w{So Mo Di Mi Do Fr Sa},
- },
- :de_at => {
- :monthnames => [nil] + %w(Jänner Feber März April Mai Juni Juli August September Oktober November Dezember),
- :abbr_monthnames => [nil] + %w(Jan Feb Mrz Apr Mai Jun Jul Aug Sep Okt Nov Dez),
- :daynames => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag),
- :abbr_daynames => %w(So Mo Di Mi Do Fr Sa),
- },
- :et => {
- :monthnames => [nil] + %w{Jaanuar Veebruar Märts Aprill Mai Juuni Juuli August September Oktober November Detsember},
- :abbr_monthnames => [nil] + %w{Jaan. Veebr. Märts Apr. Mai Juuni Juuli. Aug. Sep. Okt. Nov. Dets.},
- :daynames => %w{Pühapäev Esmapäev Teisipäev Kolmapäev Neljapäev Reedel Laupäev},
- :abbr_daynames => %w{P E T K N R L},
- },
- :en => {
- :monthnames => [nil] + %w{January February March April May June July August September October November December},
- :abbr_monthnames => [nil] + %w{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec},
- :daynames => %w{Sunday Monday Tuesday Wednesday Thursday Friday Saturday},
- :abbr_daynames => %w{Sun Mon Tue Wed Thu Fri Sat},
- },
- :es => {
- :monthnames => [nil] + %w{enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre},
- :abbr_monthnames => [nil] + %w{ene feb mar abr may jun jul ago sep oct nov dic},
- :daynames => %w{domingo lunes martes miércoles jueves viernes sábado},
- :abbr_daynames => %w{dom lun mar mié jue vie sáb},
- },
- :es_ar => {
- :monthnames => [nil] + %w{enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre},
- :abbr_monthnames => [nil] + %w{ene feb mar abr may jun jul ago sep oct nov dic},
- :daynames => %w{domingo lunes martes miércoles jueves viernes sábado},
- :abbr_daynames => %w{dom lun mar mié jue vie sáb},
- },
- :fi => {
- :monthnames => [nil] + %w{tammikuu helmikuu maaliskuu huhtikuu toukokuu kesäkuu heinäkuu elokuu syyskuu lokakuu marraskuu joulukuu},
- :abbr_monthnames => [nil] + %w{tammi helmi maalis huhti touko kesä heinä elo syys loka marras joulu},
- :daynames => %w{sunnuntai maanantai tiistai keskiviikko torstai perjantai lauantai},
- :abbr_daynames => %w{su ma ti ke to pe la},
- },
- :fr => {
- :monthnames => [nil] + %w{janvier février mars avril mai juin juillet août septembre octobre novembre decembre},
- :abbr_monthnames => [nil] + %w{jan fév mar avr mai jun jul aoû sep oct nov déc},
- :daynames => %w{dimanche lundi mardi mercredi jeudi vendredi samedi},
- :abbr_daynames => %w{dim lun mar mer jeu ven sam},
- },
- :it => {
- :monthnames => [nil] + %w{Gennaio Febbraio Marzo Aprile Maggio Giugno Luglio Agosto Settembre Ottobre Novembre Dicembre },
- :daynames => %w{ Domenica Lunedì Martedì Mercoledì Giovedì Venerdì Sabato },
- :abbr_monthnames => [nil] + %w{ Gen Feb Mar Apr Mag Giu Lug Ago Set Ott Nov Dic },
- :abbr_daynames => %w{ Dom Lun Mar Mer Gio Ven Sab },
- },
- :ko => {
- :monthnames => [nil] + %w{1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월},
- :abbr_monthnames => [nil] + %w{1 2 3 4 5 6 7 8 9 10 11 12},
- :daynames => %w{일요일 월요일 화요일 수요일 목요일 금요일 토요일},
- :abbr_daynames => %w{일 월 화 수 목 금 토},
- },
- :nl => {
- :monthnames => [nil] + %w{Januari Februari Maart April Mei Juni Juli Augustus September Oktober November December},
- :abbr_monthnames => [nil] + %w{Jan Feb Maa Apr Mei Jun Jul Aug Sep Okt Nov Dec},
- :daynames => %w{Zondag Maandag Dinsdag Woensdag Donderdag Vrijdag Zaterdag},
- :abbr_daynames => %w{Zo Ma Di Wo Do Vr Za},
- },
- :no => {
- :monthnames => [nil] + %w{januar februar mars april mai juni juli august september oktober november desember},
- :abbr_monthnames => [nil] + %w{jan feb mar apr mai jun jul aug sep okt nov des},
- :daynames => %w{søndag mandag tirsdag onsdag torsdag fredag lørdag},
- :abbr_daynames => %w{søn man tir ons tors fre lør},
- },
- :pt => {
- :monthnames => [nil] + %w{Janeiro Fevereiro Março Abril Maio Junho Julho Agosto Setembro Outubro Novembro Dezembro},
- :abbr_monthnames => [nil] + %w{Jan Fev Mar Abr Mai Jun Jul Ago Set Out Nov Dez},
- :daynames => %w{domingo segunda terça quarta quinta sexta sábado},
- :abbr_daynames => %w{Dom Seg Ter Qua Qui Sex Sab},
- },
- :pt_br => {
- :monthnames => [nil] + %w{janeiro fevereiro março abril maio junho julho agosto setembro outubro novembro dezembro},
- :abbr_monthnames => [nil] + %w{jan fev mar abr mai jun jul ago set out nov dez},
- :daynames => %w{domingo segunda terça quarta quinta sexta sábado},
- :abbr_daynames => %w{dom seg ter qua qui sex sáb},
- },
- :ru => {
- :monthnames => [nil] + %w{Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь},
- :abbr_monthnames => [nil] + %w{Янв Фев Мар Апр Май Июн Июл Авг Сен Окт Ноя Дек},
- :daynames => %w{Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота},
- :abbr_daynames => %w{Вск Пнд Втр Сре Чет Пят Суб},
- },
- :sv => {
- :monthnames => [nil] + %w{januari februari mars april maj juni juli augusti september oktober november december},
- :abbr_monthnames => [nil] + %w{jan feb mar apr maj jun jul aug sep okt nov dec},
- :daynames => %w{söndag måndag tisdag onsdag torsdag fredag lördag},
- :abbr_daynames => %w{sön mån tis ons tors fre lör},
- },
- :sr => {
- :monthnames => [nil] + %w{Januar Februar Mart April Maj Jun Jul Avgust Septembar Oktobar Novembar Decembar},
- :abbr_monthnames => [nil] + %w{Jan Feb Mar Apr Maj Jun Jul Aug Sep Okt Nov Dec},
- :daynames => %w{Nedelja Ponedeljak Utorak Sreda Četvrtak Petak Subota},
- :abbr_daynames => %w{Ned Pon Uto Sre Čet Pet Sub},
- },
- :hu => {
- :monthnames => [nil] + %w{január február március május június július augusztus szeptember október november december},
- :abbr_monthnames => [nil] + %w{jan feb már ápr máj jún júl aug sze okt nov dec},
- :daynames => %w{vasárnap hétfő kedd szerda csütörtök péntek szombat},
- :abbr_daynames => %w{vas hét ked sze csü pén szo},
- },
- }
- #~ puts DATE_TEXTS.to_yaml
-
- #Not really necessary.
- #But I want to avoid later changes.
- DATE_TEXTS.freeze
-
- #
- #Test if the seleted language is available in Date_locale.
- def self.locale?( lang )
- return DATE_TEXTS[lang]
- end
-
-
- #
- #Get the key for the wanted language.
- #
- #Allows the usage (or not to use) locale.
- def self.get_language_key( lang = nil )
-
- #
- #What's the better solution? Check for locale, or check for the method :language?
- #
- #if defined?( Locale ) and lang.is_a?(Locale::TagList)
- if lang.respond_to?(:language)
- if lang.respond_to?(:charset) && lang.charset != nil
- Date_locale.set_target_encoding( lang.charset )
- end
- return lang.language.to_sym
- end
-
- case lang
- when nil #Undefined default, take actual locale or en
- return defined?( Locale ) ? Locale.current.language.to_sym : :en
- #This code require locale (or you get an error "uninitialized constant Date_locale::Locale")
- #when Locale::Object
- # return lang.language.to_sym
- else
- return lang.to_sym
- end
- end
-
- #
- #strftime with the day- and month names in the selected language.
- #
- #Lang can be a language symbol or a locale.
- def strftime_locale(format = '%F', lang = nil )
-
- lang = Date_locale.get_language_key(lang)
-
- #Get the texts
- if DATE_TEXTS[lang]
- daynames = DATE_TEXTS[lang][:daynames]
- abbr_daynames = DATE_TEXTS[lang][:abbr_daynames]
- monthnames = DATE_TEXTS[lang][:monthnames]
- abbr_monthnames = DATE_TEXTS[lang][:abbr_monthnames]
- else
- #raise "Missing Support for locale #{lang.inspect}"
- #fallback to english
- daynames = DATE_TEXTS[:en][:daynames]
- abbr_daynames = DATE_TEXTS[:en][:abbr_daynames]
- monthnames = DATE_TEXTS[:en][:monthnames]
- abbr_monthnames = DATE_TEXTS[:en][:abbr_monthnames]
- end
-
- #Make the original replacements, after....
- result = self.strftime_orig(
- #...you replaced the language dependent parts.
- format.gsub(/%([aAbB])/){|m|
- case $1
- when 'a'; abbr_daynames[self.wday]
- when 'A'; daynames[self.wday]
- when 'b'; abbr_monthnames[self.mon]
- when 'B'; monthnames[self.mon]
- else
- raise "Date#strftime: InputError"
- end
- }
- )
- result.encode("utf-8")
- end #strftime_locale(format = '%F', lang = :en )
-
-end #module Date_locale
-
-class Date
-
- include Date_locale
- alias :strftime_orig :strftime
-
- #Redefine strftime with flexible daynames.
- #
- def strftime(format = '%F', lang = nil )
- return strftime_locale(format, lang )
- end #strftime
-end #class Date
-
-
-#
-#Redefine strftime for DateTime
-#
-class DateTime
- #No alias! It is done already in class Date.
- #alias :strftime_orig_date :strftime
-
- #Redefine strftime.
- #strftime_orig is already defined in Date.
- def strftime( format='%F', lang = nil )
- return strftime_locale(format, lang )
- end #strftime
-end
-
-
-class Time
- include Date_locale
- alias :strftime_orig :strftime
- #Redefine strftime for locale versions.
- def strftime(format='%F', lang = nil )
- return strftime_locale(format, lang )
- end #strftime
-
-end
-
-#
-#Make some quick tests
-#
-if __FILE__ == $0
- #~ require 'date_locale'
-
- d = Date.new(2009,10,21)
- puts d.strftime("de: %A {%a} {%A} {%W} %w ", :de ) #=> de: Mittwoch {Mi} {Mittwoch} {42} 3 (loc: en)
- puts d.strftime("en: %A {%a} {%A} {%W} %w ", :en ) #=> en: Wednesday {Wed} {Wednesday} {42} 3 (loc: en)
-
- puts "=======Load locale"
- require 'locale'
- Locale.current = 'de'
- puts d.strftime("#{Locale.current}: %A {%a} {%A} {%W} %w") #=> de: Mittwoch {Mi} {Mittwoch} {42} 3
- Locale.current = 'en'
- puts d.strftime("#{Locale.current}: %A {%a} {%A} {%W} %w") #=> en: Wednesday {Wed} {Wednesday} {42} 3
- puts d.strftime("de: %A {%a} {%A} {%W} %w (loc: #{Locale.current})", :de ) #=> de: Mittwoch {Mi} {Mittwoch} {42} 3 (loc: en)
- puts d.strftime("en: %A {%a} {%A} {%W} %w (loc: #{Locale.current})", :en ) #=> en: Wednesday {Wed} {Wednesday} {42} 3 (loc: en)
-end #if __FILE__ == $0
+# coding: utf-8 +#Make a 'localization' for Date, DateTime and Time. +# +#This is not using locale, but if you use locale, it is detected and locale sensitive. +# +#The output is in iso-8859-1, other encodings can be set with Date_locale.set_target_encoding. +# + + +require 'date' + +# +#Adaption for a localized Date-class +# +#Solution based on discussion at ruby-forum.de +#-http://forum.ruby-portal.de/viewtopic.php?f=1&t=10527&start=0 +# +module Date_locale + + #Constant/Hash with the supported languages. + # + #Initial definitions are taken from localization_simplified. + # + #Changes: + #* added de_at + #* adapted :pt to pt_br (original :pt was French). + DATE_TEXTS = { + :ca => { + :monthnames => [nil] + %w{gener febrer març abril maig juny juliol agost setembre octubre novembre desembre}, + :abbr_monthnames => [nil] + %w{gen feb mar abr mai jun jul ago set oct nov des}, + :daynames => %w{diumenge dilluns dimarts dimecres dijous divendres dissabte}, + :abbr_daynames => %w{dg dl dt dc dj dv ds}, + }, + :cf => { + :monthnames => [nil] + %w{Janvier Février Mars Avril Mai Juin Juillet Août Septembre Octobre Novembre Décembre}, + :abbr_monthnames => [nil] + %w{Jan Fev Mar Avr Mai Jun Jui Aou Sep Oct Nov Dec}, + :daynames => %w{Dimanche Lundi Mardi Mercredi Jeudi Vendredi Samedi}, + :abbr_daynames => %w{Dim Lun Mar Mer Jeu Ven Sam}, + }, + :cs => { + :monthnames => [nil] + %w{Leden Únor Březen Duben Květen Červen Červenec Srpen Září Říjen Listopad Prosinec}, + :abbr_monthnames => [nil] + %w{Led Úno Bře Dub Kvě Čvn Čvc Srp Zář Říj Lis Pro}, + :daynames => %w{Neděle Pondělí Úterý Středa Čtvrtek Pátek Sobota}, + :abbr_daynames => %w{Ne Po Út St Čt Pá So}, + }, + :da => { + :monthnames => [nil] + %w{januar februar marts april maj juni juli august september oktober november december}, + :abbr_monthnames => [nil] + %w{jan feb mar apr maj jun jul aug sep okt nov dec}, + :daynames => %w{søndag mandag tirsdag onsdag torsdag fredag lørdag}, + :abbr_daynames => %w{søn man tir ons tors fre lør}, + }, + :de => { + :monthnames => [nil] + %w{Januar Februar März April Mai Juni Juli August September Oktober November Dezember}, + :abbr_monthnames => [nil] + %w{Jan Feb Mrz Apr Mai Jun Jul Aug Sep Okt Nov Dez}, + :daynames => %w{Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag}, + :abbr_daynames => %w{So Mo Di Mi Do Fr Sa}, + }, + :de_at => { + :monthnames => [nil] + %w(Jänner Feber März April Mai Juni Juli August September Oktober November Dezember), + :abbr_monthnames => [nil] + %w(Jan Feb Mrz Apr Mai Jun Jul Aug Sep Okt Nov Dez), + :daynames => %w(Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag), + :abbr_daynames => %w(So Mo Di Mi Do Fr Sa), + }, + :et => { + :monthnames => [nil] + %w{Jaanuar Veebruar Märts Aprill Mai Juuni Juuli August September Oktober November Detsember}, + :abbr_monthnames => [nil] + %w{Jaan. Veebr. Märts Apr. Mai Juuni Juuli. Aug. Sep. Okt. Nov. Dets.}, + :daynames => %w{Pühapäev Esmapäev Teisipäev Kolmapäev Neljapäev Reedel Laupäev}, + :abbr_daynames => %w{P E T K N R L}, + }, + :en => { + :monthnames => [nil] + %w{January February March April May June July August September October November December}, + :abbr_monthnames => [nil] + %w{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec}, + :daynames => %w{Sunday Monday Tuesday Wednesday Thursday Friday Saturday}, + :abbr_daynames => %w{Sun Mon Tue Wed Thu Fri Sat}, + }, + :es => { + :monthnames => [nil] + %w{enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre}, + :abbr_monthnames => [nil] + %w{ene feb mar abr may jun jul ago sep oct nov dic}, + :daynames => %w{domingo lunes martes miércoles jueves viernes sábado}, + :abbr_daynames => %w{dom lun mar mié jue vie sáb}, + }, + :es_ar => { + :monthnames => [nil] + %w{enero febrero marzo abril mayo junio julio agosto septiembre octubre noviembre diciembre}, + :abbr_monthnames => [nil] + %w{ene feb mar abr may jun jul ago sep oct nov dic}, + :daynames => %w{domingo lunes martes miércoles jueves viernes sábado}, + :abbr_daynames => %w{dom lun mar mié jue vie sáb}, + }, + :fi => { + :monthnames => [nil] + %w{tammikuu helmikuu maaliskuu huhtikuu toukokuu kesäkuu heinäkuu elokuu syyskuu lokakuu marraskuu joulukuu}, + :abbr_monthnames => [nil] + %w{tammi helmi maalis huhti touko kesä heinä elo syys loka marras joulu}, + :daynames => %w{sunnuntai maanantai tiistai keskiviikko torstai perjantai lauantai}, + :abbr_daynames => %w{su ma ti ke to pe la}, + }, + :fr => { + :monthnames => [nil] + %w{janvier février mars avril mai juin juillet août septembre octobre novembre decembre}, + :abbr_monthnames => [nil] + %w{jan fév mar avr mai jun jul aoû sep oct nov déc}, + :daynames => %w{dimanche lundi mardi mercredi jeudi vendredi samedi}, + :abbr_daynames => %w{dim lun mar mer jeu ven sam}, + }, + :it => { + :monthnames => [nil] + %w{Gennaio Febbraio Marzo Aprile Maggio Giugno Luglio Agosto Settembre Ottobre Novembre Dicembre }, + :daynames => %w{ Domenica Lunedì Martedì Mercoledì Giovedì Venerdì Sabato }, + :abbr_monthnames => [nil] + %w{ Gen Feb Mar Apr Mag Giu Lug Ago Set Ott Nov Dic }, + :abbr_daynames => %w{ Dom Lun Mar Mer Gio Ven Sab }, + }, + :ko => { + :monthnames => [nil] + %w{1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월}, + :abbr_monthnames => [nil] + %w{1 2 3 4 5 6 7 8 9 10 11 12}, + :daynames => %w{일요일 월요일 화요일 수요일 목요일 금요일 토요일}, + :abbr_daynames => %w{일 월 화 수 목 금 토}, + }, + :nl => { + :monthnames => [nil] + %w{Januari Februari Maart April Mei Juni Juli Augustus September Oktober November December}, + :abbr_monthnames => [nil] + %w{Jan Feb Maa Apr Mei Jun Jul Aug Sep Okt Nov Dec}, + :daynames => %w{Zondag Maandag Dinsdag Woensdag Donderdag Vrijdag Zaterdag}, + :abbr_daynames => %w{Zo Ma Di Wo Do Vr Za}, + }, + :no => { + :monthnames => [nil] + %w{januar februar mars april mai juni juli august september oktober november desember}, + :abbr_monthnames => [nil] + %w{jan feb mar apr mai jun jul aug sep okt nov des}, + :daynames => %w{søndag mandag tirsdag onsdag torsdag fredag lørdag}, + :abbr_daynames => %w{søn man tir ons tors fre lør}, + }, + :pt => { + :monthnames => [nil] + %w{Janeiro Fevereiro Março Abril Maio Junho Julho Agosto Setembro Outubro Novembro Dezembro}, + :abbr_monthnames => [nil] + %w{Jan Fev Mar Abr Mai Jun Jul Ago Set Out Nov Dez}, + :daynames => %w{domingo segunda terça quarta quinta sexta sábado}, + :abbr_daynames => %w{Dom Seg Ter Qua Qui Sex Sab}, + }, + :pt_br => { + :monthnames => [nil] + %w{janeiro fevereiro março abril maio junho julho agosto setembro outubro novembro dezembro}, + :abbr_monthnames => [nil] + %w{jan fev mar abr mai jun jul ago set out nov dez}, + :daynames => %w{domingo segunda terça quarta quinta sexta sábado}, + :abbr_daynames => %w{dom seg ter qua qui sex sáb}, + }, + :ru => { + :monthnames => [nil] + %w{Январь Февраль Март Апрель Май Июнь Июль Август Сентябрь Октябрь Ноябрь Декабрь}, + :abbr_monthnames => [nil] + %w{Янв Фев Мар Апр Май Июн Июл Авг Сен Окт Ноя Дек}, + :daynames => %w{Воскресенье Понедельник Вторник Среда Четверг Пятница Суббота}, + :abbr_daynames => %w{Вск Пнд Втр Сре Чет Пят Суб}, + }, + :sv => { + :monthnames => [nil] + %w{januari februari mars april maj juni juli augusti september oktober november december}, + :abbr_monthnames => [nil] + %w{jan feb mar apr maj jun jul aug sep okt nov dec}, + :daynames => %w{söndag måndag tisdag onsdag torsdag fredag lördag}, + :abbr_daynames => %w{sön mån tis ons tors fre lör}, + }, + :sr => { + :monthnames => [nil] + %w{Januar Februar Mart April Maj Jun Jul Avgust Septembar Oktobar Novembar Decembar}, + :abbr_monthnames => [nil] + %w{Jan Feb Mar Apr Maj Jun Jul Aug Sep Okt Nov Dec}, + :daynames => %w{Nedelja Ponedeljak Utorak Sreda Četvrtak Petak Subota}, + :abbr_daynames => %w{Ned Pon Uto Sre Čet Pet Sub}, + }, + :hu => { + :monthnames => [nil] + %w{január február március május június július augusztus szeptember október november december}, + :abbr_monthnames => [nil] + %w{jan feb már ápr máj jún júl aug sze okt nov dec}, + :daynames => %w{vasárnap hétfő kedd szerda csütörtök péntek szombat}, + :abbr_daynames => %w{vas hét ked sze csü pén szo}, + }, + } + #~ puts DATE_TEXTS.to_yaml + + #Not really necessary. + #But I want to avoid later changes. + DATE_TEXTS.freeze + + # + #Test if the seleted language is available in Date_locale. + def self.locale?( lang ) + return DATE_TEXTS[lang] + end + + + # + #Get the key for the wanted language. + # + #Allows the usage (or not to use) locale. + def self.get_language_key( lang = nil ) + + # + #What's the better solution? Check for locale, or check for the method :language? + # + #if defined?( Locale ) and lang.is_a?(Locale::TagList) + if lang.respond_to?(:language) + if lang.respond_to?(:charset) && lang.charset != nil + Date_locale.set_target_encoding( lang.charset ) + end + return lang.language.to_sym + end + + case lang + when nil #Undefined default, take actual locale or en + return defined?( Locale ) ? Locale.current.language.to_sym : :en + #This code require locale (or you get an error "uninitialized constant Date_locale::Locale") + #when Locale::Object + # return lang.language.to_sym + else + return lang.to_sym + end + end + + # + #strftime with the day- and month names in the selected language. + # + #Lang can be a language symbol or a locale. + def strftime_locale(format = '%F', lang = nil ) + + lang = Date_locale.get_language_key(lang) + + #Get the texts + if DATE_TEXTS[lang] + daynames = DATE_TEXTS[lang][:daynames] + abbr_daynames = DATE_TEXTS[lang][:abbr_daynames] + monthnames = DATE_TEXTS[lang][:monthnames] + abbr_monthnames = DATE_TEXTS[lang][:abbr_monthnames] + else + #raise "Missing Support for locale #{lang.inspect}" + #fallback to english + daynames = DATE_TEXTS[:en][:daynames] + abbr_daynames = DATE_TEXTS[:en][:abbr_daynames] + monthnames = DATE_TEXTS[:en][:monthnames] + abbr_monthnames = DATE_TEXTS[:en][:abbr_monthnames] + end + + #Make the original replacements, after.... + result = self.strftime_orig( + #...you replaced the language dependent parts. + format.gsub(/%([aAbB])/){|m| + case $1 + when 'a'; abbr_daynames[self.wday] + when 'A'; daynames[self.wday] + when 'b'; abbr_monthnames[self.mon] + when 'B'; monthnames[self.mon] + else + raise "Date#strftime: InputError" + end + } + ) + result.encode("utf-8") + end #strftime_locale(format = '%F', lang = :en ) + +end #module Date_locale + +class Date + + include Date_locale + alias :strftime_orig :strftime + + #Redefine strftime with flexible daynames. + # + def strftime(format = '%F', lang = nil ) + return strftime_locale(format, lang ) + end #strftime +end #class Date + + +# +#Redefine strftime for DateTime +# +class DateTime + #No alias! It is done already in class Date. + #alias :strftime_orig_date :strftime + + #Redefine strftime. + #strftime_orig is already defined in Date. + def strftime( format='%F', lang = nil ) + return strftime_locale(format, lang ) + end #strftime +end + + +class Time + include Date_locale + alias :strftime_orig :strftime + #Redefine strftime for locale versions. + def strftime(format='%F', lang = nil ) + return strftime_locale(format, lang ) + end #strftime + +end + +# +#Make some quick tests +# +if __FILE__ == $0 + #~ require 'date_locale' + + d = Date.new(2009,10,21) + puts d.strftime("de: %A {%a} {%A} {%W} %w ", :de ) #=> de: Mittwoch {Mi} {Mittwoch} {42} 3 (loc: en) + puts d.strftime("en: %A {%a} {%A} {%W} %w ", :en ) #=> en: Wednesday {Wed} {Wednesday} {42} 3 (loc: en) + + puts "=======Load locale" + require 'locale' + Locale.current = 'de' + puts d.strftime("#{Locale.current}: %A {%a} {%A} {%W} %w") #=> de: Mittwoch {Mi} {Mittwoch} {42} 3 + Locale.current = 'en' + puts d.strftime("#{Locale.current}: %A {%a} {%A} {%W} %w") #=> en: Wednesday {Wed} {Wednesday} {42} 3 + puts d.strftime("de: %A {%a} {%A} {%W} %w (loc: #{Locale.current})", :de ) #=> de: Mittwoch {Mi} {Mittwoch} {42} 3 (loc: en) + puts d.strftime("en: %A {%a} {%A} {%W} %w (loc: #{Locale.current})", :en ) #=> en: Wednesday {Wed} {Wednesday} {42} 3 (loc: en) +end #if __FILE__ == $0 diff --git a/default.css b/default.css index 5c3abb1..3199fe4 100644 --- a/default.css +++ b/default.css @@ -27,7 +27,7 @@ a, a:visited { color:#36c; text-decoration:none; } - + a:hover, a:active { color:#36c; text-decoration:underline; @@ -66,12 +66,12 @@ td.name { } input.delete, input.toggle{ - border: none; + border: none; cursor: pointer; } input.navigation, input.disabled, input.chosen, input.notchosen { - border-width: 1px; + border-width: 1px; border-style: solid; border-color: black; padding: 0px; @@ -100,8 +100,8 @@ input.disabled { color:#AAA } -table { - border: none; +table { + border: none; } table.calendarday { @@ -109,7 +109,7 @@ table.calendarday { } div#AddRemoveColumndaysDescription{ - max-width: 15em; + max-width: 15em; } table.calendarday th, table.calendarday td{ @@ -193,14 +193,14 @@ tr.participantrow:hover { background: #EEE; } -tr.participantrow{ +tr.participantrow{ background-color:#fff; } - -tr#summary { + +tr#summary { background-color:#eee; } -td.sum, tr#summary { +td.sum, tr#summary { margin-top:5ex; } td.sum{ color: #FFF} @@ -216,12 +216,12 @@ td.match_20{ background-color: #888888; } td.match_10{ background-color: #999999; } td.match_0{ background-color: #AAAAAA; } - + td.polls { text-align:left; } -th { +th { font-weight: normal; padding-left: 3px; padding-right: 3px; @@ -229,7 +229,7 @@ th { border:none; } -td.date { +td.date { color:#ccc; text-align: left; } @@ -240,7 +240,7 @@ html { } #main{ margin-left: auto; - margin-right:auto; + margin-right:auto; } #content { background: #fff; @@ -310,17 +310,17 @@ div#tabs a{ } li.active_tab{ - border-style: solid solid none; + border-style: solid solid none; padding-bottom: 1px; } -li.nonactive_tab{ +li.nonactive_tab{ border-style: solid; border-color:#CCC; border-bottom:none; } -li.nonactive_tab a:hover { +li.nonactive_tab a:hover { background: #EEE; } diff --git a/delete_poll.rb b/delete_poll.rb index dd69138..df7bbd7 100755 --- a/delete_poll.rb +++ b/delete_poll.rb @@ -109,7 +109,7 @@ $d.html << "<h2>" + _("Delete this poll") + "</h2>" $d.html << _("You want to delete the poll named") + " <b>#{$d.table.name}</b>.<br />" $d.html << _("This is an irreversible action!") + "<br />" $d.html << _("If you are sure that you want to permanently remove this poll, please type “%{question}” into the form.") % {:question => QUESTIONS[CONFIRM]} -deletestr = _("Delete") +deletestr = _("Delete") $d.html << %{ #{hint} <form method='post' action='' accept-charset='utf-8'> @@ -128,8 +128,8 @@ class Dudle @table = YAML::load(VCS.cat(self.revision, "data.yaml")) @urlsuffix = File.basename(File.expand_path(".")) @title = @table.name - - + + configfiles = @configtabs.collect{|name,file| file} @is_config = configfiles.include?(@tab) @wizzardindex = configfiles.index(@tab) if @is_config @@ -144,7 +144,7 @@ class Dudle end - + @css = ["default", "classic", "print"].collect{|f| f + ".css"} if Dir.exists?("#{@basedir}/css/") Dir.open("#{@basedir}/css/").each{|f| diff --git a/edit_columns.rb b/edit_columns.rb index d20ae9a..fc871c6 100755 --- a/edit_columns.rb +++ b/edit_columns.rb @@ -20,7 +20,7 @@ ############################################################################ if __FILE__ == $0 - + load "../dudle.rb" revbeforeedit = VCS.revno @@ -28,7 +28,7 @@ revbeforeedit = VCS.revno if $cgi.include?("undo_revision") && $cgi["undo_revision"].to_i < revbeforeedit undorevision = $cgi["undo_revision"].to_i $d = Dudle.new(:revision => undorevision) - comment = $cgi.include?("redo") ? "Redo changes" : "Reverted Poll" + comment = $cgi.include?("redo") ? "Redo changes" : "Reverted Poll" $d.table.store("#{comment} to version #{undorevision}") else $d = Dudle.new @@ -82,9 +82,9 @@ if rrevs.min case action when "added" title["Redo"] = _("Add column") + " #{coltitle}" - when "deleted" + when "deleted" title["Redo"] = _("Delete column") + " #{coltitle}" - when "edited" + when "edited" title["Redo"] = _("Edit column") + " #{coltitle}" end @@ -72,7 +72,7 @@ end if $conf.auto_send_report && !known tmpfile = "/tmp/error.#{rand(10000)}" - File.open(tmpfile,"w"){|f| + File.open(tmpfile,"w"){|f| f << errorstr } diff --git a/example.cgi b/example.cgi index 2af2637..f7f8755 100755 --- a/example.cgi +++ b/example.cgi @@ -58,14 +58,14 @@ if $cgi.include?("poll") else $d << "<div class='error'>" $d << _("Example not found: %{example}") % { :example => CGI.escapeHTML($cgi["poll"])} - $d << "</div>" + $d << "</div>" end end 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:") + $d << _("If you want to play with the application, you may want to take a look at these example polls:") $d << "<ul>" $conf.examples.each{|poll| $d << "<li><a href='example.cgi?poll=#{poll[:url]}'>#{poll[:description]}</a></li>" unless poll[:hidden] @@ -57,6 +57,6 @@ require "test/unit" assert_equal( 1,d.compare_by_values(c,[1,2,3])) assert_equal( 0,d.compare_by_values(c,[])) end - end + end end @@ -37,7 +37,7 @@ class HTML def head ret = <<HEAD <head> - <meta http-equiv="Content-Type" content="#{@header["type"]}; charset=#{@header["charset"]}" /> + <meta http-equiv="Content-Type" content="#{@header["type"]}; charset=#{@header["charset"]}" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <title>#{@title}</title> <link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon"> @@ -100,7 +100,7 @@ SCRIPT def out(cgi) #FIXME: quick and dirty fix for encoding problem - { + { "ö" => "ö", "ü" => "ü", "ä" => "ä", @@ -36,7 +36,7 @@ if $cgi.include?("create_poll") && $cgi.include?("poll_url") if guessurl =~ /^[a-zA-Z0-9_-]+$/ && !File.exist?(guessurl) POLLURL = guessurl else - chars = ("a".."z").to_a + ("1".."9").to_a + chars = ("a".."z").to_a + ("1".."9").to_a POLLURL = Array.new(8){chars[rand(chars.size)]}.join end else @@ -77,7 +77,7 @@ class Log return @log[i] end end - + def size @log.size end @@ -135,7 +135,7 @@ class Log elem = self[rev] prevrev = elem.comment.scan(/^.* to version (\d*)$/).flatten[0] if prevrev - rev = prevrev.to_i + rev = prevrev.to_i else h << elem rev -= 1 @@ -143,10 +143,10 @@ class Log end h.sort! a = [] - begin + begin a << h.pop end while a.last && a.last.comment =~ /^Column .*$/ - a.pop + a.pop a.sort! Log.new(a) end @@ -162,7 +162,7 @@ class Log break unless revertrevs.empty? redone << r.to_i() -1 else - revertrevs << r.to_i + revertrevs << r.to_i end } revertrevs = revertrevs - redone @@ -213,7 +213,7 @@ require "pp" # | | | | # 0-1-2-3-4-5 # p - + def dummy_add(log,comment) log.add(log.max.rev+1,Time.now,comment) end @@ -242,7 +242,7 @@ require "pp" assert_equal([2,3,8,9],l.undorevisions.revisions) assert_equal([],l.redorevisions.revisions) - + dummy_add(l,"Reverted Poll to version 8") dummy_add(l,"Reverted Poll to version 7") dummy_add(l,"Reverted Poll to version 2") @@ -254,7 +254,7 @@ require "pp" dummy_add(l,"Redo changes to version 3") assert_equal([2,3],l.undorevisions.revisions) assert_equal([8,9],l.redorevisions.revisions) - + dummy_add(l,"Redo changes to version 8") dummy_add(l,"Redo changes to version 9") assert_equal([2,3,8,9],l.undorevisions.revisions) @@ -278,11 +278,11 @@ require "pp" dummy_add(l,"Redo changes to version 3") assert_equal([2,3],l.undorevisions.revisions) assert_equal([8,9],l.redorevisions.revisions) - + dummy_add(l,"Redo changes to version 8") dummy_add(l,"Redo changes to version 9") assert_equal([2,3,8,9],l.undorevisions.revisions) assert_equal([],l.redorevisions.revisions) end - end + end end diff --git a/participate.rb b/participate.rb index e6fc55b..6184f9d 100755 --- a/participate.rb +++ b/participate.rb @@ -48,14 +48,14 @@ if $cgi["comment"] != "" end if $cgi.include?("delete_comment") - $d.table.delete_comment($cgi["delete_comment"]) + $d.table.delete_comment($cgi["delete_comment"]) edit = true end if edit $d.html.header["status"] = "REDIRECT" $d.html.header["Cache-Control"] = "no-cache" - $d.html.header["Location"] = $conf.siteurl + $d.html.header["Location"] = $conf.siteurl $d << _("The changes were saved, you should be redirected to %{link}.") % {:link => "<a href=\"#{$conf.siteurl}\">#{$conf.siteurl}</a>"} else @@ -80,7 +80,7 @@ class Poll until fields.pop == "name" end @data.sort{|x,y| - cmp = x[1].compare_by_values(y[1],fields) + cmp = x[1].compare_by_values(y[1],fields) cmp == 0 ? x[0].downcase <=> y[0].downcase : cmp } else @@ -92,12 +92,12 @@ class Poll ret = "" if link ret += "<td><span class='edituser'>" - ret += "<a title=\"" - ret += _("Edit user %{user}...") % {:user => CGI.escapeHTML(participant)} + ret += "<a title=\"" + ret += _("Edit user %{user}...") % {:user => CGI.escapeHTML(participant)} ret += "\" href=\"?edituser=#{CGI.escape(participant)}\">" ret += EDIT - ret += "</a> | <a title=\"" - ret += _("Delete user %{user}...") % {:user => CGI.escapeHTML(participant)} + ret += "</a> | <a title=\"" + ret += _("Delete user %{user}...") % {:user => CGI.escapeHTML(participant)} ret += "\" href=\"?deleteuser&edituser=#{CGI.escape(participant)}\">" ret += "#{DELETE}</a>" ret += "</span></td>" @@ -112,7 +112,7 @@ class Poll def to_html(showparticipation = true) # border=1 for textbrowsers ;--) ret = "<table id='participanttable' class='polltable' border='1'>\n" - + sortcolumns = $cgi.include?("sort") ? $cgi.params["sort"] : ["timestamp"] ret += "<thead>#{@head.to_html(sortcolumns)}</thead>" ret += "<tbody id='participants'>" @@ -221,8 +221,8 @@ HEAD return <<END <td colspan='2' id='add_participant_input_td'> <input type='hidden' name='olduser' value="#{CGI.escapeHTML(edituser.to_s)}" /> - <input size='16' - type='text' + <input size='16' + type='text' name='add_participant' id='add_participant_input' value="#{CGI.escapeHTML(edituser.to_s)}"/> @@ -283,10 +283,10 @@ END ret += <<TR <tr class='input-#{valbinary}'> <td class='input-radio'> - <input type='radio' - value='#{valbinary}' - id=\"add_participant_checked_#{column.to_htmlID}_#{valbinary}\" - name=\"add_participant_checked_#{CGI.escapeHTML(column.to_s)}\" + <input type='radio' + value='#{valbinary}' + id=\"add_participant_checked_#{column.to_htmlID}_#{valbinary}\" + name=\"add_participant_checked_#{CGI.escapeHTML(column.to_s)}\" title=\"#{CGI.escapeHTML(column.to_s)}\" #{checked[column] == valbinary ? "checked='checked'":""}/> </td> <td class='input-label'> @@ -309,7 +309,7 @@ TR ret += "<h2>" + _("Comments") if !@comment.empty? || editable if $cgi.include?("comments_reverse") ret += " <a class='comment_sort' href='?' title='" - ret += _("Sort oldest comment first") + "'>#{REVERSESORT}</a>" + ret += _("Sort oldest comment first") + "'>#{REVERSESORT}</a>" else ret += " <a class='comment_sort' href='?comments_reverse' title='" ret += _("Sort newest comment first") + "'>#{SORT}</a>" @@ -317,7 +317,7 @@ TR if @comment.size > 5 ret += " <a class='top_bottom_ref' href='#comment#{@comment.size - 1}' title='" - ret += _("Go to last comment") + "'>#{GODOWN}</a>" + ret += _("Go to last comment") + "'>#{GODOWN}</a>" end ret += "</h2>" if !@comment.empty? || editable @@ -348,7 +348,7 @@ TR ret += _("Go up") + "'>#{GOUP}</a>" end - + if editable # ADD COMMENT saysstr = _("says") @@ -374,7 +374,7 @@ ADDCOMMENT ret = <<FORM <form method='get' action=''> <div> - #{showhiststr} + #{showhiststr} <select name='history'> FORM [["",_("All")], @@ -451,7 +451,7 @@ FORM end ############################### - # comment related functions + # comment related functions ############################### def add_comment name, comment @comment << [Time.now, CGI.escapeHTML(name.strip), CGI.escapeHTML(comment.strip).gsub("\r\n","<br />")] diff --git a/pollhead.rb b/pollhead.rb index 07d825b..b74fca7 100644 --- a/pollhead.rb +++ b/pollhead.rb @@ -47,7 +47,7 @@ class PollHead if parsedtitle != "" @data[parsedtitle] = cgi["columndescription"].strip return parsedtitle - else + else return false end end @@ -88,7 +88,7 @@ EDITDELETE ret += "</tr>\n" ret end - + def edit_column_htmlform(activecolumn, revision) if activecolumn != "" title = activecolumn @@ -72,7 +72,7 @@ th.weekday{ } input.navigation, input.disabled, input.chosen, input.notchosen { - border-width: 1px; + border-width: 1px; border-style: solid; border-color: black; padding: 0px; @@ -81,19 +81,19 @@ input.navigation, input.disabled, input.chosen, input.notchosen { } input.navigation { - color: white; + color: white; background-color: black; } input.disabled { background-color:#DDD;color:#BBB} td.calendarday{ - border: 1px; + border: 1px; padding: 0px; margin: 0px; } -table { - border: none; +table { + border: none; border-spacing: 0; border-collapse: collapse; } @@ -118,7 +118,7 @@ div#add_comment,div#edit_column, div#history, div#backlink, input.delete_comment display: none; } -th { +th { padding: 1px 3px; font-weight: normal; border-width: 1px; @@ -130,7 +130,7 @@ th a{ color: black; } -td.date { +td.date { text-align: left; } diff --git a/vcs_test.rb b/vcs_test.rb index cd96bf1..1c5d517 100644 --- a/vcs_test.rb +++ b/vcs_test.rb @@ -21,7 +21,7 @@ if __FILE__ == $0 require "test/unit" require "pp" unless ARGV[0] - puts "Usage: ruby #{$0} git" + puts "Usage: ruby #{$0} git" exit end require "vcs_#{ARGV[0]}" @@ -82,5 +82,5 @@ class VCS_test < Test::Unit::TestCase @t = "history" end -end +end end |