Gab's Notes backend https://gabnotes.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

39 lines
1.0 KiB

from django.contrib.syndication.views import Feed
from articles.models import Article, Tag
from blog import settings
class CompleteFeed(Feed):
FEED_LIMIT = 15
title = settings.BLOG["title"]
link = settings.BLOG["base_url"]
description = settings.BLOG["description"]
def get_queryset(self, obj):
return Article.objects.filter(status=Article.PUBLISHED).order_by(
"-published_at"
)
def items(self, obj):
return self.get_queryset(obj)[: self.FEED_LIMIT]
def item_description(self, item: Article): # type: ignore[override]
return item.get_formatted_content
def item_pubdate(self, item: Article):
return item.published_at
class TagFeed(CompleteFeed):
def get_object(self, request, *args, **kwargs):
return Tag.objects.get(slug=kwargs.get("slug"))
def get_queryset(self, tag):
return super().get_queryset(tag).filter(tags=tag)
def title(self, tag):
return tag.get_feed_title()
def link(self, tag):
return tag.get_absolute_url()