Mercurial > libervia-web
comparison src/pages/blog_new/page_meta.py @ 918:96a56856d357
pages (blog_new/articles): first concert Libervia page, blog articles:
This page is for now called blog_new to avoid conflict with former blog static page, but it will replace the older one when ready.
The page get target profile from URL, the request 10 last blog from it, and display it using blog/articles template.
Errors are not correctly handled for now (specially blog retrieval errors).
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 06 Mar 2017 00:05:31 +0100 |
parents | |
children | d042f194624a |
comparison
equal
deleted
inserted
replaced
917:86563d6c83b0 | 918:96a56856d357 |
---|---|
1 #!/usr/bin/env python2.7 | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 from libervia.server.constants import Const as C | |
5 from twisted.internet import defer | |
6 from twisted.words.protocols.jabber import jid | |
7 from sat.tools.common import data_objects | |
8 | |
9 access = C.PAGES_ACCESS_PUBLIC # can be a callable | |
10 template = u"blog/articles.html" | |
11 | |
12 @defer.inlineCallbacks | |
13 def parse_url(self, request): | |
14 try: | |
15 prof_requested = self.nextPath(request) | |
16 except IndexError: | |
17 self.pageError(request) | |
18 | |
19 template_data = request.template_data | |
20 | |
21 target_profile = yield self.host.bridge.profileNameGet(prof_requested) | |
22 template_data[u'target_profile'] = target_profile | |
23 target_jid = yield self.host.bridge.asyncGetParamA('JabberID', 'Connection', 'value', profile_key=target_profile) | |
24 target_jid = jid.JID(target_jid).userhost() | |
25 template_data[u'target_jid'] = target_jid | |
26 | |
27 | |
28 @defer.inlineCallbacks | |
29 def prepare_render(self, request): | |
30 target_jid = request.template_data[u'target_jid'] | |
31 blog_data = yield self.host.bridge.mbGet( | |
32 target_jid, | |
33 "", | |
34 10, | |
35 [], | |
36 {}, | |
37 C.SERVICE_PROFILE) | |
38 request.template_data[u'items'] = data_objects.BlogItems(blog_data) |