make read more a link

This commit is contained in:
Tobias Brunner 2025-07-17 11:00:20 +02:00
parent faf73d3ea4
commit d740d6a8da
Signed by: tobru
SSH key fingerprint: SHA256:kOXg1R6c11XW3/Pt9dbLdQvOJGFAy+B2K6v6PtRWBGQ

View file

@ -6,6 +6,9 @@ from django.contrib.syndication.views import Feed
from django.urls import reverse
from django.utils.feedgenerator import Rss201rev2Feed
from django.utils.html import strip_tags
from django.conf import settings
from django.contrib.sites.models import Site
from .models import Article
@ -27,9 +30,22 @@ class ArticleRSSFeed(Feed):
def item_description(self, item):
"""Return the article excerpt with 'Read more' link"""
# Use the excerpt and add a read more link
# Get the current site domain for absolute URLs
try:
current_site = Site.objects.get_current()
domain = current_site.domain
protocol = "https" if getattr(settings, "USE_TLS", True) else "http"
base_url = f"{protocol}://{domain}"
except:
# Fallback if Site framework is not configured
base_url = "https://servala.com"
# Use the excerpt and add a proper HTML read more link
excerpt = strip_tags(item.excerpt)
return f"{excerpt} Read more..."
article_url = f"{base_url}{item.get_absolute_url()}"
# Return HTML content for the RSS description
return f'{excerpt} <a href="{article_url}">Read more...</a>'
def item_link(self, item):
"""Return the link to the article detail page"""