RSS support
This commit is contained in:
parent
1fc2fcbd7e
commit
89fa8efd87
|
@ -0,0 +1,24 @@
|
|||
from django.contrib.syndication.views import Feed
|
||||
|
||||
from main.models import Thought
|
||||
|
||||
|
||||
class MainFeed(Feed):
|
||||
title = "Thoughts"
|
||||
link = "/"
|
||||
|
||||
@staticmethod
|
||||
def items():
|
||||
return Thought.objects.all().order_by("-posted")
|
||||
|
||||
def item_title(self, item):
|
||||
return item.text
|
||||
|
||||
def item_description(self, item):
|
||||
return item.extended_text
|
||||
|
||||
def item_link(self, item):
|
||||
return "/"
|
||||
|
||||
def item_pubdate(self, item):
|
||||
return item.posted
|
|
@ -162,4 +162,4 @@ footer {
|
|||
width: 100%;
|
||||
padding: 10px;
|
||||
height: 20px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
<link rel="icon" sizes="192x192" href="{% static 'images/favicon-192x192.png'%}">
|
||||
<link rel="apple-touch-icon" href="{% static 'images/apple-touch-icon.png'%}"/>
|
||||
|
||||
<link rel="alternate" href="/feed" type="application/rss+xml" title="RSS">
|
||||
</head>
|
||||
<body>
|
||||
<header><span class="text">Thoughts</span>{% if authenticated %}
|
||||
|
|
|
@ -16,8 +16,10 @@ Including another URLconf
|
|||
from django.urls import path
|
||||
|
||||
from main import views
|
||||
from main.feed import MainFeed
|
||||
|
||||
urlpatterns = [
|
||||
path("", views.index, name="index"),
|
||||
path("post", views.post, name="post"),
|
||||
path("feed", MainFeed())
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue