comparison libervia/pages/blog/view/atom.xml/page_meta.py @ 1124:28e3eb3bb217

files reorganisation and installation rework: - files have been reorganised to follow other SàT projects and usual Python organisation (no more "/src" directory) - VERSION file is now used, as for other SàT projects - replace the overcomplicated setup.py be a more sane one. Pyjamas part is not compiled anymore by setup.py, it must be done separatly - removed check for data_dir if it's empty - installation tested working in virtual env - libervia launching script is now in bin/libervia
author Goffi <goffi@goffi.org>
date Sat, 25 Aug 2018 17:59:48 +0200
parents src/pages/blog/view/atom.xml/page_meta.py@cdd389ef97bc
children b2d067339de3
comparison
equal deleted inserted replaced
1123:63a4b8fe9782 1124:28e3eb3bb217
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(
20 request, C.CACHE_PUBSUB, service=service, node=node, short="microblog"
21 )
22 data["show_comments"] = False
23 template_data = request.template_data
24 blog_page = self.getPageByName(u"blog_view")
25 yield blog_page.prepare_render(self, request)
26 items = data[u"items"]
27
28 template_data[u"request_uri"] = self.host.getExtBaseURL(
29 request, request.path.decode("utf-8")
30 )
31 template_data[u"xmpp_uri"] = uri.buildXMPPUri(
32 u"pubsub", subtype=u"microblog", path=service.full(), node=node
33 )
34 blog_view = self.getPageByName(u"blog_view")
35 template_data[u"http_uri"] = self.host.getExtBaseURL(
36 request, blog_view.getURL(service.full(), node)
37 )
38 if items:
39 template_data[u"updated"] = items[0].updated
40 else:
41 template_data[u"updated"] = time.time()