comparison 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
comparison
equal deleted inserted replaced
370:30d03d9f07e4 371:d7870ab9d1ff
84 <title>%(user)s's microblog</title> 84 <title>%(user)s's microblog</title>
85 </head> 85 </head>
86 <body> 86 <body>
87 <div class='mblog_title'>%(user)s</div> 87 <div class='mblog_title'>%(user)s</div>
88 """ % {'user': user}) 88 """ % {'user': user})
89 mblog_data = sorted(mblog_data, key=lambda entry: (-int(entry.get('published', 0)))) 89 mblog_data = sorted(mblog_data, key=lambda entry: (-float(entry.get('published', 0))))
90 for entry in mblog_data: 90 for entry in mblog_data:
91 timestamp = float(entry.get('published', 0)) 91 timestamp = float(entry.get('published', 0))
92 _datetime = datetime.fromtimestamp(timestamp) 92 _datetime = datetime.fromtimestamp(timestamp)
93 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 '') 93
94 def getText(key):
95 if ('%s_xhtml' % key) in entry:
96 return entry['%s_xhtml' % key].encode('utf-8')
97 elif key in entry:
98 processor = addURLToText if key.startswith('content') else sanitizeHtml
99 return processor(entry[key]).encode('utf-8')
100 return ''
101
94 body = getText('content') 102 body = getText('content')
95 title = getText('title') 103 title = getText('title')
96 if title: 104 if title:
97 body = "<h1>%s</h1>\n%s" % (title, body) 105 body = "<h1>%s</h1>\n%s" % (title, body)
98 request.write("""<div class='mblog_entry'><span class='mblog_timestamp'>%(date)s</span> 106 request.write("""<div class='mblog_entry'><span class='mblog_timestamp'>%(date)s</span>