Mercurial > libervia-web
changeset 371:d7870ab9d1ff
server_side: blog: bug fixes
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 23 Feb 2014 17:22:05 +0100 |
parents | 30d03d9f07e4 |
children | 564208366dd6 |
files | libervia_server/blog.py |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia_server/blog.py Sun Feb 23 17:01:03 2014 +0100 +++ b/libervia_server/blog.py Sun Feb 23 17:22:05 2014 +0100 @@ -86,11 +86,19 @@ <body> <div class='mblog_title'>%(user)s</div> """ % {'user': user}) - mblog_data = sorted(mblog_data, key=lambda entry: (-int(entry.get('published', 0)))) + mblog_data = sorted(mblog_data, key=lambda entry: (-float(entry.get('published', 0)))) for entry in mblog_data: timestamp = float(entry.get('published', 0)) _datetime = datetime.fromtimestamp(timestamp) - getText = lambda key: entry['%s_xhtml' % key].encode() if ('%s_xhtml' % key) in entry else (addURLToText(sanitizeHtml(entry[key])).encode('utf-8') if key in entry else '') + + def getText(key): + if ('%s_xhtml' % key) in entry: + return entry['%s_xhtml' % key].encode('utf-8') + elif key in entry: + processor = addURLToText if key.startswith('content') else sanitizeHtml + return processor(entry[key]).encode('utf-8') + return '' + body = getText('content') title = getText('title') if title: