From d740d6a8da7efa36c9b87797072dcdff28bd69fe Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Thu, 17 Jul 2025 11:00:20 +0200 Subject: [PATCH] make read more a link --- hub/services/feeds.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/hub/services/feeds.py b/hub/services/feeds.py index 5205318..29045ef 100644 --- a/hub/services/feeds.py +++ b/hub/services/feeds.py @@ -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} Read more...' def item_link(self, item): """Return the link to the article detail page"""