Mercurial > libervia-web
diff libervia/web/pages/forums/topics/page_meta.py @ 1642:c03297bb8d19
server, browser (forums): Redesign of the forum feature:
Forum has been fully redesigned, it now uses pubsub relationships and pubsub extended
discovery to handle the hierarchy.
Categories lead to topics (which are the name of the items of a blog-like nodes). Topics
have comment nodes which are used to show the topic messages.
Subscription state is retrieve when a thread is shown, and can be changed easily with as
ingle button click.
Quill editor is used, and is extended with Quill-Mention to easily send a mention to an
XMPP entity.
Attachments and tags are handled with buttons added to Quill editor.
Search in a thread is using Pubsub MAM, is the same way as for blogs.
rel 463
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 06 Sep 2025 16:30:46 +0200 |
parents | eb00d593801d |
children |
line wrap: on
line diff
--- a/libervia/web/pages/forums/topics/page_meta.py Sat Sep 06 12:12:42 2025 +0200 +++ b/libervia/web/pages/forums/topics/page_meta.py Sat Sep 06 16:30:46 2025 +0200 @@ -21,11 +21,7 @@ def add_breadcrumb(self, request, breadcrumbs): - data = self.get_r_data(request) - breadcrumbs.append({ - "label": label, - "url": self.get_url(data["service"].full(), data["node"]) - }) + return None async def prepare_render(self, request): @@ -36,31 +32,35 @@ template_data = request.template_data page_max = data.get("page_max", 20) extra = self.get_pubsub_extra(request, page_max=page_max) - topics, metadata = await self.host.bridge_call( - "forum_topics_get", - service.full(), - node, - extra, - profile + if not self.use_cache(request): + extra[C.KEY_USE_CACHE] = False + blog_data = data_format.deserialise( + await self.host.bridge_call( + 'mb_get', + service.userhost(), + node, + C.NO_LIMIT, + [], + data_format.serialise(extra), + profile + ) ) - metadata = data_format.deserialise(metadata) - self.set_pagination(request, metadata) - identities = self.host.get_session_data( - request, session_iface.IWebSession - ).identities - for topic in topics: - parsed_uri = xmpp_uri.parse_xmpp_uri(topic["uri"]) - author = topic["author"] - topic["http_uri"] = self.get_page_by_name("forum_view").get_url( - parsed_uri["path"], parsed_uri["node"] + for item in blog_data["items"]: + try: + # We check that there is a comment node for this topic. + item["comments"][0]["service"] + item["comments"][0]["node"] + except (KeyError, IndexError): + log.warning(f"Can't get comments node for item: {item}") + continue + else: + item["http_url"] = self.get_page_by_name("forum_view").get_url( + service.full(), node, item["id"] ) - if author not in identities: - id_raw = await self.host.bridge_call( - "identity_get", author, [], True, profile - ) - identities[topic["author"]] = data_format.deserialise(id_raw) + self.set_pagination(request, blog_data) + await self.fill_missing_identities(request, [i['author_jid'] for i in blog_data['items']]) - template_data["topics"] = topics + template_data['blog_items'] = blog_data template_data["url_topic_new"] = self.get_sub_page_url(request, "forum_topic_new")