view libervia/web/pages/u/page_meta.py @ 1584:eab815e48795

browser (chat): message edition + extra menu: - handle extra menu - implement `quote` action - last message correction - show popup with last editions history when "editer" pencil icon is hovered - up arrow let quickly edit last message - implement input modes, `normal` being the default, `edit` or `quote` are new ones. - [ESC] erase input and returns to `normal` mode - fix size and set focus on message input when page is loaded - fix identity retrieval on new messages
author Goffi <goffi@goffi.org>
date Tue, 28 Nov 2023 17:59:11 +0100
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)