# HG changeset patch # User souliane # Date 1447950037 -3600 # Node ID c3cb68227cca38622d0396b5a4fdba6c8bc9f03c # Parent b6510fd9ae15522db83571090ef31fef7f970695 browser_side: read and write tags from microblog data: - not tested! - implementation missing in quick_blog.Item and quick_blog.Entry diff -r b6510fd9ae15 -r c3cb68227cca src/browser/sat_browser/list_manager.py --- a/src/browser/sat_browser/list_manager.py Thu Nov 19 16:43:18 2015 +0100 +++ b/src/browser/sat_browser/list_manager.py Thu Nov 19 17:20:37 2015 +0100 @@ -483,7 +483,7 @@ STYLE = {"main": "tagsPanel-main", "tags": "tagsPanel-tags"} - def __init__(self, suggested_tags, tags): + def __init__(self, suggested_tags, tags=None): """ @param suggested_tags (list[unicode]): list of all suggested tags @@ -491,6 +491,10 @@ """ base_panel.ToggleStackPanel.__init__(self, Width="100%") self.addStyleName(self.STYLE["main"]) + + if tags is None: + tags = [] + self.tags = ListPanel(quick_list_manager.QuickTagList(suggested_tags), tags) self.tags.addStyleName(self.STYLE["tags"]) self.tags.ACCEPT_NEW_ENTRY = True diff -r b6510fd9ae15 -r c3cb68227cca src/browser/sat_browser/richtext.py --- a/src/browser/sat_browser/richtext.py Thu Nov 19 16:43:18 2015 +0100 +++ b/src/browser/sat_browser/richtext.py Thu Nov 19 17:20:37 2015 +0100 @@ -89,7 +89,7 @@ if edit is None: edit = hasattr(self, 'textarea') and self.textarea.getVisible() - for widget in ['title_panel', 'command']: + for widget in ['title_panel', 'tags_panel', 'command']: if hasattr(self, widget): getattr(self, widget).setVisible(edit) @@ -120,12 +120,11 @@ self.getFlexCellFormatter().setColSpan(self.title_offset, 0, 2) self.setWidget(self.title_offset, 0, self.title_panel) - if not self.read_only and not hasattr(self, 'tags'): + if not self.read_only and not hasattr(self, 'tags_panel'): suggested_tags = [] # TODO: feed this list with tags suggestion - tags = [] # TODO: feed this list with tags already assigned to this message - self.tags = list_manager.TagsPanel(suggested_tags, tags) + self.tags_panel = list_manager.TagsPanel(suggested_tags) self.getFlexCellFormatter().setColSpan(self.tags_offset, 0, 2) - self.setWidget(self.tags_offset, 0, self.tags) + self.setWidget(self.tags_offset, 0, self.tags_panel) if not self.read_only and not hasattr(self, 'command'): self.command = HorizontalPanel() @@ -266,6 +265,11 @@ content = {'text': self.strproc(self.textarea.getText()), 'syntax': self.toolbar.syntax} 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 return content def edit(self, edit=False, abort=False, sync=False): @@ -296,9 +300,16 @@ content.update({'text': text}) content.update({'syntax': syntax}) self.textarea.setText(content['text']) + if hasattr(self, 'title_panel') and 'title' in content: 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] + self.tags_panel.setTags(tags) + self.tags_panel.setStackVisible(0, len(tags) > 0) + self.setToolBar(syntax) if content['text'] and content['syntax'] != syntax: self.host.bridge.call('syntaxConvert', syntaxConvertCb, content['text'], content['syntax']) @@ -316,7 +327,10 @@ content = self._original_content text = content['text'] if 'title' in content and content['title']: - text = '

%s

%s' % (html_tools.html_sanitize(content['title']), content['text']) + text = '

%s

%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] + text = '%s

%s %s

' % (text, _("Tags:"), html_tools.html_sanitize(", ".join(tags))) self.display.setContent({'text': text}) def setFocus(self, focus):