Mercurial > public > sg101
diff forums/latest.py @ 792:7429c98c8ece
Issue #71: use relative URLs for smileys on the web and absolute for RSS.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Mon, 26 May 2014 14:59:55 -0500 |
parents | 89b240fe9297 |
children | 90e8cc6eff77 |
line wrap: on
line diff
--- a/forums/latest.py Fri May 23 21:52:41 2014 -0500 +++ b/forums/latest.py Mon May 26 14:59:55 2014 -0500 @@ -64,6 +64,7 @@ from forums.views.subscriptions import notify_topic_subscribers from forums.tools import auto_favorite, auto_subscribe from core.services import get_redis_connection +from core.markup import site_markup # This constant controls how many latest posts per forum we store MAX_POSTS = 50 @@ -453,16 +454,17 @@ """Serialize a post to JSON and return it. """ + # Use absolute URLs for smileys for RSS. This means we have to reconvert the + # post Markdown to HTML. + content = site_markup(post.body, relative_urls=False) + # get any attachments for the post - attachments = Attachment.objects.filter(post=post).select_related( 'embed').order_by('order') embeds = [item.embed for item in attachments] - if len(embeds) == 0: - content = post.html - else: + if len(embeds): content = render_to_string('forums/post_rss.html', { - 'post': post, + 'content': content, 'embeds': embeds, })