Mercurial > libervia-web
comparison src/pages/blog_new/page_meta.py @ 1016:fc1c913cc9d1
pages (blog_new, common/blog): various blog improvments:
- item_id can now be specified in URL parsing, and a filter_keyword is used so future variants can be implemented (e.g. tags)
- if item_id is specified, rsm is discarded and only the requested item is retrieved
- new template data "items_http_uri" is filled, with links to HTTP versions of items
- blog_new is now a simple redirection to common/blog as the later should be generic enough to handle all use cases.
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 19 Jan 2018 18:09:39 +0100 |
parents | d042f194624a |
children |
comparison
equal
deleted
inserted
replaced
1015:16d52917666c | 1016:fc1c913cc9d1 |
---|---|
1 #!/usr/bin/env python2.7 | 1 #!/usr/bin/env python2.7 |
2 # -*- coding: utf-8 -*- | 2 # -*- coding: utf-8 -*- |
3 | 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 name = u"blog_view" | 4 name = u"blog_view" |
10 access = C.PAGES_ACCESS_PUBLIC # can be a callable | 5 redirect = u"blog" |
11 template = u"blog/articles.html" | |
12 | |
13 @defer.inlineCallbacks | |
14 def parse_url(self, request): | |
15 try: | |
16 prof_requested = self.nextPath(request) | |
17 except IndexError: | |
18 self.pageError(request) | |
19 | |
20 template_data = request.template_data | |
21 | |
22 target_profile = yield self.host.bridge.profileNameGet(prof_requested) | |
23 template_data[u'target_profile'] = target_profile | |
24 target_jid = yield self.host.bridge.asyncGetParamA('JabberID', 'Connection', 'value', profile_key=target_profile) | |
25 target_jid = jid.JID(target_jid).userhost() | |
26 template_data[u'target_jid'] = target_jid | |
27 | |
28 | |
29 @defer.inlineCallbacks | |
30 def prepare_render(self, request): | |
31 target_jid = request.template_data[u'target_jid'] | |
32 blog_data = yield self.host.bridge.mbGet( | |
33 target_jid, | |
34 "", | |
35 10, | |
36 [], | |
37 {}, | |
38 C.SERVICE_PROFILE) | |
39 request.template_data[u'items'] = data_objects.BlogItems(blog_data) |