Advertise the WebSub hub inside all Atom feeds, to make sure subscribers know it exists
This commit is contained in:
parent
39d0a64c34
commit
9f3cbac3c4
1 changed files with 10 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
from django.conf import settings
|
||||||
from django.contrib.sites.models import Site
|
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
|
||||||
|
@ -8,6 +9,13 @@ from ..kinds import on_home
|
||||||
from ..models import Entry
|
from ..models import Entry
|
||||||
|
|
||||||
|
|
||||||
|
class Atom1FeedWithHub(Atom1Feed):
|
||||||
|
def add_root_elements(self, handler):
|
||||||
|
super().add_root_elements(handler)
|
||||||
|
handler.startElement('link', {'rel': 'hub', 'href': settings.PUSH_HUB})
|
||||||
|
handler.endElement('link')
|
||||||
|
|
||||||
|
|
||||||
class EntriesFeed(Feed):
|
class EntriesFeed(Feed):
|
||||||
def item_title(self, entry):
|
def item_title(self, entry):
|
||||||
return entry.title
|
return entry.title
|
||||||
|
@ -59,7 +67,7 @@ class RssByKind(EntriesFeed):
|
||||||
|
|
||||||
|
|
||||||
class AtomByKind(RssByKind):
|
class AtomByKind(RssByKind):
|
||||||
feed_type = Atom1Feed
|
feed_type = Atom1FeedWithHub
|
||||||
subtitle = RssByKind.description
|
subtitle = RssByKind.description
|
||||||
|
|
||||||
|
|
||||||
|
@ -80,5 +88,5 @@ class RssHomeEntries(EntriesFeed):
|
||||||
|
|
||||||
|
|
||||||
class AtomHomeEntries(RssHomeEntries):
|
class AtomHomeEntries(RssHomeEntries):
|
||||||
feed_type = Atom1Feed
|
feed_type = Atom1FeedWithHub
|
||||||
subtitle = RssHomeEntries.description
|
subtitle = RssHomeEntries.description
|
||||||
|
|
Loading…
Reference in a new issue