diff src/browser/sat_browser/richtext.py @ 742:d123e27fc386

browser_side: use methods defined in quick_frontend to retrieve and set the tags from/to microblog data
author souliane <souliane@mailoo.org>
date Sat, 21 Nov 2015 14:34:36 +0100
parents c3cb68227cca
children 34f066ed3b23
line wrap: on
line diff
--- a/src/browser/sat_browser/richtext.py	Thu Nov 19 17:20:37 2015 +0100
+++ b/src/browser/sat_browser/richtext.py	Sat Nov 21 14:34:36 2015 +0100
@@ -39,7 +39,7 @@
 import html_tools
 import list_manager
 
-from sat_frontends.quick_frontend import quick_list_manager
+from sat_frontends.quick_frontend import quick_blog
 
 
 class RichTextEditor(editor_widget.BaseTextEditor, FlexTable):
@@ -266,10 +266,7 @@
         if hasattr(self, 'title_panel'):
             content.update({'title': self.strproc(self.title_panel.getText())})
         if hasattr(self, 'tags_panel'):
-            count = 0
-            for tag in self.tags_panel.getTags():
-                content['tag#%i' % count if count else 'tag'] = tag
-                count += 1
+            content.update(quick_blog.tags2mbdata(self.tags_panel.getTags()))
         return content
 
     def edit(self, edit=False, abort=False, sync=False):
@@ -305,8 +302,8 @@
                         self.title_panel.setText(content['title'])
                         self.title_panel.setStackVisible(0, content['title'] != '')
 
-                    if hasattr(self, 'tags_panel') and 'tag' in content:
-                        tags = [tag for key, tag in content.iteritems() if (key == "tag" or key.startswith("tag#")) and tag]
+                    if hasattr(self, 'tags_panel'):
+                        tags = quick_blog.mbdata2tags(content)
                         self.tags_panel.setTags(tags)
                         self.tags_panel.setStackVisible(0, len(tags) > 0)
 
@@ -328,8 +325,8 @@
         text = content['text']
         if 'title' in content and content['title']:
             text = '<h1>%s</h1>%s' % (html_tools.html_sanitize(content['title']), text)
-        if 'tag' in content:  # FIXME: display it more beautiful
-            tags = [tag for key, tag in content.iteritems() if (key == "tag" or key.startswith("tag#")) and tag]
+        tags = quick_blog.mbdata2tags(content)
+        if tags: # FIXME: display it more beautiful
             text = '%s<h3>%s %s</h3>' % (text, _("Tags:"), html_tools.html_sanitize(", ".join(tags)))
         self.display.setContent({'text': text})