Mercurial > libervia-web
diff libervia/pages/blog/view/page_meta.py @ 1171:469d0de8da0e
pages (blog, u): added atom feed link in "links" template data.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 26 Apr 2019 08:42:27 +0200 |
parents | 3048bd137aaf |
children | 0f37b65fe7c2 |
line wrap: on
line diff
--- a/libervia/pages/blog/view/page_meta.py Fri Apr 12 14:12:53 2019 +0200 +++ b/libervia/pages/blog/view/page_meta.py Fri Apr 26 08:42:27 2019 +0200 @@ -13,6 +13,7 @@ from sat.tools.common import uri from sat.tools.common import data_format from libervia.server import utils +from libervia.server.utils import SubPage from sat.core.log import getLogger log = getLogger(__name__) @@ -57,19 +58,20 @@ self.pageError(request, C.HTTP_BAD_REQUEST) try: - data['node'] = self.nextPath(request) + node = self.nextPath(request) except IndexError: - data['node'] = u'' - else: - if data['node'] == u'@': - data['node'] = u'' + node = u'@' + data['node'] = u'' if node == u'@' else node try: filter_kw = data['filter_keyword'] = self.nextPath(request) except IndexError: - pass + filter_kw = u'@' else: - if filter_kw == u'id': + if filter_kw == u'@': + # No filter, this is used when a subpage is needed, notably Atom feed + pass + elif filter_kw == u'id': try: data[u'item'] = self.nextPath(request) except IndexError: @@ -86,9 +88,25 @@ self.pageError(request, C.HTTP_BAD_REQUEST) else: # invalid filter keyword - log.warning(_(u"invalid filter keyword: {filter_kw}").format(filter_kw=filter_kw)) + log.warning(_(u"invalid filter keyword: {filter_kw}").format( + filter_kw=filter_kw)) self.pageError(request, C.HTTP_BAD_REQUEST) + # if URL is parsed here, we'll have atom.xml available and we need to + # add the link to the page + atom_url = self.getURLByPath( + SubPage(u'blog_view'), + service, + node, + filter_kw, + SubPage(u'blog_feed_atom'), + ) + request.template_data.setdefault(u'links', []).append({ + u"href": atom_url, + u"type": "application/atom+xml", + u"rel": "alternate", + u"title": "{service}'s blog".format(service=service)}) + @defer.inlineCallbacks def appendComments(self, blog_items, identities, profile):