lib/helpers.py
author Tero Marttila <terom@fixme.fi>
Sun, 08 Feb 2009 02:55:53 +0200
branchsites
changeset 43 fc11c4e86a82
parent 42 5a72c00c4ae4
permissions -rw-r--r--
implement channel_view count, the query stuff, css, layout all need some cleanup :(
26
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     1
"""
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     2
    Helper functions for use in templates
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     3
"""
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     4
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     5
import time
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     6
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     7
import config
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     8
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
     9
def now () :
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    10
    """
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    11
        Returns the current date/time
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    12
    """
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    13
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    14
    return time.strftime(config.DATETIME_FMT)
9d3beac1b196 remove foo.html page, and rice up the footer a bit
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    15
29
b06ff4c05d42 start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents: 28
diff changeset
    16
def copyright_year () :
b06ff4c05d42 start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents: 28
diff changeset
    17
    """
b06ff4c05d42 start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents: 28
diff changeset
    18
        Returns the current year
b06ff4c05d42 start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents: 28
diff changeset
    19
    """
b06ff4c05d42 start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents: 28
diff changeset
    20
b06ff4c05d42 start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents: 28
diff changeset
    21
    return time.strftime("%Y")
b06ff4c05d42 start prototyping some site-based code
Tero Marttila <terom@fixme.fi>
parents: 28
diff changeset
    22
42
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 29
diff changeset
    23
def validation_notice (site_host) :
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 29
diff changeset
    24
    """
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 29
diff changeset
    25
        Returns a short "Validated XHTML & CSS" link text for the given site hostname
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 29
diff changeset
    26
    """
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 29
diff changeset
    27
43
fc11c4e86a82 implement channel_view count, the query stuff, css, layout all need some cleanup :(
Tero Marttila <terom@fixme.fi>
parents: 42
diff changeset
    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(
42
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 29
diff changeset
    29
        host = site_host
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 29
diff changeset
    30
    )
5a72c00c4ae4 more fiddling around with the irclogs layout/css, add query args to URL
Tero Marttila <terom@fixme.fi>
parents: 29
diff changeset
    31
28
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    32
def breadcrumb (trail, links=True) :
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    33
    """
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    34
        Returns a nicely formatted breadcrumb tail, optinally with links
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    35
    """
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    36
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    37
    return ' &raquo; '.join(
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    38
        (
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    39
            '<a href="$site_url/%s">%s</a>' % (page.url, page.title) if links else page.title
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    40
        ) for page in trail
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    41
    )
b68145b5ce24 breadcrumb, but it's hidden
Tero Marttila <terom@fixme.fi>
parents: 26
diff changeset
    42