annotate 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
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 log = getLogger('pages/common/blog')
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
9
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 name = u'blog'
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 access = C.PAGES_ACCESS_PROFILE
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 template = u"blog/discover.html"
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
13
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 @defer.inlineCallbacks
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 def prepare_render(self, request):
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 profile = self.getProfile(request)
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 template_data = request.template_data
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 __, entities_own, entities_roster = yield self.host.bridgeCall('discoFindByFeatures', [], [(u'pubsub', u'pep')], True, False, True, True, profile)
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
20 entities = template_data[u'disco_entities'] = entities_own.keys() + entities_roster.keys()
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 entities_url = template_data[u'entities_url'] = {}
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 identities = template_data[u'identities'] = self.host.getSessionData(request, session_iface.ISATSession).identities
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 for entity_jid_s in entities:
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 entities_url[entity_jid_s] = self.getPageByName('blog_view').getURL(entity_jid_s)
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 if entity_jid_s not in identities:
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 identities[entity_jid_s] = yield self.host.bridgeCall(u'identityGet', entity_jid_s, profile)
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
27
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 def on_data_post(self, request):
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 jid_str = self.getPostedData(request, u'jid')
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 try:
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 jid_ = jid.JID(jid_str)
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 except RuntimeError:
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
33 self.pageError(request, C.HTTP_BAD_REQUEST)
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 url = self.getPageByName(u'blog_view').getURL(jid_.full())
880ea673aaff blog: moved blog page from /common to /blog:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 self.HTTPRedirect(request, url)