comparison libervia/web/pages/u/page_meta.py @ 1518:eb00d593801d

refactoring: rename `libervia` to `libervia.web` + update imports following backend changes
author Goffi <goffi@goffi.org>
date Fri, 02 Jun 2023 16:49:28 +0200
parents libervia/pages/u/page_meta.py@106bae41f5c8
children
comparison
equal deleted inserted replaced
1517:b8ed9726525b 1518:eb00d593801d
1 #!/usr/bin/env python3
2
3
4 from libervia.web.server.constants import Const as C
5 from twisted.internet import defer
6 from twisted.words.protocols.jabber import jid
7
8 """page used to target a user profile, e.g. for public blog"""
9
10 name = "user"
11 access = C.PAGES_ACCESS_PUBLIC # can be a callable
12 template = "blog/articles.html"
13 url_cache = True
14
15
16 @defer.inlineCallbacks
17 def parse_url(self, request):
18 try:
19 prof_requested = self.next_path(request)
20 except IndexError:
21 self.page_error(request)
22
23 data = self.get_r_data(request)
24
25 target_profile = yield self.host.bridge_call("profile_name_get", prof_requested)
26 request.template_data["target_profile"] = target_profile
27 target_jid = yield self.host.bridge_call(
28 "param_get_a_async", "JabberID", "Connection", "value", profile_key=target_profile
29 )
30 target_jid = jid.JID(target_jid)
31 data["service"] = target_jid
32
33 # if URL is parsed here, we'll have atom.xml available and we need to
34 # add the link to the page
35 atom_url = self.get_sub_page_url(request, 'user_blog_feed_atom')
36 request.template_data['atom_url'] = atom_url
37 request.template_data.setdefault('links', []).append({
38 "href": atom_url,
39 "type": "application/atom+xml",
40 "rel": "alternate",
41 "title": "{target_profile}'s blog".format(target_profile=target_profile)})
42
43 def add_breadcrumb(self, request, breadcrumbs):
44 # we don't want a breadcrumb here
45 pass
46
47
48 @defer.inlineCallbacks
49 def prepare_render(self, request):
50 data = self.get_r_data(request)
51 self.check_cache(
52 request, C.CACHE_PUBSUB, service=data["service"], node=None, short="microblog"
53 )
54 self.page_redirect("blog_view", request)
55
56 def on_data_post(self, request):
57 return self.get_page_by_name("blog_view").on_data_post(self, request)