mirror of
https://github.com/jointakahe/takahe.git
synced 2024-11-29 02:31:00 +00:00
Attach the first image of post to RSS feed (#333)
This commit is contained in:
parent
05adbace24
commit
d8ff43dc28
1 changed files with 13 additions and 0 deletions
|
@ -6,6 +6,7 @@ from django.contrib.syndication.views import Feed
|
|||
from django.core import validators
|
||||
from django.http import Http404, JsonResponse
|
||||
from django.shortcuts import redirect
|
||||
from django.utils import feedgenerator
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views.decorators.vary import vary_on_headers
|
||||
from django.views.generic import FormView, ListView, TemplateView, View
|
||||
|
@ -128,6 +129,18 @@ class IdentityFeed(Feed):
|
|||
def item_pubdate(self, item: Post):
|
||||
return item.published
|
||||
|
||||
def item_enclosures(self, item: Post):
|
||||
attachment = item.attachments.first()
|
||||
if attachment is None:
|
||||
return []
|
||||
|
||||
enc = feedgenerator.Enclosure(
|
||||
url=attachment.full_url().absolute,
|
||||
length=str(attachment.file.size),
|
||||
mime_type=attachment.mimetype,
|
||||
)
|
||||
return [enc]
|
||||
|
||||
|
||||
class IdentityFollows(ListView):
|
||||
"""
|
||||
|
|
Loading…
Reference in a new issue