annotate src/browser/sat_browser/blog.py @ 705:531eacb82e9f

browser and server sides: renamed max to max_ after sat's changeset 1423 (882e5fabf68c)
author souliane <souliane@mailoo.org>
date Thu, 04 Jun 2015 12:03:45 +0200
parents 82123705474b
children d75935e2b279
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
9877607c719a 2015 copyright dates update
Goffi <goffi@goffi.org>
parents: 679
diff changeset
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__)
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
23
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
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
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from pyjamas.ui.HorizontalPanel import HorizontalPanel
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from pyjamas.ui.Label import Label
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
30 from pyjamas.ui.HTML import HTML
83
68d360caeecb New widget system: first draft
Goffi <goffi@goffi.org>
parents: 78
diff changeset
31 from pyjamas.ui.Image import Image
19
e8e3704eb97f Added basic chat panel
Goffi <goffi@goffi.org>
parents: 18
diff changeset
32 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
33 from pyjamas.ui.FlowPanel import FlowPanel
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
34 from pyjamas.ui.KeyboardListener import KEY_ENTER, KeyboardHandler
323
0b7934e75e76 misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents: 322
diff changeset
35 from pyjamas.ui.FocusListener import FocusHandler
186
72bb1d845b6a browser side: global resize on UniBox resize
Goffi <goffi@goffi.org>
parents: 185
diff changeset
36 from pyjamas.ui.MouseListener import MouseHandler
33
e70521e6d803 browser side, misc stuffs
Goffi <goffi@goffi.org>
parents: 27
diff changeset
37 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
38
0b7934e75e76 misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents: 322
diff changeset
39 from datetime import datetime
0b7934e75e76 misc: reorganization of the file panels.py + clean the modules import:
souliane <souliane@mailoo.org>
parents: 322
diff changeset
40 from time import time
449
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
41
467
97c72fe4a5f2 browser_side: import fixes:
Goffi <goffi@goffi.org>
parents: 463
diff changeset
42 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
43 import dialog
981ed669d3b3 /!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents: 442
diff changeset
44 import richtext
648
6d3142b782c3 browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents: 638
diff changeset
45 import editor_widget
6d3142b782c3 browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents: 638
diff changeset
46 import libervia_widget
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
47 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
48 from sat_frontends.quick_frontend import quick_widgets
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
49 from sat_frontends.tools import jid
279
2d6bd975a72d browser_side: set your own presence status and display those of others
souliane <souliane@mailoo.org>
parents: 276
diff changeset
50
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
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
53
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
54
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
55 class MicroblogItem():
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
56 # XXX: should be moved in a separated module
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
57
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
58 def __init__(self, data):
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
59 self.id = data['id']
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
60 self.type = data.get('type', 'main_item')
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
61 self.empty = data.get('new', False)
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
62 self.title = data.get('title', '')
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
63 self.title_xhtml = data.get('title_xhtml', '')
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
64 self.content = data.get('content', '')
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
65 self.content_xhtml = data.get('content_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
66 self.author = jid.JID(data['author'])
307
44b46db7dfef browser_side (groupblog): order items using "published" instead of "updated"
souliane <souliane@mailoo.org>
parents: 306
diff changeset
67 self.updated = float(data.get('updated', 0)) # XXX: int doesn't work here
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
68 self.published = float(data.get('published', self.updated)) # XXX: int doesn't work here
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
69 self.service = data.get('service', '')
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
70 self.node = data.get('node', '')
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
71 self.comments = data.get('comments', False)
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
72 self.comments_service = data.get('comments_service', '')
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
73 self.comments_node = data.get('comments_node', '')
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
74
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
75
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
76 class MicroblogEntry(SimplePanel, ClickHandler, FocusHandler, KeyboardHandler):
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
77
350
f1b9ec412769 browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents: 349
diff changeset
78 def __init__(self, blog_panel, 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
79 """
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
80 @param blog_panel: the parent panel
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
81 @param data: dict containing the blog item data, or a MicroblogItem instance.
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
82 """
350
f1b9ec412769 browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents: 349
diff changeset
83 self._base_item = data if isinstance(data, MicroblogItem) else MicroblogItem(data)
f1b9ec412769 browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents: 349
diff changeset
84 for attr in ['id', 'type', 'empty', 'title', 'title_xhtml', 'content', 'content_xhtml',
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
85 'author', 'updated', 'published', 'comments', 'service', 'node',
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
86 'comments_service', 'comments_node']:
350
f1b9ec412769 browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents: 349
diff changeset
87 getter = lambda attr: lambda inst: getattr(inst._base_item, attr)
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
88 setter = lambda attr: lambda inst, value: setattr(inst._base_item, attr, value)
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
89 setattr(MicroblogEntry, attr, property(getter(attr), setter(attr)))
350
f1b9ec412769 browser_side: MicroblogEntry defines properties to access MicroblogItem attributes (instead of overwriting __getattr__)
souliane <souliane@mailoo.org>
parents: 349
diff changeset
90
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
91 SimplePanel.__init__(self)
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
92 self._blog_panel = blog_panel
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
93
291
89818bca1a33 browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents: 289
diff changeset
94 self.panel = FlowPanel()
89818bca1a33 browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents: 289
diff changeset
95 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
96
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
97 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
98 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
99
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
100 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
101 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
102 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
103
89818bca1a33 browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents: 289
diff changeset
104 entry_avatar = SimplePanel()
89818bca1a33 browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents: 289
diff changeset
105 entry_avatar.setStyleName('mb_entry_avatar')
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
106 assert isinstance(self.author, jid.JID) # FIXME: temporary
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
107 self.avatar = Image(self._blog_panel.host.getAvatarURL(self.author)) # FIXME: self.author should be initially a jid.JID
291
89818bca1a33 browser_side: set the ideal width for the blog post update dialog
souliane <souliane@mailoo.org>
parents: 289
diff changeset
108 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
109 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
110
667
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
111 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
112 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
113 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
114
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
115 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
116 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
117 self.addClickListener(self)
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
118
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
119 self.__pub_data = (self.service, self.node, self.id)
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
120 self.__setContent()
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
121
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
122 def __setContent(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
123 """Actually set the entry content (header, icons, bubble...)"""
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
124 self.delete_label = self.update_label = self.comment_label = None
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
125 self.bubble = self._current_comment = None
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
126 self.__setHeader()
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
127 self.__setBubble()
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
128 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
129
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
130 def __setHeader(self):
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
131 """Set the 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
132 if self.empty:
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
133 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
134 update_text = u" — ✍ " + "<span class='mb_entry_timestamp'>%s</span>" % datetime.fromtimestamp(self.updated)
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
135 self.header.add(HTML("""<span class='mb_entry_header_info'>
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
136 <span class='mb_entry_author'>%(author)s</span> on
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
137 <span class='mb_entry_timestamp'>%(published)s</span>%(updated)s
679
a90cc8fc9605 merged branch frontends_multi_profiles
Goffi <goffi@goffi.org>
parents: 586 667
diff changeset
138 </span>""" % {'author': html_tools.html_sanitize(unicode(self.author)),
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
139 'published': datetime.fromtimestamp(self.published),
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
140 'updated': update_text if self.published != self.updated else ''
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
141 }))
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
142 if self.comments:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
143 self.comments_count = self.hidden_count = 0
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
144 self.show_comments_link = HTML('')
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
145 self.header.add(self.show_comments_link)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
146
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
147 def updateHeader(self, comments_count=None, hidden_count=None, inc=None):
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
148 """Update the header.
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
149
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
150 @param comments_count (int): total number of comments.
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
151 @param hidden_count (int): number of hidden comments.
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
152 @param inc (int): number to increment the total number of comments with.
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
153 """
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
154 if comments_count is not None:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
155 self.comments_count = comments_count
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
156 if hidden_count is not None:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
157 self.hidden_count = hidden_count
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
158 if inc is not None:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
159 self.comments_count += inc
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
160
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
161 if self.hidden_count > 0:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
162 comments = D_('comments') if self.hidden_count > 1 else D_('comment')
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
163 text = D_("<a>show %(count)d previous %(comments)s</a>") % {'count': self.hidden_count,
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
164 'comments': comments}
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
165 if self not in self.show_comments_link._clickListeners:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
166 self.show_comments_link.addClickListener(self)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
167 else:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
168 if self.comments_count > 1:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
169 text = "%(count)d %(comments)s" % {'count': self.comments_count,
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
170 'comments': D_('comments')}
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
171 elif self.comments_count == 1:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
172 text = D_('1 comment')
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
173 else:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
174 text = ''
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
175 try:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
176 self.show_comments_link.removeClickListener(self)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
177 except ValueError:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
178 pass
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
179
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
180 self.show_comments_link.setHTML("""<span class='mb_entry_comments'>%(text)s</span></div>""" % {'text': text})
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
181
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
182 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
183 """Set the entry icons (delete, update, comment)"""
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
184 if self.empty:
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
185 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
186
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
187 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
188 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
189 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
190 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
191 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
192 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
193
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
194 if self.comments:
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
195 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
196 self.comment_label.setStyleName('mb_entry_action_larger')
366
39ae5bf92786 browser_side: allow one blogger to moderate the comments made on his own blog messages.
souliane <souliane@mailoo.org>
parents: 365
diff changeset
197 is_publisher = self.author == self._blog_panel.host.whoami.bare
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
198 if is_publisher:
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
199 self.update_label = addIcon(u"✍", "Edit this message")
662
ebb602d8b3f2 browser_side: replace all instances of 'str' with 'unicode'
souliane <souliane@mailoo.org>
parents: 653
diff changeset
200 if is_publisher or unicode(self.node).endswith(unicode(self._blog_panel.host.whoami.bare)):
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
201 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
202
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
203 def updateAvatar(self, new_avatar):
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
204 """Change the avatar of the entry
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
205 @param new_avatar: path to the new image"""
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
206 self.avatar.setUrl(new_avatar)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
207
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
208 def onClick(self, sender):
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
209 if sender == self:
322
971e3812903a browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents: 319
diff changeset
210 self._blog_panel.setSelectedEntry(self)
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
211 elif sender == self.delete_label:
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
212 self._delete()
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 elif sender == self.update_label:
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
214 self.edit(True)
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
215 elif sender == self.comment_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
216 self._comment()
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
217 elif sender == self.show_comments_link:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
218 self._blog_panel.loadAllCommentsForEntry(self)
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
219
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
220 def __modifiedCb(self, content):
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
221 """Send the new content to the backend
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
222 @return: False to restore the original content if a deletion has been cancelled
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
223 """
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
224 if not content['text']: # previous content has been emptied
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
225 self._delete(True)
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
226 return False
662
ebb602d8b3f2 browser_side: replace all instances of 'str' with 'unicode'
souliane <souliane@mailoo.org>
parents: 653
diff changeset
227 extra = {'published': unicode(self.published)}
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
228 if isinstance(self.bubble, richtext.RichTextEditor):
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
229 # TODO: if the user change his parameters after the message edition started,
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
230 # the message syntax could be different then the current syntax: pass the
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
231 # message syntax in extra for the frontend to use it instead of current syntax.
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
232 extra.update({'content_rich': content['text'], 'title': content['title']})
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
233 if self.empty:
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
234 if self.type == 'main_item':
653
e1d067378ad3 browser_side: fixes sending/updating blog message/comment
souliane <souliane@mailoo.org>
parents: 652
diff changeset
235 self._blog_panel.host.bridge.call('sendMblog', None, None, tuple(self._blog_panel.accepted_groups), content['text'], extra)
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
236 else:
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
237 self._blog_panel.host.bridge.call('sendMblogComment', None, self._parent_entry.comments, content['text'], extra)
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
238 else:
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
239 self._blog_panel.host.bridge.call('updateMblog', None, self.__pub_data, self.comments, content['text'], extra)
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
240 return True
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
241
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
242 def __afterEditCb(self, content):
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
243 """Remove the entry if it was an empty one (used for creating a new blog post).
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
244 Data for the actual new blog post will be received from the bridge"""
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
245 if self.empty:
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
246 self._blog_panel.removeEntry(self.type, self.id, update_header=False)
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
247 if self.type == 'main_item': # restore the "New message" button
667
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
248 self._blog_panel.addNewMessageEntry()
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
249 else: # allow to create a new comment
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
250 self._parent_entry._current_comment = None
425
19bd203daa27 browser_side: set microblog editor width to 80%
souliane <souliane@mailoo.org>
parents: 422
diff changeset
251 self.entry_dialog.setWidth('auto')
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
252 try:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
253 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
254 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
255 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
256
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
257 def __setBubble(self, edit=False):
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
258 """Set the bubble displaying the initial content."""
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
259 content = {'text': self.content_xhtml if self.content_xhtml else self.content,
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
260 'title': self.title_xhtml if self.title_xhtml else self.title}
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
261 if self.content_xhtml:
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
262 content.update({'syntax': C.SYNTAX_XHTML})
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
263 if self.author != self._blog_panel.host.whoami.bare:
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
264 options = ['read_only']
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
265 else:
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
266 options = [] if self.empty else ['update_msg']
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
267 self.bubble = richtext.RichTextEditor(self._blog_panel.host, content, self.__modifiedCb, self.__afterEditCb, options)
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
268 else: # assume raw text message have no title
648
6d3142b782c3 browser_side: classes reorganisation:
Goffi <goffi@goffi.org>
parents: 638
diff changeset
269 self.bubble = editor_widget.LightTextEditor(content, self.__modifiedCb, self.__afterEditCb, options={'no_xhtml': True})
425
19bd203daa27 browser_side: set microblog editor width to 80%
souliane <souliane@mailoo.org>
parents: 422
diff changeset
270 self.bubble.addStyleName("bubble")
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
271 try:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
272 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
273 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
274 pass
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
275 self.entry_dialog.add(self.bubble)
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
276 self.edit(edit)
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
277 self.bubble.addEditListener(self.__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
278
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
279 def __showWarning(self, sender, keycode):
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
280 if keycode == KEY_ENTER:
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
281 self._blog_panel.host.showWarning(None, None)
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
282 else:
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
283 self._blog_panel.host.showWarning(*self._blog_panel.getWarningData(self.type == 'comment'))
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
284
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
285 def _delete(self, empty=False):
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
286 """Ask confirmation for deletion.
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
287 @return: False if the deletion has been cancelled."""
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
288 def confirm_cb(answer):
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
289 if answer:
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
290 self._blog_panel.host.bridge.call('deleteMblog', None, self.__pub_data, self.comments)
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
291 else: # restore the text if it has been emptied during the edition
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
292 self.bubble.setContent(self.bubble._original_content)
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
293
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
294 if self.empty:
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
295 text = _("New ") + (_("message") if self.comments else _("comment")) + _(" without body has been cancelled.")
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
296 dialog.InfoDialog(_("Information"), text).show()
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
297 return
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
298 text = ""
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
299 if empty:
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
300 text = (_("Message") if self.comments else _("Comment")) + _(" body has been emptied.<br/>")
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
301 target = _('message and all its comments') if self.comments else _('comment')
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
302 text += _("Do you really want to delete this %s?") % target
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
303 dialog.ConfirmDialog(confirm_cb, text=text).show()
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
304
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
305 def _comment(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
306 """Add an empty entry for a new comment"""
315
09205b410a53 browser_side: handle successive click on blog post "edit" and "comment" icons
souliane <souliane@mailoo.org>
parents: 314
diff changeset
307 if self._current_comment:
351
c943fd54c90e browser_side: heavy refactorisation for microblogs:
souliane <souliane@mailoo.org>
parents: 350
diff changeset
308 self._current_comment.bubble.setFocus(True)
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
309 self._blog_panel.setSelectedEntry(self._current_comment, True)
315
09205b410a53 browser_side: handle successive click on blog post "edit" and "comment" icons
souliane <souliane@mailoo.org>
parents: 314
diff changeset
310 return
662
ebb602d8b3f2 browser_side: replace all instances of 'str' with 'unicode'
souliane <souliane@mailoo.org>
parents: 653
diff changeset
311 data = {'id': unicode(time()),
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
312 'new': True,
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
313 'type': 'comment',
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
314 'author': unicode(self._blog_panel.host.whoami.bare),
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
315 'service': self.comments_service,
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
316 'node': self.comments_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
317 }
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
318 entry = self._blog_panel.addEntry(data, update_header=False)
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
319 if entry is None:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
320 log.info("The entry of id %s can not be commented" % self.id)
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
321 return
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
322 entry._parent_entry = self
315
09205b410a53 browser_side: handle successive click on blog post "edit" and "comment" icons
souliane <souliane@mailoo.org>
parents: 314
diff changeset
323 self._current_comment = entry
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
324 self.edit(True, entry)
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
325 self._blog_panel.setSelectedEntry(entry, True)
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
326
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
327 def edit(self, edit, entry=None):
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
328 """Toggle the bubble between display and edit mode
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
329 @edit: boolean value
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
330 @entry: MicroblogEntry instance, or None to use self
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
331 """
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
332 if entry is None:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
333 entry = self
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
334 try:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
335 entry.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
336 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
337 pass
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
338 entry.bubble.edit(edit)
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
339 if edit:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
340 if isinstance(entry.bubble, richtext.RichTextEditor):
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
341 image = '<a class="richTextIcon">A</a>'
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
342 html = '<a style="color: blue;">raw text</a>'
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
343 title = _('Switch to raw text edition')
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
344 else:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
345 image = '<img src="media/icons/tango/actions/32/format-text-italic.png" class="richTextIcon"/>'
442
17259c2ff96f browser_side: changes about the UI (remarks from Franck):
souliane <souliane@mailoo.org>
parents: 439
diff changeset
346 html = '<a style="color: blue;">rich text</a>'
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
347 title = _('Switch to rich text edition')
667
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
348 entry.toggle_syntax_button = HTML(html)
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
349 entry.toggle_syntax_button.addClickListener(entry.toggleContentSyntax)
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
350 entry.toggle_syntax_button.addStyleName('mb_entry_toggle_syntax')
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
351 entry.entry_dialog.add(entry.toggle_syntax_button)
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
352 entry.toggle_syntax_button.setStyleAttribute('top', '-20px') # XXX: need to force CSS
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
353 entry.toggle_syntax_button.setStyleAttribute('left', '-20px')
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
354
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
355 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
356 """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
357 original_content = self.bubble.getOriginalContent()
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
358 rich = not isinstance(self.bubble, richtext.RichTextEditor)
400
487dd238ab88 browser_side: bug fixes for microblog raw/rich edition toggle
souliane <souliane@mailoo.org>
parents: 397
diff changeset
359 if rich:
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
360 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
361
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
362 def setBubble(text):
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
363 self.content = text
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
364 self.content_xhtml = text if rich else ''
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
365 self.content_title = self.content_title_xhtml = ''
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
366 self.bubble.removeFromParent()
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
367 self.__setBubble(True)
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
368 self.bubble.setOriginalContent(original_content)
400
487dd238ab88 browser_side: bug fixes for microblog raw/rich edition toggle
souliane <souliane@mailoo.org>
parents: 397
diff changeset
369 if rich:
487dd238ab88 browser_side: bug fixes for microblog raw/rich edition toggle
souliane <souliane@mailoo.org>
parents: 397
diff changeset
370 self.bubble.setDisplayContent() # needed in case the edition is aborted, to not end with an empty bubble
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
371
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
372 text = self.bubble.getContent()['text']
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
373 if not text:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
374 setBubble(' ') # something different than empty string is needed to initialize the rich text editor
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
375 return
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
376 if not rich:
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
377 def confirm_cb(answer):
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
378 if answer:
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
379 self._blog_panel.host.bridge.call('syntaxConvert', setBubble, text, C.SYNTAX_CURRENT, C.SYNTAX_TEXT)
395
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
380 dialog.ConfirmDialog(confirm_cb, text=_("Do you really want to lose the title and text formatting?")).show()
98cd5387d291 browser_side: new microblogs are not using the rich text editor by default:
souliane <souliane@mailoo.org>
parents: 394
diff changeset
381 else:
433
bbdbee25123a import constants.Const as C (according to the coding rules)
souliane <souliane@mailoo.org>
parents: 432
diff changeset
382 self._blog_panel.host.bridge.call('syntaxConvert', setBubble, text, C.SYNTAX_TEXT, C.SYNTAX_XHTML)
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
383
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
384
679
a90cc8fc9605 merged branch frontends_multi_profiles
Goffi <goffi@goffi.org>
parents: 586 667
diff changeset
385 class MicroblogPanel(quick_widgets.QuickWidget, libervia_widget.LiberviaWidget, MouseHandler):
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
386 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
387 warning_msg_group = "This message will be published for all the people of the following groups: <span class='warningTarget'>%s</span>"
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
388 # FIXME: all the generic parts must be moved to quick_frontends
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
389
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
390 def __init__(self, host, targets, profiles=None):
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
391 """Panel used to show microblog
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
392
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
393 @param targets (tuple(unicode)): contact groups displayed in this panel.
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
394 If empty, show all microblogs from all contacts.
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
395 """
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
396 # do not mix self.targets (set of tuple of unicode) and self.accepted_groups (set of unicode)
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
397 quick_widgets.QuickWidget.__init__(self, host, targets, C.PROF_KEY_NONE)
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
398 libervia_widget.LiberviaWidget.__init__(self, host, ", ".join(self.accepted_groups), selectable=True)
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
399 MouseHandler.__init__(self)
58
4fa3d57f72f8 browser side: microblog entries caching
Goffi <goffi@goffi.org>
parents: 57
diff changeset
400 self.entries = {}
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
401 self.comments = {}
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
402 self.vpanel = VerticalPanel()
83
68d360caeecb New widget system: first draft
Goffi <goffi@goffi.org>
parents: 78
diff changeset
403 self.vpanel.setStyleName('microblogPanel')
34
ed935f763cc8 browser side: misc css/layout fixes
Goffi <goffi@goffi.org>
parents: 33
diff changeset
404 self.setWidget(self.vpanel)
667
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
405 self.addNewMessageEntry()
624
9092e624bb27 browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents: 622
diff changeset
406
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
407 self.footer = HTML('', StyleName='microblogPanel_footer')
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
408 self.footer.waiting = False
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
409 self.footer.addClickListener(self)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
410 self.footer.addMouseListener(self)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
411 self.vpanel.add(self.footer)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
412 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
413
624
9092e624bb27 browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents: 622
diff changeset
414 # FIXME: workaround for a pyjamas issue: calling hash on a class method always return a different value if that method is defined directly within the class (with the "def" keyword)
9092e624bb27 browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents: 622
diff changeset
415 self.avatarListener = self.onAvatarUpdate
9092e624bb27 browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents: 622
diff changeset
416 host.addListener('avatar', self.avatarListener, [C.PROF_KEY_NONE])
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
417
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
418 def __str__(self):
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
419 return u"Blog Widget [target: {}, profile: {}]".format(', '.join(self.accepted_groups), self.profile)
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
420
607
537649f6a2d0 browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents: 606
diff changeset
421 def onDelete(self):
537649f6a2d0 browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents: 606
diff changeset
422 quick_widgets.QuickWidget.onDelete(self)
624
9092e624bb27 browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents: 622
diff changeset
423 self.host.removeListener('avatar', self.avatarListener)
607
537649f6a2d0 browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents: 606
diff changeset
424
638
63697f082e8a browser side: fixed use of profile for listeners
Goffi <goffi@goffi.org>
parents: 624
diff changeset
425 def onAvatarUpdate(self, jid_, hash_, profile):
607
537649f6a2d0 browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents: 606
diff changeset
426 """Called on avatar update events
537649f6a2d0 browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents: 606
diff changeset
427
537649f6a2d0 browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents: 606
diff changeset
428 @param jid_: jid of the entity with updated avatar
537649f6a2d0 browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents: 606
diff changeset
429 @param hash_: hash of the avatar
638
63697f082e8a browser side: fixed use of profile for listeners
Goffi <goffi@goffi.org>
parents: 624
diff changeset
430 @param profile: %(doc_profile)s
607
537649f6a2d0 browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents: 606
diff changeset
431 """
624
9092e624bb27 browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents: 622
diff changeset
432 whoami = self.host.profiles[self.profile].whoami
9092e624bb27 browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents: 622
diff changeset
433 if self.isJidAccepted(jid_) or jid_.bare == whoami.bare:
607
537649f6a2d0 browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents: 606
diff changeset
434 self.updateValue('avatar', jid_, hash_)
537649f6a2d0 browser side (blog, contact list): use of new listener mechanism to update avatar
Goffi <goffi@goffi.org>
parents: 606
diff changeset
435
667
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
436 def addNewMessageEntry(self):
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
437 """Add an empty entry for writing a new message if needed."""
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
438 if self.getNewMainEntry():
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
439 return # there's already one
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
440 data = {'id': unicode(time()),
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
441 'new': True,
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
442 'author': unicode(self.host.whoami.bare),
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
443 }
679
a90cc8fc9605 merged branch frontends_multi_profiles
Goffi <goffi@goffi.org>
parents: 586 667
diff changeset
444 entry = self.addEntry(data, update_header=False)
667
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
445 entry.edit(True)
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
446
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
447 def getNewMainEntry(self):
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
448 """Get the new entry being edited, or None if it doesn't exists.
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
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
450 @return (MicroblogEntry): the new entry being edited.
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
451 """
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
452 if len(self.vpanel.children) < 2:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
453 return None # there's only the footer
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
454 first = self.vpanel.children[0]
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
455 assert(first.type == 'main_item')
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
456 return first if first.empty else None
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
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
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
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
467 widget = host.displayWidget(MicroblogPanel, targets, dropped=True)
679
a90cc8fc9605 merged branch frontends_multi_profiles
Goffi <goffi@goffi.org>
parents: 586 667
diff changeset
468 widget.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
469 return widget
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
470
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
471 @property
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
472 def accepted_groups(self):
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
473 """Return a set of the accepted groups"""
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
474 return set().union(*self.targets)
195
dd27072d8ae0 browser side: widgets refactoring:
Goffi <goffi@goffi.org>
parents: 194
diff changeset
475
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
476 def loadAllCommentsForEntry(self, main_entry):
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
477 """Load all the comments for the given main entry.
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
478
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
479 @param main_entry (MicroblogEntry): main entry having comments.
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
480 """
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
481 index = str(main_entry.comments_count - main_entry.hidden_count)
705
531eacb82e9f browser and server sides: renamed max to max_ after sat's changeset 1423 (882e5fabf68c)
souliane <souliane@mailoo.org>
parents: 694
diff changeset
482 rsm = {'max_': str(main_entry.hidden_count), 'index': index}
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
483 self.host.bridge.call('getMblogComments', self.mblogsInsert, main_entry.comments_service, main_entry.comments_node, rsm)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
484
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
485 def loadMoreMainEntries(self):
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
486 if self.footer.waiting:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
487 return
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
488 self.footer.waiting = True
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
489 self.footer.setHTML("loading...")
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
490
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
491 self.host.loadOurMainEntries(self.next_rsm_index, self)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
492
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
493 type_ = 'ALL' if self.accepted_groups == [] else 'GROUP'
705
531eacb82e9f browser and server sides: renamed max to max_ after sat's changeset 1423 (882e5fabf68c)
souliane <souliane@mailoo.org>
parents: 694
diff changeset
494 rsm = {'max_': str(C.RSM_MAX_ITEMS), 'index': str(self.next_rsm_index)}
679
a90cc8fc9605 merged branch frontends_multi_profiles
Goffi <goffi@goffi.org>
parents: 586 667
diff changeset
495 self.host.bridge.getMassiveMblogs(type_, list(self.accepted_groups), rsm, profile=C.PROF_KEY_NONE, callback=self.massiveInsert)
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
496
667
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
497 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
498 """
667
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
499 @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
500 @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
501 if comment:
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
502 return ("PUBLIC", "This is a <span class='warningTarget'>comment</span> and keep the initial post visibility, so it is potentialy public")
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
503 elif not self.accepted_groups:
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
504 # we have a meta MicroblogPanel, we publish publicly
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
505 return ("PUBLIC", self.warning_msg_public)
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
506 else:
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
507 # FIXME: manage several groups
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
508 return ("GROUP", self.warning_msg_group % ' '.join(self.accepted_groups))
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
509
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
510 def onTextEntered(self, text):
667
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
511 if not self.accepted_groups:
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
512 # we are entering a public microblog
653
e1d067378ad3 browser_side: fixes sending/updating blog message/comment
souliane <souliane@mailoo.org>
parents: 652
diff changeset
513 self.bridge.call("sendMblog", None, "PUBLIC", (), text, {})
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
514 else:
653
e1d067378ad3 browser_side: fixes sending/updating blog message/comment
souliane <souliane@mailoo.org>
parents: 652
diff changeset
515 self.bridge.call("sendMblog", None, "GROUP", tuple(self.accepted_groups), text, {})
201
aa76793da353 server + browser: message warning level/sending refactoring:
Goffi <goffi@goffi.org>
parents: 200
diff changeset
516
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
517 def accept_all(self):
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
518 return not self.accepted_groups # we accept every microblog only if we are not filtering by groups
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
519
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
520 def getEntries(self):
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
521 """Ask all the entries for the currenly accepted groups,
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
522 and fill the panel"""
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
523
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
524 def massiveInsert(self, mblogs):
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
525 """Insert several microblogs at once
679
a90cc8fc9605 merged branch frontends_multi_profiles
Goffi <goffi@goffi.org>
parents: 586 667
diff changeset
526
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
527 @param mblogs (dict): dictionary mapping a publisher to microblogs data:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
528 - key: publisher (str)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
529 - value: couple (list[dict], dict) with:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
530 - list of microblogs data
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
531 - RSM response data
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
532 """
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
533 count_pub = len(mblogs)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
534 count_msg = sum([len(value) for value in mblogs.values()])
694
82123705474b massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents: 685
diff changeset
535 log.debug(u"massive insertion of {count_msg} blogs for {count_pub} contacts".format(count_msg=count_msg, count_pub=count_pub))
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
536 for publisher in mblogs:
694
82123705474b massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents: 685
diff changeset
537 log.debug(u"adding {count} blogs for [{publisher}]".format(count=len(mblogs[publisher]), publisher=publisher))
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
538 self.mblogsInsert(mblogs[publisher])
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
539 self.next_rsm_index += C.RSM_MAX_ITEMS
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
540 self.footer.waiting = False
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
541 self.footer.setHTML('show older messages')
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
542
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
543 def mblogsInsert(self, mblogs):
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
544 """ Insert several microblogs from the same node at once.
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
545
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
546 @param mblogs (list): couple (list[dict], dict) with:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
547 - list of microblogs data
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
548 - RSM response data
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
549 """
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
550 mblogs, rsm = mblogs
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
551
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
552 for mblog in mblogs:
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
553 if "content" not in mblog:
694
82123705474b massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
souliane <souliane@mailoo.org>
parents: 685
diff changeset
554 log.warning(u"No content found in microblog [%s]" % mblog)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
555 continue
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
556 self.addEntry(mblog, update_header=False)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
557
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
558 hashes = set([(entry['service'], entry['node']) for entry in mblogs if entry['type'] == 'comment'])
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
559 assert(len(hashes) < 2) # ensure the blogs come from the same node
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
560 if len(hashes) == 1:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
561 main_entry = self.comments[hashes.pop()]
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
562 count = int(rsm['count'])
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
563 hidden = count - (int(rsm['index']) + len(mblogs))
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
564 main_entry.updateHeader(count, hidden)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
565
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
566 def _chronoInsert(self, vpanel, entry, reverse=True):
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
567 """ Insert an entry in chronological order
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
568 @param vpanel: VerticalPanel instance
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
569 @param entry: MicroblogEntry
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
570 @param reverse: more recent entry on top if True, chronological order else"""
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
571 # XXX: for now we can't use "published" timestamp because the entries
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
572 # are retrieved using the "updated" field. We don't want new items
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
573 # inserted with RSM to be inserted "randomly" in the panel, they
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
574 # should be added at the bottom of the list.
463
b62c1cf0dbf7 browser side: a new message being edited should always stay on top position (or last position for a comment)
souliane <souliane@mailoo.org>
parents: 462
diff changeset
575 assert(isinstance(reverse, bool))
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
576 if entry.empty:
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
577 entry.updated = time()
135
ceef355156de server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents: 132
diff changeset
578 # we look for the right index to insert our entry:
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
579 # if reversed, we insert the entry above the first entry
135
ceef355156de server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents: 132
diff changeset
580 # in the past
ceef355156de server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents: 132
diff changeset
581 idx = 0
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
582
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
583 for child in vpanel.children[0:-1]: # ignore the footer
135
ceef355156de server + browser side: groupblog subscription + fixed blog insertion order
Goffi <goffi@goffi.org>
parents: 132
diff changeset
584 if not isinstance(child, MicroblogEntry):
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
585 idx += 1
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
586 continue
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
587 condition_to_stop = child.empty or (child.updated > entry.updated)
463
b62c1cf0dbf7 browser side: a new message being edited should always stay on top position (or last position for a comment)
souliane <souliane@mailoo.org>
parents: 462
diff changeset
588 if condition_to_stop != reverse: # != is XOR
b62c1cf0dbf7 browser side: a new message being edited should always stay on top position (or last position for a comment)
souliane <souliane@mailoo.org>
parents: 462
diff changeset
589 break
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
590 idx += 1
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
591
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
592 vpanel.insert(entry, idx)
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
593
597
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
594 def addEntryIfAccepted(self, sender, groups, mblog_entry):
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
595 """Check if an entry can go in MicroblogPanel and add to it
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
596
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
597 @param sender(jid.JID): jid of the entry sender
597
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
598 @param groups: groups which can receive this entry
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
599 @param mblog_entry: panels.MicroblogItem instance
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
600 """
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
601 assert isinstance(sender, jid.JID) # FIXME temporary
597
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
602 if (mblog_entry.type == "comment"
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
603 or self.isJidAccepted(sender)
624
9092e624bb27 browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents: 622
diff changeset
604 or (groups is None and sender == self.host.profiles[self.profile].whoami.bare)
597
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
605 or (groups and groups.intersection(self.accepted_groups))):
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
606 self.addEntry(mblog_entry)
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
607
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
608 def addEntry(self, data, update_header=True):
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
609 """Add an entry to the panel
597
be2891462e63 browser side (blog): added addEntryIfAccepeted method in MicroblogPanel, so it decide itself is an entry should be added, it's not done anymore in libervia_main.
Goffi <goffi@goffi.org>
parents: 595
diff changeset
610
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
611 @param data (dict): dict containing the item data
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
612 @param update_header (bool): update or not the main comment header
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
613 @return: the added MicroblogEntry instance, or None
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
614 """
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
615 _entry = MicroblogEntry(self, data)
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
616 if _entry.type == "comment":
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
617 comments_hash = (_entry.service, _entry.node)
624
9092e624bb27 browser_side: fixes various issues
souliane <souliane@mailoo.org>
parents: 622
diff changeset
618 if comments_hash not in self.comments:
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
619 # The comments node is not known in this panel
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
620 return None
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
621 parent = self.comments[comments_hash]
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
622 parent_idx = self.vpanel.getWidgetIndex(parent)
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
623 # we find or create the panel where the comment must be inserted
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
624 try:
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
625 sub_panel = self.vpanel.getWidget(parent_idx + 1)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
626 except IndexError:
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
627 sub_panel = None
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
628 if not sub_panel or not isinstance(sub_panel, VerticalPanel):
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
629 sub_panel = VerticalPanel()
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
630 sub_panel.setStyleName('microblogPanel')
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
631 sub_panel.addStyleName('subPanel')
226
744426c2b699 browser_side, misc: better PEP8 compliance
souliane <souliane@mailoo.org>
parents: 223
diff changeset
632 self.vpanel.insert(sub_panel, parent_idx + 1)
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
633
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
634 for idx in xrange(0, len(sub_panel.getChildren())):
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
635 comment = sub_panel.getIndexedChild(idx)
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
636 if comment.id == _entry.id:
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
637 # update an existing comment
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
638 sub_panel.remove(comment)
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
639 sub_panel.insert(_entry, idx)
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
640 return _entry
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
641 # we want comments to be inserted in chronological order
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
642 self._chronoInsert(sub_panel, _entry, reverse=False)
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
643 if update_header:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
644 parent.updateHeader(inc=+1)
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
645 return _entry
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
646
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
647 if _entry.comments:
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
648 # entry has comments, we keep the comments service/node as a reference
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
649 comments_hash = (_entry.comments_service, _entry.comments_node)
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
650 self.comments[comments_hash] = _entry
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
651 self.host.bridge.call('getMblogComments', self.mblogsInsert, _entry.comments_service, _entry.comments_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
652
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
653 if _entry.id in self.entries: # update
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
654 old_entry = self.entries[_entry.id]
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
655 idx = self.vpanel.getWidgetIndex(old_entry)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
656 counts = (old_entry.comments_count, old_entry.hidden_count)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
657 self.vpanel.remove(old_entry)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
658 self.vpanel.insert(_entry, idx)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
659 _entry.updateHeader(*counts)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
660 else: # new entry
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
661 self._chronoInsert(self.vpanel, _entry)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
662 if _entry.comments:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
663 self.host.bridge.call('getMblogComments', self.mblogsInsert, _entry.comments_service, _entry.comments_node)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
664
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
665 self.entries[_entry.id] = _entry
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
666
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
667 return _entry
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
668
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
669 def removeEntry(self, type_, id_, update_header=True):
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
670 """Remove an entry from the panel
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
671
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
672 @param type_ (str): entry type ('main_item' or 'comment')
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
673 @param id_ (str): entry id
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
674 @param update_header (bool): update or not the main comment header
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
675 """
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
676 for child in self.vpanel.getChildren():
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
677 if isinstance(child, MicroblogEntry) and type_ == 'main_item':
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
678 if child.id == id_:
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
679 main_idx = self.vpanel.getWidgetIndex(child)
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
680 try:
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
681 sub_panel = self.vpanel.getWidget(main_idx + 1)
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
682 if isinstance(sub_panel, VerticalPanel):
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
683 sub_panel.removeFromParent()
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
684 except IndexError:
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
685 pass
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
686 child.removeFromParent()
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
687 break
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
688 elif isinstance(child, VerticalPanel) and type_ == 'comment':
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
689 for comment in child.getChildren():
365
a74a2dfbe4f5 browser_side: groupblog: handle main items with no associated comments node + do not mix up attributes names between the item own service/node and the comments service/node
souliane <souliane@mailoo.org>
parents: 362
diff changeset
690 if comment.id == id_:
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
691 if update_header:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
692 hash_ = (comment.service, comment.node)
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
693 self.comments[hash_].updateHeader(inc=-1)
282
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
694 comment.removeFromParent()
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
695 break
ae3ec654836d browser_side: added blog item modification/deletion
souliane <souliane@mailoo.org>
parents: 279
diff changeset
696
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
697 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
698 """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
699
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
700 @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
701 """
322
971e3812903a browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents: 319
diff changeset
702 try:
971e3812903a browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents: 319
diff changeset
703 self.vpanel.getParent().ensureVisible(entry) # scroll to the clicked entry
971e3812903a browser_side: scroll to the clicked microblog post and blink it (previous behavior is conserved when the unibox is enabled)
souliane <souliane@mailoo.org>
parents: 319
diff changeset
704 except AttributeError:
439
d52f529a6d42 browser side: use of new log system (first draft):
Goffi <goffi@goffi.org>
parents: 433
diff changeset
705 log.warning("FIXME: MicroblogPanel.vpanel should be wrapped in a ScrollPanel!")
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
706
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
707 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
708 """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
709
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
710 @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
711 @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
712 """
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
713 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
714 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
715
667
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
716 entry.addStyleName('selected_entry') # blink the clicked entry
166f3b624816 browser_side (blog): clean the MicroblogPanel:
souliane <souliane@mailoo.org>
parents: 662
diff changeset
717 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
718 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
719
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
720 def updateValue(self, type_, jid_, value):
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
721 """Update a jid value in entries
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
722
241
86055ccf69c3 browser_side: added class PopupMenuPanel to manage more complex context menu
souliane <souliane@mailoo.org>
parents: 239
diff changeset
723 @param type_: one of 'avatar', 'nick'
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
724 @param jid_(jid.JID): jid concerned
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
725 @param value: new value"""
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
726 assert isinstance(jid_, jid.JID) # FIXME: temporary
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
727 def updateVPanel(vpanel):
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
728 avatar_url = self.host.getAvatarURL(jid_)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
729 for child in vpanel.children:
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
730 if isinstance(child, MicroblogEntry) and child.author == jid_:
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
731 child.updateAvatar(avatar_url)
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
732 elif isinstance(child, VerticalPanel):
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
733 updateVPanel(child)
241
86055ccf69c3 browser_side: added class PopupMenuPanel to manage more complex context menu
souliane <souliane@mailoo.org>
parents: 239
diff changeset
734 if type_ == 'avatar':
202
2bc6cf004e61 browser, server: comments handling:
Goffi <goffi@goffi.org>
parents: 201
diff changeset
735 updateVPanel(self.vpanel)
119
a8d11fdea090 microblog avatar update
Goffi <goffi@goffi.org>
parents: 114
diff changeset
736
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
737 def addAcceptedGroups(self, groups):
230
266e9678eec0 browser_side: added the flag REUSE_EXISTING_LIBERVIA_WIDGETS
souliane <souliane@mailoo.org>
parents: 226
diff changeset
738 """Add one or more group(s) which can be displayed in this panel.
589
a5019e62c3e9 browser side: big refactoring to base Libervia on QuickFrontend, first draft:
Goffi <goffi@goffi.org>
parents: 585
diff changeset
739
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
740 @param groups (tuple(unicode)): tuple of groups to add
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
741 """
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
742 # FIXME: update the widget's hash in QuickApp._widgets[MicroblogPanel]
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
743 self.targets.update(groups)
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
744
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
745 def isJidAccepted(self, jid_):
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
746 """Tell if a jid is actepted and must be shown in this panel
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
747
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
748 @param jid_(jid.JID): jid to check
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
749 @return: True if the jid is accepted
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
750 """
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
751 assert isinstance(jid_, jid.JID) # FIXME temporary
132
30d8e328559b server & browser side: microblogging refactoring first draft
Goffi <goffi@goffi.org>
parents: 131
diff changeset
752 if self.accept_all():
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
753 return True
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
754 for group in self.accepted_groups:
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
755 if self.host.contact_lists[self.profile].isEntityInGroup(jid_, group):
18
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
756 return True
795d144fc1d2 moved panels and menu in a separate file
Goffi <goffi@goffi.org>
parents:
diff changeset
757 return False
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
758
586
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
759 def onClick(self, sender):
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
760 if sender == self.footer:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
761 self.loadMoreMainEntries()
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
762
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
763 def onMouseEnter(self, sender):
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
764 if sender == self.footer:
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
765 self.loadMoreMainEntries()
3eb3a2c0c011 browser and server side: uses RSM (XEP-0059)
souliane <souliane@mailoo.org>
parents: 585
diff changeset
766
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
767
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
768 libervia_widget.LiberviaWidget.addDropKey("GROUP", lambda host, item: MicroblogPanel.onGroupDrop(host, (item,)))
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
769
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
770 # Needed for the drop keys to not be mixed between meta panel and panel for "Contacts" group
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
771 libervia_widget.LiberviaWidget.addDropKey("CONTACT_TITLE", lambda host, item: MicroblogPanel.onGroupDrop(host, ()))