Mercurial > libervia-web
comparison src/pages/blog/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 | 3af28f84ce91 |
comparison
equal
deleted
inserted
replaced
1076:5bf288f84862 | 1077:880ea673aaff |
---|---|
1 #!/usr/bin/env python2.7 | |
2 # -*- coding: utf-8 -*- | |
3 from libervia.server.constants import Const as C | |
4 from twisted.words.protocols.jabber import jid | |
5 from twisted.internet import defer | |
6 from libervia.server import session_iface | |
7 from sat.core.log import getLogger | |
8 log = getLogger('pages/common/blog') | |
9 | |
10 name = u'blog' | |
11 access = C.PAGES_ACCESS_PROFILE | |
12 template = u"blog/discover.html" | |
13 | |
14 | |
15 @defer.inlineCallbacks | |
16 def prepare_render(self, request): | |
17 profile = self.getProfile(request) | |
18 template_data = request.template_data | |
19 __, entities_own, entities_roster = yield self.host.bridgeCall('discoFindByFeatures', [], [(u'pubsub', u'pep')], True, False, True, True, profile) | |
20 entities = template_data[u'disco_entities'] = entities_own.keys() + entities_roster.keys() | |
21 entities_url = template_data[u'entities_url'] = {} | |
22 identities = template_data[u'identities'] = self.host.getSessionData(request, session_iface.ISATSession).identities | |
23 for entity_jid_s in entities: | |
24 entities_url[entity_jid_s] = self.getPageByName('blog_view').getURL(entity_jid_s) | |
25 if entity_jid_s not in identities: | |
26 identities[entity_jid_s] = yield self.host.bridgeCall(u'identityGet', entity_jid_s, profile) | |
27 | |
28 def on_data_post(self, request): | |
29 jid_str = self.getPostedData(request, u'jid') | |
30 try: | |
31 jid_ = jid.JID(jid_str) | |
32 except RuntimeError: | |
33 self.pageError(request, C.HTTP_BAD_REQUEST) | |
34 url = self.getPageByName(u'blog_view').getURL(jid_.full()) | |
35 self.HTTPRedirect(request, url) |