lib/helpers.py
author Tero Marttila <terom@fixme.fi>
Sat, 07 Feb 2009 06:05:10 +0200
branchsites
changeset 29 b06ff4c05d42
parent 28 b68145b5ce24
child 42 5a72c00c4ae4
permissions -rw-r--r--
start prototyping some site-based code
"""
    Helper functions for use in templates
"""

import time

import config

def now () :
    """
        Returns the current date/time
    """

    return time.strftime(config.DATETIME_FMT)

def copyright_year () :
    """
        Returns the current year
    """

    return time.strftime("%Y")

def breadcrumb (trail, links=True) :
    """
        Returns a nicely formatted breadcrumb tail, optinally with links
    """

    return ' &raquo; '.join(
        (
            '<a href="$site_url/%s">%s</a>' % (page.url, page.title) if links else page.title
        ) for page in trail
    )