diff libervia/pages/blog/view/page_meta.py @ 1483:595e7fef41f3

merge bookmark @
author Goffi <goffi@goffi.org>
date Fri, 12 Nov 2021 17:48:30 +0100
parents 907f519faaf0 10ccad665d57
children 3002ea1d6ae9
line wrap: on
line diff
--- a/libervia/pages/blog/view/page_meta.py	Tue Sep 28 18:18:37 2021 +0200
+++ b/libervia/pages/blog/view/page_meta.py	Fri Nov 12 17:48:30 2021 +0100
@@ -3,6 +3,7 @@
 import html
 from libervia.server.constants import Const as C
 from twisted.words.protocols.jabber import jid
+from twisted.web import server
 from sat.core.i18n import _, D_
 from sat.tools.common.template import safe
 from sat.tools.common import uri
@@ -144,7 +145,15 @@
             comment_data['items'] = comments['items']
             await appendComments(self, request, comments, profile)
 
-async def getBlogItems(self, request, service, node, item_id, extra, profile):
+async def getBlogItems(
+    self,
+    request: server.Request,
+    service: jid.JID,
+    node: str,
+    item_id,
+    extra: dict,
+    profile: str
+) -> dict:
     try:
         if item_id:
             items_id = [item_id]
@@ -211,7 +220,25 @@
     target_profile = template_data.get('target_profile')
 
     if blog_items:
-        if not item_id:
+        if item_id:
+            template_data["previous_page_url"] = self.getURL(
+                service.full(),
+                node,
+                before=item_id,
+                page_max=1
+            )
+            template_data["next_page_url"] = self.getURL(
+                service.full(),
+                node,
+                after=item_id,
+                page_max=1
+            )
+            blog_items["rsm"] = {
+                "last": item_id,
+                "first": item_id,
+            }
+            blog_items["complete"] = False
+        else:
             self.setPagination(request, blog_items)
     else:
         if item_id:
@@ -287,7 +314,9 @@
         uri_args['node'] = node
     if item_id:
         uri_args['item'] = item_id
-    template_data['xmpp_uri'] = uri.buildXMPPUri('pubsub', subtype='microblog', **uri_args)
+    template_data['xmpp_uri'] = uri.buildXMPPUri(
+        'pubsub', subtype='microblog', **uri_args
+    )
 
 
 async def on_data_post(self, request):
@@ -300,7 +329,7 @@
 
         if not body:
             self.pageError(request, C.HTTP_BAD_REQUEST)
-        comment_data = {"content": body}
+        comment_data = {"content_rich": body}
         try:
             await self.host.bridgeCall('mbSend',
                                        service,