rename config.PREF_TIMEZONE_FALLBACK, add Cookie expire/path info, and move the hg version stuff into the template/helpers
--- 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 = '<a href="http://projects.qmsk.net/irclogs2">irclogs2</a> 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
--- 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
--- 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 <a href> 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
--- 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) :
"""
--- 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 @@
</div>
<div id="footer-left">
- ${config.HTML_FOOTER_TEXT}
+ <a href="http://projects.qmsk.net/irclogs2">irclogs2</a> version ${h.version_link()}
</div>
<div id="footer-center">