annotate src/pages/blog/page_meta.py @ 1119:5a73525f75a3 0.7.0a2

0.7.0a2 release
author Goffi <goffi@goffi.org>
date Sun, 15 Jul 2018 09:03:36 +0200
parents cdd389ef97bc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2.7
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 from libervia.server.constants import Const as C
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 from twisted.words.protocols.jabber import jid
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 from twisted.internet import defer
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 from libervia.server import session_iface
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 from sat.core.log import getLogger
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
8
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
9 log = getLogger("pages/blog")
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
10
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
11 name = u"blog"
1079
3af28f84ce91 pages (blog): blog page is now public (only free jid is available when not connected)
Goffi <goffi@goffi.org>
parents: 1077
diff changeset
12 access = C.PAGES_ACCESS_PUBLIC
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 template = u"blog/discover.html"
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
14
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 @defer.inlineCallbacks
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 def prepare_render(self, request):
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 profile = self.getProfile(request)
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 template_data = request.template_data
1079
3af28f84ce91 pages (blog): blog page is now public (only free jid is available when not connected)
Goffi <goffi@goffi.org>
parents: 1077
diff changeset
20 if profile is not None:
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
21 __, entities_own, entities_roster = yield self.host.bridgeCall(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
22 "discoFindByFeatures",
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
23 [],
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
24 [(u"pubsub", u"pep")],
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
25 True,
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
26 False,
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
27 True,
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
28 True,
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
29 True,
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
30 profile,
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
31 )
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
32 entities = template_data[u"disco_entities"] = (
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
33 entities_own.keys() + entities_roster.keys()
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
34 )
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
35 entities_url = template_data[u"entities_url"] = {}
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
36 identities = template_data[u"identities"] = self.host.getSessionData(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
37 request, session_iface.ISATSession
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
38 ).identities
1079
3af28f84ce91 pages (blog): blog page is now public (only free jid is available when not connected)
Goffi <goffi@goffi.org>
parents: 1077
diff changeset
39 for entity_jid_s in entities:
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
40 entities_url[entity_jid_s] = self.getPageByName("blog_view").getURL(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
41 entity_jid_s
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
42 )
1079
3af28f84ce91 pages (blog): blog page is now public (only free jid is available when not connected)
Goffi <goffi@goffi.org>
parents: 1077
diff changeset
43 if entity_jid_s not in identities:
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
44 identities[entity_jid_s] = yield self.host.bridgeCall(
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
45 u"identityGet", entity_jid_s, profile
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
46 )
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
47
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
48
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 def on_data_post(self, request):
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
50 jid_str = self.getPostedData(request, u"jid")
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 try:
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
52 jid_ = jid.JID(jid_str)
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 except RuntimeError:
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 self.pageError(request, C.HTTP_BAD_REQUEST)
1113
cdd389ef97bc server: code style reformatting using black
Goffi <goffi@goffi.org>
parents: 1087
diff changeset
55 url = self.getPageByName(u"blog_view").getURL(jid_.full())
1077
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 self.HTTPRedirect(request, url)