diff --git a/articles/templates/articles/base.html b/articles/templates/articles/base.html index ea2433b..1ba0712 100644 --- a/articles/templates/articles/base.html +++ b/articles/templates/articles/base.html @@ -5,12 +5,13 @@ Gab's Notes +
diff --git a/articles/views/__init__.py b/articles/views/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/articles/views/feeds.py b/articles/views/feeds.py new file mode 100644 index 0000000..93b1053 --- /dev/null +++ b/articles/views/feeds.py @@ -0,0 +1,24 @@ +from django.contrib.syndication.views import Feed + +from articles.models import Article +from blog import settings + + +class CompleteFeed(Feed): + title = "Gab's Notes" + link = settings.BLOG["base_url"] + description = settings.BLOG["description"] + + def items(self): + return Article.objects.filter(status=Article.PUBLISHED).order_by( + "-published_at" + )[:15] + + def item_title(self, item: Article): + return item.title + + def item_description(self, item: Article): + return item.get_formatted_content() + + def item_pubdate(self, item: Article): + return item.published_at diff --git a/articles/views.py b/articles/views/html.py similarity index 100% rename from articles/views.py rename to articles/views/html.py diff --git a/blog/settings.py b/blog/settings.py index cb80f11..a635866 100644 --- a/blog/settings.py +++ b/blog/settings.py @@ -115,3 +115,8 @@ USE_TZ = True STATIC_URL = "/static/" AUTH_USER_MODEL = "articles.User" + +BLOG = { + "description": "My take on tech-related subjects (but not only)", + "base_url": "https://gabnotes.org/", +} diff --git a/blog/urls.py b/blog/urls.py index 04add88..354d4b0 100644 --- a/blog/urls.py +++ b/blog/urls.py @@ -16,11 +16,12 @@ Including another URLconf from django.contrib import admin from django.urls import path -from articles import views +from articles.views import feeds, html urlpatterns = [ path("admin/", admin.site.urls), - path("", views.ArticlesListView.as_view(), name="articles-list"), - path("drafts/", views.DraftsListView.as_view(), name="drafts-list"), - path("", views.ArticleDetailView.as_view(), name="article-detail"), + path("", html.ArticlesListView.as_view(), name="articles-list"), + path("drafts/", html.DraftsListView.as_view(), name="drafts-list"), + path("", html.ArticleDetailView.as_view(), name="article-detail"), + path("feed/", feeds.CompleteFeed(), name="complete-feed"), ]