Mercurial > libervia-web
view libervia/web/pages/u/page_meta.py @ 1525:c921e7002bac
build: don't use local dependencies, and remove backend package:
hatch doesn't support yet editable dependencies
(https://github.com/pypa/hatch/issues/588), and to work on dev, backend and templates must
be installed manually in dev mode. To avoid issues during sync when entering a shell,
those dependencies are disabled and must be installed manually.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 08 Jun 2023 21:07:54 +0200 |
parents | eb00d593801d |
children |
line wrap: on
line source
#!/usr/bin/env python3 from libervia.web.server.constants import Const as C from twisted.internet import defer from twisted.words.protocols.jabber import jid """page used to target a user profile, e.g. for public blog""" name = "user" access = C.PAGES_ACCESS_PUBLIC # can be a callable template = "blog/articles.html" url_cache = True @defer.inlineCallbacks def parse_url(self, request): try: prof_requested = self.next_path(request) except IndexError: self.page_error(request) data = self.get_r_data(request) target_profile = yield self.host.bridge_call("profile_name_get", prof_requested) request.template_data["target_profile"] = target_profile target_jid = yield self.host.bridge_call( "param_get_a_async", "JabberID", "Connection", "value", profile_key=target_profile ) target_jid = jid.JID(target_jid) data["service"] = target_jid # if URL is parsed here, we'll have atom.xml available and we need to # add the link to the page atom_url = self.get_sub_page_url(request, 'user_blog_feed_atom') request.template_data['atom_url'] = atom_url request.template_data.setdefault('links', []).append({ "href": atom_url, "type": "application/atom+xml", "rel": "alternate", "title": "{target_profile}'s blog".format(target_profile=target_profile)}) def add_breadcrumb(self, request, breadcrumbs): # we don't want a breadcrumb here pass @defer.inlineCallbacks def prepare_render(self, request): data = self.get_r_data(request) self.check_cache( request, C.CACHE_PUBSUB, service=data["service"], node=None, short="microblog" ) self.page_redirect("blog_view", request) def on_data_post(self, request): return self.get_page_by_name("blog_view").on_data_post(self, request)