config.py
author Tero Marttila <terom@fixme.fi>
Sun, 15 Feb 2009 23:50:24 +0200
changeset 129 67a30d680f60
parent 128 2a8a190f8aee
child 131 67f5d2fdca1d
permissions -rw-r--r--
Autodetect user timezone using Javascript, this makes the Preferences code a bit more complicated in terms of interaction between default/parse/is_default/build/process/etc, but it should work as intended now
"""
    Configureable defaults
"""

import os.path, pytz
from log_parser import IrssiParser
from log_channel import LogChannel
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
relpath = lambda path : os.path.join(os.path.dirname(__file__), path)

###                     ###
###    Configuration    ###
###                     ###

# timezone to use for logs
LOG_TIMEZONE                    = pytz.timezone('Europe/Helsinki')

# timestamp format for logfiles
LOG_TIMESTAMP_FMT               = '%H:%M:%S'

# the decoder used for logfiles
LOG_DECODER                     = LogSourceDecoder((
    ('utf-8',       'strict'),
    ('latin-1',     'replace'),
))

# log filename format
LOG_FILENAME_FMT                = '%Y-%m-%d'

# the log parser that we use
LOG_PARSER                      = IrssiParser(LOG_TIMEZONE, LOG_TIMESTAMP_FMT)
#LOG_PARSER_FULLTS               = IrssiParser(LOG_TIMEZONE, '%Y%m%d%H%M%S')

# the statically defined channel list
LOG_CHANNELS                    = ChannelList([
    LogChannel('tycoon',    "OFTC",     "#tycoon", 
        LogDirectory(relpath('/home/spbot/irclogs/tycoon'),    LOG_TIMEZONE, LOG_PARSER, LOG_DECODER, LOG_FILENAME_FMT)
    ),

    LogChannel('openttd',   "OFTC",     "#openttd", 
        LogDirectory(relpath('/home/spbot/irclogs/openttd'),   LOG_TIMEZONE, LOG_PARSER, LOG_DECODER, LOG_FILENAME_FMT)
    ),

    LogChannel('test',      "TEST",     "#test",
        LogDirectory(relpath('/home/spbot/irclogs/test'),  LOG_TIMEZONE, LOG_PARSER, LOG_DECODER, LOG_FILENAME_FMT)
    )
])

# version stuff
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)

# how to handle decode() errors for logfile lines
LOG_SOURCE_DECODE_ERRORS        = 'replace'

# date format for URLs
URL_DATE_FMT                    = '%Y-%m-%d'

# month name format
MONTH_FMT                       = '%B %Y'

# timezone name format
TIMEZONE_FMT                    = '%Z %z'

# TTF fonts to use for drawing images
FORMATTER_IMAGE_FONTS =         {
    # XXX: no unicode support
    #    'default':              (None,                                                                  "Ugly default font"         ),
    'ttf-dejavu-mono':      ("/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf",             "DejaVu Sans Mono"          ),
    'ttf-liberation-mono':  ("/usr/share/fonts/truetype/ttf-liberation/LiberationMono-Regular.ttf", "Liberation Mono Regular"   )
}

# available formatters
LOG_FORMATTERS =                {
    'irssi':        IrssiFormatter,
    'debug':        DebugFormatter,
}

# default preferences
PREF_TIME_FMT_DEFAULT           = '%H:%M:%S'
PREF_DATE_FMT_DEFAULT           = '%Y-%m-%d'
PREF_TIMEZONE_DEFAULT           = pytz.utc
PREF_FORMATTER_DEFAULT          = IrssiFormatter
PREF_COUNT_DEFAULT              = 200
PREF_COUNT_MAX                  = None
PREF_IMAGE_FONT_DEFAULT         = 'ttf-dejavu-mono'
PREF_IMAGE_FONT_SIZE_DEFAULT    = 12
PREF_IMAGE_FONT_SIZE_MAX        = 32

# search line count options
SEARCH_LINE_COUNT_OPTIONS       = (
    (50,    50), 
    (100,   100), 
    (200,   200), 
    (None,  "&#8734;"),
)

# search index database path
SEARCH_INDEX_PATH               = '/home/spbot/irclogs/search-index'
SEARCH_AUTOINDEX_PATH           = '/home/spbot/irclogs/search-autoindex'