leichte Layout-Aufhuebschungen
This commit is contained in:
parent
115f9bdfbc
commit
1ba9bfed33
6 changed files with 85 additions and 61 deletions
32
helpers.py
Normal file
32
helpers.py
Normal file
|
@ -0,0 +1,32 @@
|
|||
import creoleparser
|
||||
import genshi
|
||||
import datetime
|
||||
from settings import DATE_FORMAT_SHORT, DATE_FORMAT_FULL
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
last_day = datetime.datetime.today() - datetime.timedelta(days=1)
|
||||
def show_timestamp(date):
|
||||
if date <= last_day:
|
||||
template = DATE_FORMAT_SHORT
|
||||
else:
|
||||
template = DATE_FORMAT_FULL
|
||||
return date.strftime(template)
|
||||
|
||||
def nav_links(prev_link, next_link):
|
||||
result = []
|
||||
if prev_link:
|
||||
result.append('<a href="%s" title="zeige neuere Einträge">aktuellere</a>' % prev_link)
|
||||
if next_link:
|
||||
result.append('<a href="%s" title="zeige ältere Einträge">ältere</a>' % next_link)
|
||||
return genshi.Markup(" | ".join(result))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue