Mercurial > libervia-web
annotate src/browser/sat_browser/blog.py @ 768:6c89dfdba563
browser_side (blog): typo in the CSS
author | souliane <souliane@mailoo.org> |
---|---|
date | Wed, 25 Nov 2015 17:03:36 +0100 |
parents | 063385cbbfc2 |
children | 5b28bca05d23 |
rev | line source |
---|---|
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/usr/bin/python |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 # -*- coding: utf-8 -*- |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
4 # Libervia: a Salut à Toi frontend |
685 | 5 # Copyright (C) 2011, 2012, 2013, 2014, 2015 Jérôme Poisson <goffi@goffi.org> |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
7 # This program is free software: you can redistribute it and/or modify |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
8 # it under the terms of the GNU Affero General Public License as published by |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
9 # the Free Software Foundation, either version 3 of the License, or |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
10 # (at your option) any later version. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
12 # This program is distributed in the hope that it will be useful, |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
15 # GNU Affero General Public License for more details. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 |
339
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
17 # You should have received a copy of the GNU Affero General Public License |
2067d6241927
fixed docstrings wrong usage for licence informations
Goffi <goffi@goffi.org>
parents:
334
diff
changeset
|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
19 |
226
744426c2b699
browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents:
223
diff
changeset
|
20 import pyjd # this is dummy in pyjs |
439
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
21 from sat.core.log import getLogger |
d52f529a6d42
browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents:
433
diff
changeset
|
22 log = getLogger(__name__) |
762
8eeb98659de2
browser_side (blog): tags were not read when receiving a message
souliane <souliane@mailoo.org>
parents:
761
diff
changeset
|
23 from sat.tools import common |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
24 from sat.core.i18n import _ #, D_ |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
25 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 from pyjamas.ui.SimplePanel import SimplePanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
27 from pyjamas.ui.VerticalPanel import VerticalPanel |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
28 from pyjamas.ui.ScrollPanel import ScrollPanel |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 from pyjamas.ui.HorizontalPanel import HorizontalPanel |
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 from pyjamas.ui.Label import Label |
33 | 31 from pyjamas.ui.HTML import HTML |
83 | 32 from pyjamas.ui.Image import Image |
19 | 33 from pyjamas.ui.ClickListener import ClickHandler |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
34 from pyjamas.ui.FlowPanel import FlowPanel |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
35 from pyjamas.ui import KeyboardListener as keyb |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
36 from pyjamas.ui.KeyboardListener import KeyboardHandler |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
37 from pyjamas.ui.FocusListener import FocusHandler |
186
72bb1d845b6a
browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents:
185
diff
changeset
|
38 from pyjamas.ui.MouseListener import MouseHandler |
33 | 39 from pyjamas.Timer import Timer |
323
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
40 |
0b7934e75e76
misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents:
322
diff
changeset
|
41 from datetime import datetime |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
42 |
467 | 43 import html_tools |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
44 import dialog |
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
442
diff
changeset
|
45 import richtext |
648
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
638
diff
changeset
|
46 import editor_widget |
6d3142b782c3
browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents:
638
diff
changeset
|
47 import libervia_widget |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
48 from constants import Const as C |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
49 from sat_frontends.quick_frontend import quick_widgets |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
50 from sat_frontends.quick_frontend import quick_blog |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
51 |
606
7af8f4ab3675
browser side: fixed avatar getting + better DEFAULT/EMPTY avatars constants + use of jid.JID for microblog's author
Goffi <goffi@goffi.org>
parents:
598
diff
changeset
|
52 unicode = str # XXX: pyjamas doesn't manage unicode |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
53 ENTRY_RICH = (C.ENTRY_MODE_RICH, C.ENTRY_MODE_XHTML) |
606
7af8f4ab3675
browser side: fixed avatar getting + better DEFAULT/EMPTY avatars constants + use of jid.JID for microblog's author
Goffi <goffi@goffi.org>
parents:
598
diff
changeset
|
54 |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
55 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
56 class Entry(quick_blog.Entry, VerticalPanel, ClickHandler, FocusHandler, KeyboardHandler): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
57 """Graphical representation of a quick_blog.Item""" |
132
30d8e328559b
server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents:
131
diff
changeset
|
58 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
59 def __init__(self, manager, item_data=None, comments_data=None, service=None, node=None): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
60 quick_blog.Entry.__init__(self, manager, item_data, comments_data, service, node) |
210
3092f6b1710c
browser side: make the OK button title for group selector configureable + few "cosmetic" changes (PEP 8...)
souliane <souliane@mailoo.org>
parents:
206
diff
changeset
|
61 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
62 VerticalPanel.__init__(self) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
64 self.panel = FlowPanel() |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
65 self.panel.setStyleName('mb_entry') |
307
44b46db7dfef
browser_side (groupblog): order items using "published" instead of "updated"
souliane <souliane@mailoo.org>
parents:
306
diff
changeset
|
66 |
586
3eb3a2c0c011
browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
585
diff
changeset
|
67 self.header = HorizontalPanel(StyleName='mb_entry_header') |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
68 self.panel.add(self.header) |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
69 |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
70 self.entry_actions = VerticalPanel() |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
71 self.entry_actions.setStyleName('mb_entry_actions') |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
72 self.panel.add(self.entry_actions) |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
73 |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
74 entry_avatar = SimplePanel() |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
75 entry_avatar.setStyleName('mb_entry_avatar') |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
76 author_jid = self.author_jid |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
77 self.avatar = Image(self.blog.host.getAvatarURL(author_jid) if author_jid is not None else C.DEFAULT_AVATAR_URL) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
78 # TODO: show a warning icon if author is not validated |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
79 entry_avatar.add(self.avatar) |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
80 self.panel.add(entry_avatar) |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
81 |
667
166f3b624816
browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
82 self.entry_dialog = VerticalPanel() |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
83 self.entry_dialog.setStyleName('mb_entry_dialog') |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
84 self.panel.add(self.entry_dialog) |
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
85 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
86 self.comments_panel = None |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
87 self._current_comment = None |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
88 |
119 | 89 self.add(self.panel) |
199
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
90 ClickHandler.__init__(self) |
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
91 self.addClickListener(self) |
119 | 92 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
93 self.refresh() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
94 self.displayed = False # True when entry is added to parent |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
95 if comments_data: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
96 self.addComments(comments_data) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
97 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
98 def refresh(self): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
99 self.header.clear() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
100 self.entry_dialog.clear() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
101 self.entry_actions.clear() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
102 self._setHeader() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
103 self._setBubble() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
104 self._setIcons() |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
105 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
106 def _setHeader(self): |
586
3eb3a2c0c011
browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
585
diff
changeset
|
107 """Set the entry header.""" |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
108 if not self.new: |
767
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
109 author = html_tools.html_sanitize(unicode(self.item.author)) |
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
110 author_jid = html_tools.html_sanitize(unicode(self.item.author_jid)) |
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
111 if author_jid and not self.item.author_verified: |
768
6c89dfdba563
browser_side (blog): typo in the CSS
souliane <souliane@mailoo.org>
parents:
767
diff
changeset
|
112 author_jid += u' <span style="color:red; font-weight: bold;">⚠</span>' |
767
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
113 if author: |
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
114 author += " <%s>" % author_jid |
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
115 elif author_jid: |
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
116 author = author_jid |
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
117 else: |
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
118 author = _("<unknown author>") |
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
119 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
120 update_text = u" — ✍ " + "<span class='mb_entry_timestamp'>%s</span>" % datetime.fromtimestamp(self.item.updated) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
121 self.header.add(HTML("""<span class='mb_entry_header_info'> |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
122 <span class='mb_entry_author'>%(author)s</span> on |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
123 <span class='mb_entry_timestamp'>%(published)s</span>%(updated)s |
767
063385cbbfc2
browser_side (blog): display author_jid in addition to author
souliane <souliane@mailoo.org>
parents:
762
diff
changeset
|
124 </span>""" % {'author': author, |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
125 'published': datetime.fromtimestamp(self.item.published) if self.item.published is not None else '', |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
126 'updated': update_text if self.item.published != self.item.updated else '' |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
127 })) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
128 if self.item.comments: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
129 self.show_comments_link = HTML('') |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
130 self.header.add(self.show_comments_link) |
586
3eb3a2c0c011
browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
585
diff
changeset
|
131 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
132 def _setBubble(self): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
133 """Set the bubble displaying the initial content.""" |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
134 content = {'text': self.item.content_xhtml if self.item.content_xhtml else self.item.content or '', |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
135 'title': self.item.title_xhtml if self.item.title_xhtml else self.item.title or ''} |
762
8eeb98659de2
browser_side (blog): tags were not read when receiving a message
souliane <souliane@mailoo.org>
parents:
761
diff
changeset
|
136 common.iter2dict('tag', self.item.tags, content) |
586
3eb3a2c0c011
browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
585
diff
changeset
|
137 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
138 if self.mode == C.ENTRY_MODE_TEXT: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
139 # assume raw text message have no title |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
140 self.bubble = editor_widget.LightTextEditor(content, modifiedCb=self._modifiedCb, afterEditCb=self._afterEditCb, options={'no_xhtml': True}) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
141 elif self.mode in ENTRY_RICH: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
142 content['syntax'] = C.SYNTAX_XHTML |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
143 if self.new: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
144 options = [] |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
145 elif self.item.author_jid == self.blog.host.whoami.bare: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
146 options = ['update_msg'] |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
147 else: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
148 options = ['read_only'] |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
149 self.bubble = richtext.RichTextEditor(self.blog.host, content, modifiedCb=self._modifiedCb, afterEditCb=self._afterEditCb, options=options) |
586
3eb3a2c0c011
browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
585
diff
changeset
|
150 else: |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
151 log.error("Bad entry mode: %s" % self.mode) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
152 self.bubble.addStyleName("bubble") |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
153 self._showSyntaxSwitchButton(False) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
154 self.entry_dialog.add(self.bubble) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
155 self.bubble.addEditListener(self._showWarning) # FIXME: remove edit listeners |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
156 self._setEditable() |
586
3eb3a2c0c011
browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
585
diff
changeset
|
157 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
158 def _setIcons(self): |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
159 """Set the entry icons (delete, update, comment)""" |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
160 if self.new: |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
161 return |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
162 |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
163 def addIcon(label, title): |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
164 label = Label(label) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
165 label.setTitle(title) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
166 label.addClickListener(self) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
167 self.entry_actions.add(label) |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
168 return label |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
169 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
170 if self.item.comments: |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
171 self.comment_label = addIcon(u"↶", "Comment this message") |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
172 self.comment_label.setStyleName('mb_entry_action_larger') |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
173 is_publisher = self.item.author_jid == self.blog.host.whoami.bare |
442
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
174 if is_publisher: |
17259c2ff96f
browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents:
439
diff
changeset
|
175 self.update_label = addIcon(u"✍", "Edit this message") |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
176 # TODO: add delete button if we are the owner of the node |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
177 self.delete_label = addIcon(u"✗", "Delete this message") |
291
89818bca1a33
browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents:
289
diff
changeset
|
178 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
179 def _createCommentsPanel(self): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
180 """Create the panel if it doesn't exists""" |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
181 if self.comments_panel is None: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
182 self.comments_panel = VerticalPanel() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
183 self.comments_panel.setStyleName('microblogPanel') |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
184 self.comments_panel.addStyleName('subPanel') |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
185 self.add(self.comments_panel) |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
186 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
187 def _setEditable(self): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
188 self.bubble.edit(self.editable) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
189 if self.editable: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
190 self._showSyntaxSwitchButton() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
191 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
192 def setEditable(self, editable=True): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
193 self.editable = editable |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
194 self._setEditable() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
195 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
196 def _showSyntaxSwitchButton(self, show=True): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
197 if show: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
198 if self.mode == C.ENTRY_MODE_TEXT: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
199 html = '<a style="color: blue;">rich text</a>' |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
200 else: |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
201 html = '<a style="color: blue;">raw text</a>' |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
202 self.toggle_syntax_button = HTML(html) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
203 self.toggle_syntax_button.addClickListener(self.toggleContentSyntax) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
204 self.toggle_syntax_button.addStyleName('mb_entry_toggle_syntax') |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
205 self.entry_dialog.add(self.toggle_syntax_button) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
206 self.toggle_syntax_button.setStyleAttribute('top', '-20px') # XXX: need to force CSS |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
207 self.toggle_syntax_button.setStyleAttribute('left', '-20px') |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
208 else: |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
209 try: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
210 self.toggle_syntax_button.removeFromParent() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
211 except (AttributeError, TypeError): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
212 pass |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
213 |
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
214 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
215 def edit(self, edit=True): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
216 """Toggle the bubble between display and edit mode""" |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
217 try: |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
218 self.toggle_syntax_button.removeFromParent() |
595
d78126d82ca0
browser side (blog module): fixed isJidAccepted + added __str__ method to facilitate debugging + use of AttributeError and TypeError in some exception (because pyjamas can raise both depending on compilation options)
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
219 except (AttributeError, TypeError): |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
220 pass |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
221 self.bubble.edit(edit) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
222 if edit: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
223 if self.mode in ENTRY_RICH: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
224 # image = '<a class="richTextIcon">A</a>' |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
225 html = '<a style="color: blue;">raw text</a>' |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
226 # title = _('Switch to raw text edition') |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
227 else: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
228 # image = '<img src="media/icons/tango/actions/32/format-text-italic.png" class="richTextIcon"/>' |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
229 html = '<a style="color: blue;">rich text</a>' |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
230 # title = _('Switch to rich text edition') |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
231 self.toggle_syntax_button = HTML(html) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
232 self.toggle_syntax_button.addClickListener(self.toggleContentSyntax) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
233 self.toggle_syntax_button.addStyleName('mb_entry_toggle_syntax') |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
234 self.entry_dialog.add(self.toggle_syntax_button) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
235 self.toggle_syntax_button.setStyleAttribute('top', '-20px') # XXX: need to force CSS |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
236 self.toggle_syntax_button.setStyleAttribute('left', '-20px') |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
237 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
238 # def updateAvatar(self, new_avatar): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
239 # """Change the avatar of the entry |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
240 # @param new_avatar: path to the new image""" |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
241 # self.avatar.setUrl(new_avatar) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
242 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
243 def onClick(self, sender): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
244 if sender == self: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
245 self.blog.setSelectedEntry(self) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
246 elif sender == self.delete_label: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
247 self._onRetractClick() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
248 elif sender == self.update_label: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
249 self.edit(True) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
250 elif sender == self.comment_label: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
251 self._onCommentClick() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
252 # elif sender == self.show_comments_link: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
253 # self._blog_panel.loadAllCommentsForEntry(self) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
254 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
255 def _modifiedCb(self, content): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
256 """Send the new content to the backend |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
257 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
258 @return: False to restore the original content if a deletion has been cancelled |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
259 """ |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
260 if not content['text']: # previous content has been emptied |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
261 return False |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
262 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
263 self.item.content = self.item.content_rich = self.item.content_xhtml = None |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
264 self.item.title = self.item.title_rich = self.item.title_xhtml = None |
362
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
265 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
266 if self.mode in ENTRY_RICH: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
267 # TODO: if the user change his parameters after the message edition started, |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
268 # the message syntax could be different then the current syntax: pass the |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
269 # message syntax in mb_data for the frontend to use it instead of current syntax. |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
270 self.item.content_rich = content['text'] |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
271 self.item.title = content['title'] |
762
8eeb98659de2
browser_side (blog): tags were not read when receiving a message
souliane <souliane@mailoo.org>
parents:
761
diff
changeset
|
272 self.item.tags = list(common.dict2iter('tag', content)) |
362
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
273 else: |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
274 self.item.content = content['text'] |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
275 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
276 self.send() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
277 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
278 return True |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
279 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
280 def _afterEditCb(self, content): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
281 """Post edition treatments |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
282 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
283 Remove the entry if it was an empty one (used for creating a new blog post). |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
284 Data for the actual new blog post will be received from the bridge |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
285 @param content(dict): edited content |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
286 """ |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
287 if self.new: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
288 if self.level == 0: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
289 # we have a main item, we keep the edit entry |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
290 self.reset(None) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
291 # FIXME: would be better to reset bubble |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
292 # but bubble.setContent() doesn't seem to work |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
293 self.bubble.removeFromParent() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
294 self._setBubble() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
295 else: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
296 # we don't keep edit entries for comments |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
297 self.delete() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
298 else: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
299 self._showSyntaxSwitchButton(False) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
300 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
301 def _showWarning(self, sender, keycode, modifiers): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
302 if keycode == keyb.KEY_ENTER & keyb.MODIFIER_SHIFT: # FIXME: fix edit_listeners, it's dirty (we have to check keycode/modifiers twice !) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
303 self.blog.host.showWarning(None, None) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
304 else: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
305 # self.blog.host.showWarning(*self.blog.getWarningData(self.type == 'comment')) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
306 self.blog.host.showWarning(*self.blog.getWarningData(False)) # FIXME: comments are not yet reimplemented |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
307 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
308 def _onRetractClick(self): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
309 """Ask confirmation then retract current entry.""" |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
310 assert not self.new |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
311 |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
312 def confirm_cb(answer): |
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
313 if answer: |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
314 self.retract() |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
315 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
316 entry_type = _("message") if self.level == 0 else _("comment") |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
317 and_comments = _(" All comments will be also deleted!") if self.item.comments else "" |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
318 text = _("Do you really want to delete this {entry_type}?{and_comments}").format( |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
319 entry_type=entry_type, and_comments=and_comments) |
351
c943fd54c90e
browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents:
350
diff
changeset
|
320 dialog.ConfirmDialog(confirm_cb, text=text).show() |
119 | 321 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
322 def _onCommentClick(self): |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
323 """Add an empty entry for a new comment""" |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
324 if self._current_comment is None: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
325 if not self.item.comments_service or not self.item.comments_node: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
326 log.warning("Invalid service and node for comments, can pcreate a comment") |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
327 self._current_comment = self.addEntry(editable=True, service=self.item.comments_service, node=self.item.comments_node) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
328 self.blog.setSelectedEntry(self._current_comment, True) |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
329 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
330 def _changeMode(self, original_content, text): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
331 self.mode = C.ENTRY_MODE_RICH if self.mode == C.ENTRY_MODE_TEXT else C.ENTRY_MODE_TEXT |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
332 if self.mode in ENTRY_RICH and not text: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
333 text = ' ' # something different than empty string is needed to initialize the rich text editor |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
334 self.item.content = text |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
335 self.bubble.removeFromParent() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
336 self._setBubble() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
337 self.bubble.setOriginalContent(original_content) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
338 if self.mode in ENTRY_RICH: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
339 self.item.content_xhtml = text |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
340 self.bubble.setDisplayContent() # needed in case the edition is aborted, to not end with an empty bubble |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
341 else: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
342 self.item.content_xhtml = '' |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
343 |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
344 def toggleContentSyntax(self): |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
345 """Toggle the editor between raw and rich text""" |
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
346 original_content = self.bubble.getOriginalContent() |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
347 rich = self.mode in ENTRY_RICH |
400
487dd238ab88
browser_side: bug fixes for microblog raw/rich edition toggle
souliane <souliane@mailoo.org>
parents:
397
diff
changeset
|
348 if rich: |
433
bbdbee25123a
import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents:
432
diff
changeset
|
349 original_content['syntax'] = C.SYNTAX_XHTML |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
350 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
351 text = self.bubble.getContent()['text'] |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
352 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
353 if not text.strip(): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
354 self._changeMode(original_content,'') |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
355 else: |
400
487dd238ab88
browser_side: bug fixes for microblog raw/rich edition toggle
souliane <souliane@mailoo.org>
parents:
397
diff
changeset
|
356 if rich: |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
357 def confirm_cb(answer): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
358 if answer: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
359 self.blog.host.bridge.syntaxConvert(text, C.SYNTAX_CURRENT, C.SYNTAX_TEXT, profile=None, |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
360 callback=lambda converted: self._changeMode(original_content, converted)) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
361 dialog.ConfirmDialog(confirm_cb, text=_("Do you really want to lose the title and text formatting?")).show() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
362 else: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
363 self.blog.host.bridge.syntaxConvert(text, C.SYNTAX_TEXT, C.SYNTAX_XHTML, profile=None, |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
364 callback=lambda converted: self._changeMode(original_content, converted)) |
395
98cd5387d291
browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents:
394
diff
changeset
|
365 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
366 def update(self, entry=None): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
367 """Update comments""" |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
368 self._createCommentsPanel() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
369 self.entries.sort(key=lambda entry: entry.item.published, reverse=True) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
370 idx = 0 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
371 for entry in self.entries: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
372 if not entry.displayed: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
373 self.comments_panel.insert(entry, idx) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
374 entry.displayed = True |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
375 idx += 1 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
376 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
377 def delete(self): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
378 quick_blog.Entry.delete(self) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
379 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
380 # _current comment is specific to libervia, we remove it |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
381 if isinstance(self.manager, Entry): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
382 self.manager._current_comment = None |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
383 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
384 # now we remove the pyjamas widgets |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
385 parent = self.parent |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
386 assert isinstance(parent, VerticalPanel) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
387 self.removeFromParent() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
388 if not parent.children: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
389 # the vpanel is empty, we remove it |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
390 parent.removeFromParent() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
391 try: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
392 if self.manager.comments_panel == parent: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
393 self.manager.comments_panel = None |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
394 except AttributeError: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
395 assert isinstance(self.manager, quick_blog.QuickBlog) |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
396 |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
397 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
398 class Blog(quick_blog.QuickBlog, libervia_widget.LiberviaWidget, MouseHandler): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
399 """Panel used to show microblog""" |
499
ec3f30253040
browser_side: also display the warning banner when writing to a single contact and unibox is disabled
souliane <souliane@mailoo.org>
parents:
498
diff
changeset
|
400 warning_msg_public = "This message will be <b>PUBLIC</b> and everybody will be able to see it, even people you don't know" |
652
0262fee86375
browser_side: MicroblogPanel.accepted_groups (set of unicode) is now built from QuickWidget.targets (set of tuple of unicode)
souliane <souliane@mailoo.org>
parents:
651
diff
changeset
|
401 warning_msg_group = "This message will be published for all the people of the following groups: <span class='warningTarget'>%s</span>" |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
402 |
652
0262fee86375
browser_side: MicroblogPanel.accepted_groups (set of unicode) is now built from QuickWidget.targets (set of tuple of unicode)
souliane <souliane@mailoo.org>
parents:
651
diff
changeset
|
403 def __init__(self, host, targets, profiles=None): |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
404 quick_blog.QuickBlog.__init__(self, host, targets, C.PROF_KEY_NONE) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
405 title = ", ".join(targets) if targets else "Blog" |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
406 libervia_widget.LiberviaWidget.__init__(self, host, title, selectable=True) |
586
3eb3a2c0c011
browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
585
diff
changeset
|
407 MouseHandler.__init__(self) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
408 self.vpanel = VerticalPanel() |
83 | 409 self.vpanel.setStyleName('microblogPanel') |
34 | 410 self.setWidget(self.vpanel) |
752
9b57d117e8c5
browser side: features are checked for microblogging and group blogging. If one of them is not available, a pop-up warns it, and it is not possible to write a new entry.
Goffi <goffi@goffi.org>
parents:
748
diff
changeset
|
411 if ((self._targets_type == C.ALL and self.host.mblog_available) or |
9b57d117e8c5
browser side: features are checked for microblogging and group blogging. If one of them is not available, a pop-up warns it, and it is not possible to write a new entry.
Goffi <goffi@goffi.org>
parents:
748
diff
changeset
|
412 (self._targets_type == C.GROUP and self.host.groupblog_available)): |
9b57d117e8c5
browser side: features are checked for microblogging and group blogging. If one of them is not available, a pop-up warns it, and it is not possible to write a new entry.
Goffi <goffi@goffi.org>
parents:
748
diff
changeset
|
413 self.addEntry(editable=True, first=True) |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
414 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
415 self.getAll() |
624
9092e624bb27
browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents:
622
diff
changeset
|
416 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
417 # self.footer = HTML('', StyleName='microblogPanel_footer') |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
418 # self.footer.waiting = False |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
419 # self.footer.addClickListener(self) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
420 # self.footer.addMouseListener(self) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
421 # self.vpanel.add(self.footer) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
422 # self.next_rsm_index = 0 |
312
b4781a350483
browser_side: display a "New message" button and add a "comment" icon for main entries in MicroblogPanel when the unibox is disabled
souliane <souliane@mailoo.org>
parents:
311
diff
changeset
|
423 |
595
d78126d82ca0
browser side (blog module): fixed isJidAccepted + added __str__ method to facilitate debugging + use of AttributeError and TypeError in some exception (because pyjamas can raise both depending on compilation options)
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
424 def __str__(self): |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
425 return u"Blog Widget [targets: {}, profile: {}]".format(", ".join(self.targets) if self.targets else "meta blog", self.profile) |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
426 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
427 def update(self): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
428 self.entries.sort(key=lambda entry: entry.item.published, reverse=True) |
607
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
429 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
430 idx = 0 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
431 if self._first_entry is not None: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
432 idx += 1 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
433 if not self._first_entry.displayed: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
434 self.vpanel.insert(self._first_entry, 0) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
435 self._first_entry.displayed = True |
607
537649f6a2d0
browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents:
606
diff
changeset
|
436 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
437 for entry in self.entries: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
438 if not entry.displayed: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
439 self.vpanel.insert(entry, idx) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
440 entry.displayed = True |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
441 idx += 1 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
442 |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
443 # def onDelete(self): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
444 # quick_widgets.QuickWidget.onDelete(self) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
445 # self.host.removeListener('avatar', self.avatarListener) |
18
795d144fc1d2
moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
446 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
447 # def onAvatarUpdate(self, jid_, hash_, profile): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
448 # """Called on avatar update events |
461
4f25aa5039b3
browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents:
451
diff
changeset
|
449 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
450 # @param jid_: jid of the entity with updated avatar |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
451 # @param hash_: hash of the avatar |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
452 # @param profile: %(doc_profile)s |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
453 # """ |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
454 # whoami = self.host.profiles[self.profile].whoami |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
455 # if self.isJidAccepted(jid_) or jid_.bare == whoami.bare: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
456 # self.updateValue('avatar', jid_, hash_) |
461
4f25aa5039b3
browser_side: avoid adding more than one new message bubble on top of the microblog panel
souliane <souliane@mailoo.org>
parents:
451
diff
changeset
|
457 |
598
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
597
diff
changeset
|
458 @staticmethod |
651
2df91d0308ac
browser_side, server_side: MicroblogPanel.onGroupDrop and bridge method getMassiveLastMBlogs now only accepts the publishers as a set of unicode (no more None value or single unicode).
souliane <souliane@mailoo.org>
parents:
648
diff
changeset
|
459 def onGroupDrop(host, targets): |
2df91d0308ac
browser_side, server_side: MicroblogPanel.onGroupDrop and bridge method getMassiveLastMBlogs now only accepts the publishers as a set of unicode (no more None value or single unicode).
souliane <souliane@mailoo.org>
parents:
648
diff
changeset
|
460 """Create a microblog panel for one, several or all contact groups. |
195 | 461 |
617
5baca9d46c34
browser_side: add/improve some docstrings
souliane <souliane@mailoo.org>
parents:
616
diff
changeset
|
462 @param host (SatWebFrontend): the SatWebFrontend instance |
651
2df91d0308ac
browser_side, server_side: MicroblogPanel.onGroupDrop and bridge method getMassiveLastMBlogs now only accepts the publishers as a set of unicode (no more None value or single unicode).
souliane <souliane@mailoo.org>
parents:
648
diff
changeset
|
463 @param targets (tuple(unicode)): tuple of groups (empty for "all groups") |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
464 @return: the created MicroblogPanel |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
465 """ |
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
466 # XXX: pyjamas doesn't support use of cls directly |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
467 widget = host.displayWidget(Blog, targets, dropped=True) |
598
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
597
diff
changeset
|
468 return widget |
230
266e9678eec0
browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents:
226
diff
changeset
|
469 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
470 # @property |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
471 # def accepted_groups(self): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
472 # """Return a set of the accepted groups""" |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
473 # return set().union(*self.targets) |
586
3eb3a2c0c011
browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
585
diff
changeset
|
474 |
667
166f3b624816
browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
475 def getWarningData(self, comment): |
362
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
476 """ |
667
166f3b624816
browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
477 @param comment: set to True if the composed message is a comment |
362
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
478 @return: a couple (type, msg) for calling self.host.showWarning""" |
019e1e706e74
browser_side: display the popup notifying the message's recipient when you edit the blog entry's bubble.
souliane <souliane@mailoo.org>
parents:
361
diff
changeset
|
479 if comment: |
202
2bc6cf004e61
browser, server: comments handling:
Goffi <goffi@goffi.org>
parents:
201
diff
changeset
|
480 return ("PUBLIC", "This is a <span class='warningTarget'>comment</span> and keep the initial post visibility, so it is potentialy public") |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
481 elif self._targets_type == C.ALL: |
201
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
482 # we have a meta MicroblogPanel, we publish publicly |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
483 return ("PUBLIC", self.warning_msg_public) |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
484 else: |
aa76793da353
server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents:
200
diff
changeset
|
485 # FIXME: manage several groups |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
486 return (self._targets_type, self.warning_msg_group % ' '.join(self.targets)) |
282
ae3ec654836d
browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents:
279
diff
changeset
|
487 |
496
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
488 def ensureVisible(self, entry): |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
489 """Scroll to an entry to ensure its visibility |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
490 |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
491 @param entry (MicroblogEntry): the entry |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
492 """ |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
493 current = entry |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
494 while True: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
495 parent = current.getParent() |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
496 if parent is None: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
497 log.warning("Can't find any parent ScrollPanel") |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
498 return |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
499 elif isinstance(parent, ScrollPanel): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
500 parent.ensureVisible(current) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
501 return |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
502 else: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
503 current = parent |
496
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
504 |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
505 def setSelectedEntry(self, entry, ensure_visible=False): |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
506 """Select an entry. |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
507 |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
508 @param entry (MicroblogEntry): the entry to select |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
509 @param ensure_visible (boolean): if True, also scroll to the entry |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
510 """ |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
511 if ensure_visible: |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
512 self.ensureVisible(entry) |
0924710b666a
browser_side: remove the annoying (esp. when editing a message) scrolling each time you select a microblog entry
souliane <souliane@mailoo.org>
parents:
495
diff
changeset
|
513 |
667
166f3b624816
browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
514 entry.addStyleName('selected_entry') # blink the clicked entry |
166f3b624816
browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
515 clicked_entry = entry # entry may be None when the timer is done |
166f3b624816
browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents:
662
diff
changeset
|
516 Timer(500, lambda timer: clicked_entry.removeStyleName('selected_entry')) |
199
39311c7dad77
browser side: it is now possible to select a microblog panel or an entry inside it
Goffi <goffi@goffi.org>
parents:
195
diff
changeset
|
517 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
518 # def updateValue(self, type_, jid_, value): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
519 # """Update a jid value in entries |
589
a5019e62c3e9
browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents:
585
diff
changeset
|
520 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
521 # @param type_: one of 'avatar', 'nick' |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
522 # @param jid_(jid.JID): jid concerned |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
523 # @param value: new value""" |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
524 # assert isinstance(jid_, jid.JID) # FIXME: temporary |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
525 # def updateVPanel(vpanel): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
526 # avatar_url = self.host.getAvatarURL(jid_) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
527 # for child in vpanel.children: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
528 # if isinstance(child, MicroblogEntry) and child.author == jid_: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
529 # child.updateAvatar(avatar_url) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
530 # elif isinstance(child, VerticalPanel): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
531 # updateVPanel(child) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
532 # if type_ == 'avatar': |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
533 # updateVPanel(self.vpanel) |
595
d78126d82ca0
browser side (blog module): fixed isJidAccepted + added __str__ method to facilitate debugging + use of AttributeError and TypeError in some exception (because pyjamas can raise both depending on compilation options)
Goffi <goffi@goffi.org>
parents:
589
diff
changeset
|
534 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
535 # def onClick(self, sender): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
536 # if sender == self.footer: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
537 # self.loadMoreMainEntries() |
598
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
597
diff
changeset
|
538 |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
539 # def onMouseEnter(self, sender): |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
540 # if sender == self.footer: |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
541 # self.loadMoreMainEntries() |
586
3eb3a2c0c011
browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents:
585
diff
changeset
|
542 |
598
ed6d8f7c6026
browser side (blog, chat): fixed dropKey callbacks to adapt them to new widget creation system. Drag'n'Drop should be fixed.
Goffi <goffi@goffi.org>
parents:
597
diff
changeset
|
543 |
748
0d5889b9313c
browser side: fixed group panel drop and contact_list click on GroupLabel
Goffi <goffi@goffi.org>
parents:
716
diff
changeset
|
544 libervia_widget.LiberviaWidget.addDropKey("GROUP", lambda host, item: Blog.onGroupDrop(host, (item,))) |
716
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
545 libervia_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", lambda host, item: Blog.onGroupDrop(host, ())) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
546 quick_blog.registerClass("ENTRY", Entry) |
3b91225b457a
server + browser side: blogging refactoring (draft), huge commit sorry:
Goffi <goffi@goffi.org>
parents:
713
diff
changeset
|
547 quick_widgets.register(quick_blog.QuickBlog, Blog) |