Mercurial > libervia-web
comparison 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 |
comparison
equal
deleted
inserted
replaced
741:c3cb68227cca | 742:d123e27fc386 |
---|---|
37 import base_panel | 37 import base_panel |
38 import editor_widget | 38 import editor_widget |
39 import html_tools | 39 import html_tools |
40 import list_manager | 40 import list_manager |
41 | 41 |
42 from sat_frontends.quick_frontend import quick_list_manager | 42 from sat_frontends.quick_frontend import quick_blog |
43 | 43 |
44 | 44 |
45 class RichTextEditor(editor_widget.BaseTextEditor, FlexTable): | 45 class RichTextEditor(editor_widget.BaseTextEditor, FlexTable): |
46 """Panel for the rich text editor.""" | 46 """Panel for the rich text editor.""" |
47 | 47 |
264 else: | 264 else: |
265 content = {'text': self.strproc(self.textarea.getText()), 'syntax': self.toolbar.syntax} | 265 content = {'text': self.strproc(self.textarea.getText()), 'syntax': self.toolbar.syntax} |
266 if hasattr(self, 'title_panel'): | 266 if hasattr(self, 'title_panel'): |
267 content.update({'title': self.strproc(self.title_panel.getText())}) | 267 content.update({'title': self.strproc(self.title_panel.getText())}) |
268 if hasattr(self, 'tags_panel'): | 268 if hasattr(self, 'tags_panel'): |
269 count = 0 | 269 content.update(quick_blog.tags2mbdata(self.tags_panel.getTags())) |
270 for tag in self.tags_panel.getTags(): | |
271 content['tag#%i' % count if count else 'tag'] = tag | |
272 count += 1 | |
273 return content | 270 return content |
274 | 271 |
275 def edit(self, edit=False, abort=False, sync=False): | 272 def edit(self, edit=False, abort=False, sync=False): |
276 """ | 273 """ |
277 Remark: the editor must be visible before you call this method. | 274 Remark: the editor must be visible before you call this method. |
303 | 300 |
304 if hasattr(self, 'title_panel') and 'title' in content: | 301 if hasattr(self, 'title_panel') and 'title' in content: |
305 self.title_panel.setText(content['title']) | 302 self.title_panel.setText(content['title']) |
306 self.title_panel.setStackVisible(0, content['title'] != '') | 303 self.title_panel.setStackVisible(0, content['title'] != '') |
307 | 304 |
308 if hasattr(self, 'tags_panel') and 'tag' in content: | 305 if hasattr(self, 'tags_panel'): |
309 tags = [tag for key, tag in content.iteritems() if (key == "tag" or key.startswith("tag#")) and tag] | 306 tags = quick_blog.mbdata2tags(content) |
310 self.tags_panel.setTags(tags) | 307 self.tags_panel.setTags(tags) |
311 self.tags_panel.setStackVisible(0, len(tags) > 0) | 308 self.tags_panel.setStackVisible(0, len(tags) > 0) |
312 | 309 |
313 self.setToolBar(syntax) | 310 self.setToolBar(syntax) |
314 if content['text'] and content['syntax'] != syntax: | 311 if content['text'] and content['syntax'] != syntax: |
326 """Set the content of the editor_widget.HTMLTextEditor which is used for display/wysiwyg""" | 323 """Set the content of the editor_widget.HTMLTextEditor which is used for display/wysiwyg""" |
327 content = self._original_content | 324 content = self._original_content |
328 text = content['text'] | 325 text = content['text'] |
329 if 'title' in content and content['title']: | 326 if 'title' in content and content['title']: |
330 text = '<h1>%s</h1>%s' % (html_tools.html_sanitize(content['title']), text) | 327 text = '<h1>%s</h1>%s' % (html_tools.html_sanitize(content['title']), text) |
331 if 'tag' in content: # FIXME: display it more beautiful | 328 tags = quick_blog.mbdata2tags(content) |
332 tags = [tag for key, tag in content.iteritems() if (key == "tag" or key.startswith("tag#")) and tag] | 329 if tags: # FIXME: display it more beautiful |
333 text = '%s<h3>%s %s</h3>' % (text, _("Tags:"), html_tools.html_sanitize(", ".join(tags))) | 330 text = '%s<h3>%s %s</h3>' % (text, _("Tags:"), html_tools.html_sanitize(", ".join(tags))) |
334 self.display.setContent({'text': text}) | 331 self.display.setContent({'text': text}) |
335 | 332 |
336 def setFocus(self, focus): | 333 def setFocus(self, focus): |
337 self.textarea.setFocus(focus) | 334 self.textarea.setFocus(focus) |