changeset 788:7ebde6d1a4bd

browser side: fixed public blog menu (moved temporarily to frontend side)
author Goffi <goffi@goffi.org>
date Wed, 02 Dec 2015 11:15:58 +0100
parents b2a75a103aac
children 1028a9c366d3
files src/browser/libervia_main.py src/browser/sat_browser/menu.py
diffstat 2 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/browser/libervia_main.py	Wed Dec 02 11:15:55 2015 +0100
+++ b/src/browser/libervia_main.py	Wed Dec 02 11:15:58 2015 +0100
@@ -317,6 +317,9 @@
         # we can now display all the menus
         main_menu.update(C.MENU_GLOBAL)
 
+        # XXX: temp, will be reworked in the backed static blog plugin
+        self.menus.addMenu(C.MENU_JID_CONTEXT, (D_(u"User"), D_("Public blog")), callback=main_menu.onPublicBlog)
+
     def _isRegisteredCB(self, result):
         registered, warning = result
         if not registered:
--- a/src/browser/sat_browser/menu.py	Wed Dec 02 11:15:55 2015 +0100
+++ b/src/browser/sat_browser/menu.py	Wed Dec 02 11:15:58 2015 +0100
@@ -32,6 +32,7 @@
 import contact_group
 import base_menu
 from sat_browser import html_tools
+from sat_browser import web_widget
 
 
 unicode = str  # FIXME: pyjamas workaround
@@ -163,3 +164,13 @@
         body.setCloseCb(_dialog.close)
         _dialog.setWidth('40%')
         _dialog.show()
+
+    def onPublicBlog(self, contact_box, data,  profile):
+        # FIXME: Q&D way to check domain, need to be done in a cleaner way
+        if contact_box.jid.domain != self.host._defaultDomain:
+            self.host.showDialog(u"Public blogs from other domains are not managed yet", "Can't show public blog", "error")
+            return
+
+        url = '{}/blog/{}'.format(self.host.base_location, contact_box.jid.node)
+        widget = self.host.displayWidget(web_widget.WebWidget, url, show_url=False)
+        self.host.setSelected(widget)