lib/helpers.py
changeset 46 185504387370
parent 45 e94ab812c0c8
child 47 3d59c9eeffaa
equal deleted inserted replaced
45:e94ab812c0c8 46:185504387370
     1 """
       
     2     Helper functions for use in templates
       
     3 """
       
     4 
       
     5 import time
       
     6 
       
     7 import config
       
     8 
       
     9 def now () :
       
    10     """
       
    11         Returns the current date/time
       
    12     """
       
    13 
       
    14     return time.strftime(config.DATETIME_FMT)
       
    15 
       
    16 def copyright_year () :
       
    17     """
       
    18         Returns the current year
       
    19     """
       
    20 
       
    21     return time.strftime("%Y")
       
    22 
       
    23 def validation_notice (site_host) :
       
    24     """
       
    25         Returns a short "Validated XHTML & CSS" link text for the given site hostname
       
    26     """
       
    27 
       
    28     return 'Validated <a href="http://validator.w3.org/check?uri=http://%(host)s">XHTML 1.0 Strict</a> &amp; <a href="http://jigsaw.w3.org/css-validator/validator?uri=http://%(host)s">CSS 2.1</a>' % dict(
       
    29         host = site_host
       
    30     )
       
    31 
       
    32 def breadcrumb (trail, links=True) :
       
    33     """
       
    34         Returns a nicely formatted breadcrumb tail, optinally with links
       
    35     """
       
    36 
       
    37     return ' &raquo; '.join(
       
    38         (
       
    39             '<a href="$site_url/%s">%s</a>' % (page.url, page.title) if links else page.title
       
    40         ) for page in trail
       
    41     )
       
    42