diff browser_side/panels.py @ 260:533d68585866

browser side: if 'xhtml' key is present in microblog data, rich content is displayed
author Goffi <goffi@goffi.org>
date Fri, 15 Nov 2013 15:34:55 +0100
parents da0487f0a2e7
children 3df0c3634c29
line wrap: on
line diff
--- a/browser_side/panels.py	Fri Nov 15 15:06:47 2013 +0100
+++ b/browser_side/panels.py	Fri Nov 15 15:34:55 2013 +0100
@@ -234,9 +234,9 @@
                 if target_hook:
                     parsed_txt, data = target_hook
                     if _type == "PUBLIC":
-                        self.host.bridge.call("sendMblog", None, "PUBLIC", None, parsed_txt)
+                        self.host.bridge.call("sendMblog", None, "PUBLIC", None, parsed_txt, {})
                     elif _type == "GROUP":
-                        self.host.bridge.call("sendMblog", None, "GROUP", data, parsed_txt)
+                        self.host.bridge.call("sendMblog", None, "GROUP", data, parsed_txt, {})
                     elif _type == "STATUS":
                         self.host.bridge.call('setStatus', None, parsed_txt)
                     else:
@@ -305,6 +305,7 @@
         self.id = data['id']
         self.type = data.get('type', 'main_item')
         self.content = data['content']
+        self.xhtml = data.get('xhtml')
         self.author = data['author']
         self.timestamp = float(data.get('timestamp', 0))  # XXX: int doesn't work here
         self.comments = data.get('comments', False)
@@ -337,11 +338,11 @@
             <div class='mb_entry_header'><span class='mb_entry_author'>%(author)s</span> on <span class='mb_entry_timestamp'>%(timestamp)s</span></div>
             <div class="mb_entry_avatar" id='id_avatar'></div>
             <div class="mb_entry_dialog">
-                <p class="bubble">%(body)s</p>
+                <div class="bubble">%(body)s</div>
             </div>
             """ % {"author": html_sanitize(self.author),
                    "timestamp": _datetime,
-                   "body": addURLToText(html_sanitize(mblog_entry.content))
+                   "body": addURLToText(html_sanitize(mblog_entry.content)) if not mblog_entry.xhtml else mblog_entry.xhtml
                     })
         self.avatar = Image(blog_panel.host.getAvatar(self.author))
         self.panel.add(self.avatar, "id_avatar")
@@ -442,11 +443,11 @@
             self.host.bridge.call("sendMblogComment", None, comments_node, text)
         elif not self._accepted_groups:
             # we are entering a public microblog
-            self.host.bridge.call("sendMblog", None, "PUBLIC", None, text)
+            self.host.bridge.call("sendMblog", None, "PUBLIC", None, text, {})
         else:
             # we are entering a microblog restricted to a group
             # FIXME: manage several groups
-            self.host.bridge.call("sendMblog", None, "GROUP", self._accepted_groups[0], text)
+            self.host.bridge.call("sendMblog", None, "GROUP", self._accepted_groups[0], text, {})
 
     def accept_all(self):
         return not self._accepted_groups  # we accept every microblog only if we are not filtering by groups
@@ -748,7 +749,7 @@
 
     def onTextEntered(self, text):
         mess_type = "groupchat" if self.type == 'group' else "chat"
-        self.host.bridge.call('sendMessage', None, str(self.target), text, '', mess_type)
+        self.host.bridge.call('sendMessage', None, str(self.target), text, '', mess_type, {})
         self.state_machine._onEvent("active")
 
     def onQuit(self):