#!/usr/bin/env ruby ############################################################################ # Copyright 2009 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 . # ############################################################################ if __FILE__ == $0 $:.push("..") require "dudle" $d = Dudle.new("Customize") $d << <Customize Personal Settings You need cookies enabled in order to personalize your settings. END def choosetable(tablesummary, options, cursetting) ret = < Current Setting Description HEAD options.each{|description,href,title| selected = href == cursetting ret += "" ret += CROSS if selected ret += "" ret += "" unless selected ret += description ret += "" unless selected ret += "" } ret += "" 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 << <

Charset

#{choosetable("Charset settings",a,USEUTF ? "utf" : "ascii")} CHARSET css = $cgi.cookies["css"][0] css = $cgi["css"] if $cgi.include?("css") css ||= "default.css" $d.html.add_cookie("css",css,"/",Time.now + (1*60*60*24*365 * (css == "dudle.css" ? -1 : 1 ))) $d << <

Stylesheet

#{choosetable("Stylesheet settings",$d.css.collect{|href| [href.scan(/([^\/]*)\.css/).flatten[0],"css=#{href}"]},"css=#{css}")} CSS username = $cgi.cookies["username"][0] if $cgi.include?("delete_username") $d.html.add_cookie("username","","/",Time.now - 1*60*60*24*365) username = nil elsif $cgi.include?("username") username = $cgi["username"] $d.html.add_cookie("username",username,"/",Time.now + 1*60*60*24*365) end $d << <

Default Username

CHARSET if username && !$cgi.include?("edit") $d << <#{username}
CHARSET else $d << <
CHARSET end $d.html << "" if username $d << <
CHARSET $d.out($cgi) end