helpers.py
changeset 46 54c5f5f340de
parent 43 fc11c4e86a82
child 47 99c45fc13edc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/helpers.py	Sun Feb 08 03:17:07 2009 +0200
@@ -0,0 +1,42 @@
+"""
+    Helper functions for use in templates
+"""
+
+import time
+
+from qmsk.web 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 validation_notice (site_host) :
+    """
+        Returns a short "Validated XHTML & CSS" link text for the given site hostname
+    """
+
+    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(
+        host = site_host
+    )
+
+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
+    )
+