tycker/templates/layout.html

55 lines
1.4 KiB
HTML
Raw Normal View History

2012-04-20 03:50:59 +02:00
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:py="http://genshi.edgewall.org/" py:strip="">
<py:match path="head" once="true">
<head py:attrs="select('@*')">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
${select('*|text()')}
</head>
</py:match>
<?python
import creoleparser
import genshi
import datetime
def formatter(text):
if not text:
return u""
text = text.replace("\\", "\\\\")
html = creoleparser.text2html(text, encoding=None).strip()
if html.startswith("<p>") and html.endswith("</p>"):
html = html[3:-4]
return genshi.Markup(html)
TODAY_FORMAT = "%H:%M"
FULL_FORMAT = "%d.%m.%y %H:%M"
last_day = datetime.datetime.today() - datetime.timedelta(days=1)
def show_timestamp(date):
if date <= last_day:
template = TODAY_FORMAT
else:
template = FULL_FORMAT
return date.strftime(template)
def nav_links():
result = []
if prev_link:
result.append('<a href="%s" title="zeige neuere Eintr&auml;ge">aktuellere</a>' % prev_link)
if next_link:
result.append('<a href="%s" title="zeige &auml;ltere Eintr&auml;ge">&auml;ltere</a>' % next_link)
return genshi.Markup(" | ".join(result))
?>
<py:match path="body" once="true">
<body py:attrs="select('@*')">
${select('*|text()')}
</body>
</py:match>
</html>