Mercurial > libervia-website
comparison pages/news/page_meta.py @ 0:09d66acc7c73
initial commit, website first draft:
- presentation page
- documentation (generated from backend and Libervia)
- social contract (HTML generated from sat repository)
- press/conferences (adapted from former website)
- association page (adpated from former website)
- news (a selected blog is displayed)
- fr i18n
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 26 May 2019 22:26:30 +0200 |
parents | |
children | 9ce41ef66dfa |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:09d66acc7c73 |
---|---|
1 #!/usr/bin/env python2.7 | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 from libervia.server.constants import Const as C | |
5 from twisted.words.protocols.jabber import jid | |
6 from twisted.internet import defer | |
7 from sat.core.i18n import _ | |
8 from sat.core.log import getLogger | |
9 | |
10 log = getLogger(__name__) | |
11 | |
12 name = u"news" | |
13 template = u"news/news.html" | |
14 service = None | |
15 node = None | |
16 | |
17 | |
18 @defer.inlineCallbacks | |
19 def prepare_render(self, request): | |
20 global service, node | |
21 if service is None: | |
22 blog_dict = self.getConfig(u'news_blog_dict', {}) | |
23 try: | |
24 service = jid.JID(blog_dict['service']) | |
25 except RuntimeError as e: | |
26 log.warning(_(u"Can't parse service in news_blog_dict: {e}").format(e=e)) | |
27 service = None | |
28 except KeyError: | |
29 log.warnning(_(u"Missing service in news_blog_dict")) | |
30 service = None | |
31 node = blog_dict.get('node', u'') | |
32 if not blog_dict or service is None: | |
33 log.warning(_(u'No value set for news_blog_dict, "news" page can\'t be used')) | |
34 self.pageError(request, C.HTTP_SERVICE_UNAVAILABLE) | |
35 | |
36 data = self.getRData(request) | |
37 data[u'service'] = service | |
38 data[u'node'] = node | |
39 | |
40 # self.checkCache( | |
41 # request, C.CACHE_PUBSUB, service=service, node=node, short="microblog") | |
42 | |
43 # we now need blog items, using blog common page | |
44 # this will fill the "items" template data | |
45 blog_page = self.getPageByName(u"blog_view") | |
46 yield blog_page.prepare_render(self, request) |