Mercurial > libervia-web
diff libervia_server/blog.py @ 371:d7870ab9d1ff
server_side: blog: bug fixes
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 23 Feb 2014 17:22:05 +0100 |
parents | 2109d7d30ffc |
children | 41a386a27002 |
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: