diff --git a/articles/models.py b/articles/models.py
index f65c339..e5d960b 100644
--- a/articles/models.py
+++ b/articles/models.py
@@ -4,6 +4,7 @@ from functools import cached_property
import rcssmin
import readtime
+from django.conf import settings
from django.contrib.auth.models import AbstractUser
from django.contrib.contenttypes.models import ContentType
from django.db import models
@@ -33,6 +34,15 @@ class Tag(models.Model):
def __str__(self):
return self.name
+ def get_absolute_url(self):
+ return reverse("tag", kwargs={"slug": self.slug})
+
+ def get_feed_title(self):
+ return f"{self.name} - {settings.BLOG['title']}"
+
+ def get_feed_url(self):
+ return reverse("tag-feed", kwargs={"slug": self.slug})
+
class Article(models.Model):
DRAFT = "draft"
diff --git a/articles/templates/articles/article_list.html b/articles/templates/articles/article_list.html
index f7aae61..6de2a18 100644
--- a/articles/templates/articles/article_list.html
+++ b/articles/templates/articles/article_list.html
@@ -1,5 +1,12 @@
{% extends 'articles/base.html' %}
+{% block feed_link %}
+ {{ block.super }}
+ {% if feed_url and feed_title %}
+
+ {% endif %}
+{% endblock %}
+
{% block append_css %}
diff --git a/articles/templates/articles/base.html b/articles/templates/articles/base.html
index b0e005d..849d2f3 100644
--- a/articles/templates/articles/base.html
+++ b/articles/templates/articles/base.html
@@ -8,7 +8,9 @@
{% block title %}Home | {% endblock %}{{ blog_title }} by {{ blog_author }}
-
+ {% block feed_link %}
+
+ {% endblock %}
{% include "articles/snippets/analytics_head.html" %}
{% include "articles/snippets/page_metadata.html" %}
diff --git a/articles/views/feeds.py b/articles/views/feeds.py
index c66bb3f..dcc0479 100644
--- a/articles/views/feeds.py
+++ b/articles/views/feeds.py
@@ -6,7 +6,7 @@ from blog import settings
class CompleteFeed(Feed):
FEED_LIMIT = 15
- title = "Gab's Notes"
+ title = settings.BLOG["title"]
link = settings.BLOG["base_url"]
description = settings.BLOG["description"]
@@ -31,3 +31,9 @@ class TagFeed(CompleteFeed):
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()
diff --git a/articles/views/html.py b/articles/views/html.py
index 4174e3d..b92e429 100644
--- a/articles/views/html.py
+++ b/articles/views/html.py
@@ -88,9 +88,20 @@ class SearchArticlesListView(PublicArticleListView):
class TagArticlesListView(PublicArticleListView):
+ tag = None
+
+ def dispatch(self, request, *args, **kwargs):
+ self.tag = get_object_or_404(Tag, slug=self.kwargs.get("slug"))
+ return super().dispatch(request, *args, **kwargs)
+
+ def get_context_data(self, **kwargs):
+ context = super().get_context_data(**kwargs)
+ context["feed_title"] = self.tag.get_feed_title()
+ context["feed_url"] = self.tag.get_feed_url()
+ return context
+
def get_queryset(self):
- tag = get_object_or_404(Tag, slug=self.kwargs.get("slug"))
- return super().get_queryset().filter(tags=tag)
+ return super().get_queryset().filter(tags=self.tag)
class DraftsListView(LoginRequiredMixin, BaseArticleListView):