# HG changeset patch # User Tero Marttila # Date 1234738340 -7200 # Node ID 67f5d2fdca1d88e5a41fd01e9bf802485757f467 # Parent 4212fd69d6715183bd323b787b3a7a34f376e5aa rename config.PREF_TIMEZONE_FALLBACK, add Cookie expire/path info, and move the hg version stuff into the template/helpers diff -r 4212fd69d671 -r 67f5d2fdca1d config.py --- a/config.py Sun Feb 15 23:55:48 2009 +0200 +++ b/config.py Mon Feb 16 00:52:20 2009 +0200 @@ -8,7 +8,6 @@ from log_source import LogSourceDecoder, LogDirectory from log_formatter import IrssiFormatter, DebugFormatter from channels import ChannelList -import version import log_formatter # build relative paths to the dir containing this file @@ -52,12 +51,11 @@ ) ]) -# version stuff +# URL to the hgweb installation for this code HGWEB_URL = "http://hg.qmsk.net/irclogs2" -VERSION_LINK = version.version_link_hg(HGWEB_URL, relpath(".")) -# Footer text to display -HTML_FOOTER_TEXT = 'irclogs2 version %s' % (VERSION_LINK) +# path to the mercurial working copy containing this code +HG_WC_PATH = relpath(".") # how to handle decode() errors for logfile lines LOG_SOURCE_DECODE_ERRORS = 'replace' @@ -85,10 +83,14 @@ 'debug': DebugFormatter, } +# Cookie settings +PREF_COOKIE_PATH = '/' +PREF_COOKIE_EXPIRE_SECONDS = 1 * 365 * 24 * 60 * 60 # one year + # default preferences PREF_TIME_FMT_DEFAULT = '%H:%M:%S' PREF_DATE_FMT_DEFAULT = '%Y-%m-%d' -PREF_TIMEZONE_DEFAULT = pytz.utc +PREF_TIMEZONE_FALLBACK = pytz.utc PREF_FORMATTER_DEFAULT = IrssiFormatter PREF_COUNT_DEFAULT = 200 PREF_COUNT_MAX = None diff -r 4212fd69d671 -r 67f5d2fdca1d handlers.py --- a/handlers.py Sun Feb 15 23:55:48 2009 +0200 +++ b/handlers.py Mon Feb 16 00:52:20 2009 +0200 @@ -95,6 +95,7 @@ date_prev = channel.source.get_prev_date(date), ) +@preferences.handler() def index (request) : """ The topmost index page, display a list of available channels, perhaps some general stats @@ -102,6 +103,7 @@ return templates.render_to_response("index", req = request, + prefs = request.prefs, ) # XXX: fix this namespace crap diff -r 4212fd69d671 -r 67f5d2fdca1d helpers.py --- a/helpers.py Sun Feb 15 23:55:48 2009 +0200 +++ b/helpers.py Mon Feb 16 00:52:20 2009 +0200 @@ -7,7 +7,7 @@ import qmsk.web.helpers -import preferences, urls, config +import preferences, urls, config, version class Helpers (qmsk.web.helpers.Helpers) : """ @@ -23,6 +23,14 @@ # list of (month_num, month_name) for the months in the year months = list(enumerate(_calendar.month_name))[1:] + + def version_link (self) : + """ + Returns a representing this version of the software + """ + + return version.version_link_hg(config.HGWEB_URL, config.HG_WC_PATH) + def tz_name (self, tz) : """ Returns a string describing the given timezone diff -r 4212fd69d671 -r 67f5d2fdca1d preferences.py --- a/preferences.py Sun Feb 15 23:55:48 2009 +0200 +++ b/preferences.py Mon Feb 16 00:52:20 2009 +0200 @@ -283,6 +283,8 @@ else : # set cookies[key] = value + cookies[key]["path"] = config.PREF_COOKIE_PATH + cookies[key]["expires"] = config.PREF_COOKIE_EXPIRE_SECONDS # add headers for morsel in cookies.itervalues() : @@ -369,10 +371,10 @@ def is_default (self, tz) : """ - True if it's a FixedOffsetTimezone or PREF_TIMEZONE_DEFAULT + True if it's a FixedOffsetTimezone or PREF_TIMEZONE_FALLBACK """ - return (isinstance(tz, utils.FixedOffsetTimezone) or tz == config.PREF_TIMEZONE_DEFAULT) + return (isinstance(tz, utils.FixedOffsetTimezone) or tz == config.PREF_TIMEZONE_FALLBACK) def build (self, tz) : """ @@ -393,7 +395,7 @@ If this timezone is given, simply build that. Otherwise, try and use TimezoneOffset, and if that fails, just return the default. - None -> FixedOffsetTimezone/PREF_TIMEZONE_DEFAULT + None -> FixedOffsetTimezone/PREF_TIMEZONE_FALLBACK pytz.timezone -> pytz.timezone """ @@ -407,7 +409,7 @@ # default else : - return config.PREF_TIMEZONE_DEFAULT + return config.PREF_TIMEZONE_FALLBACK class ImageFont (Preference) : """ diff -r 4212fd69d671 -r 67f5d2fdca1d templates/layout.tmpl --- a/templates/layout.tmpl Sun Feb 15 23:55:48 2009 +0200 +++ b/templates/layout.tmpl Mon Feb 16 00:52:20 2009 +0200 @@ -72,7 +72,7 @@