comparison libervia/pages/blog/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/page_meta.py@cdd389ef97bc
children e45480b6ba24
comparison
equal deleted inserted replaced
1123:63a4b8fe9782 1124:28e3eb3bb217
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
9 log = getLogger("pages/blog")
10
11 name = u"blog"
12 access = C.PAGES_ACCESS_PUBLIC
13 template = u"blog/discover.html"
14
15
16 @defer.inlineCallbacks
17 def prepare_render(self, request):
18 profile = self.getProfile(request)
19 template_data = request.template_data
20 if profile is not None:
21 __, entities_own, entities_roster = yield self.host.bridgeCall(
22 "discoFindByFeatures",
23 [],
24 [(u"pubsub", u"pep")],
25 True,
26 False,
27 True,
28 True,
29 True,
30 profile,
31 )
32 entities = template_data[u"disco_entities"] = (
33 entities_own.keys() + entities_roster.keys()
34 )
35 entities_url = template_data[u"entities_url"] = {}
36 identities = template_data[u"identities"] = self.host.getSessionData(
37 request, session_iface.ISATSession
38 ).identities
39 for entity_jid_s in entities:
40 entities_url[entity_jid_s] = self.getPageByName("blog_view").getURL(
41 entity_jid_s
42 )
43 if entity_jid_s not in identities:
44 identities[entity_jid_s] = yield self.host.bridgeCall(
45 u"identityGet", entity_jid_s, profile
46 )
47
48
49 def on_data_post(self, request):
50 jid_str = self.getPostedData(request, u"jid")
51 try:
52 jid_ = jid.JID(jid_str)
53 except RuntimeError:
54 self.pageError(request, C.HTTP_BAD_REQUEST)
55 url = self.getPageByName(u"blog_view").getURL(jid_.full())
56 self.HTTPRedirect(request, url)