Whoops, include an updated date on items in Atom/RSS but do it correctly? Also made a few other minor improvements to the feeds

This commit is contained in:
Danielle McLean 2018-05-11 13:45:26 +10:00
parent 03b2668969
commit aec98120ab
Signed by: 00dani
GPG key ID: D111F8C5A2560F19
2 changed files with 11 additions and 4 deletions

View file

@ -137,6 +137,10 @@ class Entry(ModelMeta, TimeStampedModel):
return '{0} {1}: {2}'.format(self.kind, self.id, self.title) return '{0} {1}: {2}'.format(self.kind, self.id, self.title)
def get_absolute_url(self): def get_absolute_url(self):
return self.absolute_url
@property
def absolute_url(self):
base = 'https://' + Site.objects.get_current().domain base = 'https://' + Site.objects.get_current().domain
return urljoin(base, self.url) return urljoin(base, self.url)

View file

@ -3,7 +3,6 @@ from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed from django.contrib.syndication.views import Feed
from django.urls import reverse from django.urls import reverse
from django.utils.feedgenerator import Atom1Feed from django.utils.feedgenerator import Atom1Feed
from urllib.parse import urljoin
from lemoncurry.templatetags.markdown import markdown from lemoncurry.templatetags.markdown import markdown
from ..kinds import on_home from ..kinds import on_home
from ..models import Entry from ..models import Entry
@ -17,6 +16,11 @@ class Atom1FeedWithHub(Atom1Feed):
class EntriesFeed(Feed): class EntriesFeed(Feed):
item_guid_is_permalink = True
def item_link(self, entry):
return entry.absolute_url
def item_title(self, entry): def item_title(self, entry):
return entry.title return entry.title
@ -30,13 +34,12 @@ class EntriesFeed(Feed):
return entry.author.email return entry.author.email
def item_author_link(self, entry): def item_author_link(self, entry):
base = 'https://' + Site.objects.get_current().domain return entry.author.absolute_url
return urljoin(base, entry.author.url)
def item_pubdate(self, entry): def item_pubdate(self, entry):
return entry.published return entry.published
def item_updatedate(self, entry): def item_updateddate(self, entry):
return entry.updated return entry.updated
def item_categories(self, entry): def item_categories(self, entry):