Add thumbnail image to Atom feed.
authorBen Sturmfels <ben@sturm.com.au>
Fri, 7 Oct 2016 12:12:25 +0000 (23:12 +1100)
committerAndrew Browning <ayleph@thisshitistemp.com>
Fri, 4 Nov 2016 05:24:10 +0000 (01:24 -0400)
Signed-off-by: Andrew Browning <ayleph@thisshitistemp.com>
mediagoblin/listings/views.py

index f640cc9521281ee748ca7215cd2e727bb5d99558..181486c25778316caabd428566871aaf66b26cf3 100644 (file)
 from mediagoblin import mg_globals
 from mediagoblin.db.models import MediaEntry
 from mediagoblin.db.util import media_entries_for_tag_slug
+from mediagoblin.decorators import uses_pagination
+from mediagoblin.plugins.api.tools import get_media_file_paths
 from mediagoblin.tools.pagination import Pagination
 from mediagoblin.tools.response import render_to_response
-from mediagoblin.decorators import uses_pagination
 
 from werkzeug.contrib.atom import AtomFeed
 
@@ -102,8 +103,16 @@ def atom_feed(request):
         links=atomlinks)
 
     for entry in cursor:
+        # Include a thumbnail image in content.
+        file_urls = get_media_file_paths(entry.media_files, request.urlgen)
+        if 'thumb' in file_urls:
+            content = '<img src="{thumb}" alt='' /> {desc}'.format(
+                thumb=file_urls['thumb'], desc=entry.description_html)
+        else:
+            content = entry.description_html
+
         feed.add(entry.get('title'),
-            entry.description_html,
+            content,
             id=entry.url_for_self(request.urlgen,qualified=True),
             content_type='html',
             author={'name': entry.get_actor.username,