comparison src/pages/blog/atom.xml/page_meta.py @ 1077:880ea673aaff

blog: moved blog page from /common to /blog: - removed common pages (it was only used for blog so far, it may come back in the future if needed) - /blog now prepares a discover page by default
author Goffi <goffi@goffi.org>
date Mon, 26 Mar 2018 08:20:41 +0200
parents
children
comparison
equal deleted inserted replaced
1076:5bf288f84862 1077:880ea673aaff
1 #!/usr/bin/env python2.7
2 # -*- coding: utf-8 -*-
3
4 from libervia.server.constants import Const as C
5 from twisted.internet import defer
6 from sat.tools.common import uri
7 import time
8
9 name = u"blog_feed_atom"
10 access = C.PAGES_ACCESS_PUBLIC
11 template = u"blog/atom.xml"
12
13
14 @defer.inlineCallbacks
15 def prepare_render(self, request):
16 request.setHeader('Content-Type', 'application/atom+xml; charset=utf-8')
17 data = self.getRData(request)
18 service, node = data[u'service'], data.get(u'node')
19 self.checkCache(request, C.CACHE_PUBSUB, service=service, node=node, short='microblog')
20 data['show_comments'] = False
21 template_data = request.template_data
22 blog_page = self.getPageByName(u'blog')
23 yield blog_page.prepare_render(self, request)
24 items = data[u'items']
25
26 template_data[u'request_uri'] = self.host.getExtBaseURL(request, request.path.decode('utf-8'))
27 template_data[u'xmpp_uri'] = uri.buildXMPPUri(u'pubsub',
28 subtype=u'microblog',
29 path=service.full(),
30 node=node)
31 blog_view = self.getPageByName(u'blog_view')
32 template_data[u'http_uri'] = self.host.getExtBaseURL(request, blog_view.getURL(service.full(), node))
33 if items:
34 template_data[u'updated'] = items[0].updated
35 else:
36 template_data[u'updated'] = time.time()