Mercurial > libervia-web
annotate libervia.py @ 9:c80b75bf2e91
browser: misc appearance change
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 25 Mar 2011 00:31:27 +0100 |
parents | a663b9955cf3 |
children | 331c093e4eb3 |
rev | line source |
---|---|
0 | 1 #!/usr/bin/python |
2 # -*- coding: utf-8 -*- | |
3 | |
4 """ | |
5 Libervia: a Salut à Toi frontend | |
6 Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org) | |
7 | |
8 This program is free software: you can redistribute it and/or modify | |
9 it under the terms of the GNU Affero General Public License as published by | |
10 the Free Software Foundation, either version 3 of the License, or | |
11 (at your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, | |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 GNU Affero General Public License for more details. | |
17 | |
18 You should have received a copy of the GNU Affero General Public License | |
19 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
20 """ | |
21 | |
22 import pyjd # this is dummy in pyjs | |
23 from pyjamas.ui.SimplePanel import SimplePanel | |
24 from pyjamas.ui.RootPanel import RootPanel | |
25 from pyjamas.ui.VerticalPanel import VerticalPanel | |
26 from pyjamas.ui.HorizontalPanel import HorizontalPanel | |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
27 from pyjamas.ui.HTMLPanel import HTMLPanel |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
28 from pyjamas.ui.Grid import Grid |
0 | 29 from pyjamas.ui.Label import Label |
30 from pyjamas.ui import HasAlignment | |
31 from pyjamas.ui.MenuBar import MenuBar | |
32 from pyjamas.ui.MenuItem import MenuItem | |
6 | 33 from pyjamas.ui.AutoComplete import AutoCompleteTextBox |
34 from pyjamas.ui.DropWidget import DropWidget | |
0 | 35 from pyjamas import Window |
36 from pyjamas.JSONService import JSONProxy | |
37 from register import RegisterPanel, RegisterBox | |
1 | 38 from pyjamas import DOM |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
39 from contact import ContactPanel |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
40 from datetime import datetime |
0 | 41 |
42 | |
43 class LiberviaJsonProxy(JSONProxy): | |
44 def __init__(self, *args, **kwargs): | |
45 JSONProxy.__init__(self, *args, **kwargs) | |
46 self.handler=self | |
47 self.cb={} | |
48 | |
49 def call(self, method, cb, *args): | |
50 self.cb[method] = cb | |
51 self.callMethod(method,args) | |
52 | |
53 def onRemoteResponse(self, response, request_info): | |
54 if self.cb.has_key(request_info.method): | |
55 self.cb[request_info.method](response) | |
56 del self.cb[request_info.method] | |
57 | |
58 def onRemoteError(self, code, errobj, request_info): | |
59 if code != 0: | |
60 Window.alert("Internal server error") | |
61 else: | |
62 if isinstance(errobj['message'],dict): | |
63 Window.alert("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString'])) | |
64 else: | |
65 Window.alert("Error: %s" % errobj['message']) | |
66 | |
67 class RegisterCall(LiberviaJsonProxy): | |
68 def __init__(self): | |
69 LiberviaJsonProxy.__init__(self, "/register_api", | |
70 ["isRegistered","isConnected","connect"]) | |
71 self.handler=self | |
72 self.cb={} | |
73 | |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
74 class BridgeCall(LiberviaJsonProxy): |
0 | 75 def __init__(self): |
76 LiberviaJsonProxy.__init__(self, "/json_api", | |
77 ["getContacts"]) | |
78 | |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
79 class BridgeSignals(LiberviaJsonProxy): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
80 def __init__(self): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
81 LiberviaJsonProxy.__init__(self, "/json_signal_api", |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
82 ["getSignals"]) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
83 |
0 | 84 class MenuCmd: |
85 | |
86 def __init__(self, object, handler): | |
87 self._object = object | |
88 self._handler = handler | |
89 | |
90 def execute(self): | |
91 handler = getattr(self._object, self._handler) | |
92 handler() | |
93 | |
94 class Menu(SimplePanel): | |
95 | |
96 def __init__(self): | |
97 SimplePanel.__init__(self) | |
98 | |
99 menu_general = MenuBar(vertical=True) | |
100 menu_general.addItem("Properties", MenuCmd(self, "onProperties")) | |
101 | |
102 menu_games = MenuBar(vertical=True) | |
103 menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame")) | |
104 menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame")) | |
105 | |
106 menubar = MenuBar(vertical=False) | |
107 menubar.addItem(MenuItem("General", menu_general)) | |
108 menubar.addItem(MenuItem("Games", True, menu_games)) | |
109 self.add(menubar) | |
110 | |
111 def onProperties(self): | |
112 Window.alert("Properties selected") | |
113 | |
114 def onTarotGame(self): | |
115 Window.alert("Tarot selected") | |
116 | |
117 def onXiangqiGame(self): | |
118 Window.alert("Xiangqi selected") | |
119 | |
120 class MagicBox(AutoCompleteTextBox): | |
121 | |
122 def __init__(self): | |
123 AutoCompleteTextBox.__init__(self) | |
1 | 124 |
125 def addKey(self, key): | |
126 self.getCompletionItems().completions.append(key) | |
127 | |
128 def addContact(self, jid, attributes, groups): | |
129 """Add a contact to the panel | |
130 @param jid: jid | |
131 @attributes: cf SàT Bridge API's newContact | |
132 @param groups: list of groups""" | |
133 for group in groups: | |
134 if not self.groups.has_key(group): | |
135 self.groups[group] = set() | |
136 self._groupList.add(group) | |
137 self.host.magicBox.addKey("@%s: " % group) | |
138 self.groups[group].add(jid) | |
139 self._contactList.add(jid) | |
140 | |
141 def onMouseMove(self, sender, x, y): | |
142 pass | |
143 | |
144 def onMouseDown(self, sender, x, y): | |
145 pass | |
146 | |
147 def onMouseUp(self, sender, x, y): | |
148 pass | |
149 | |
150 def onMouseEnter(self, sender): | |
151 if isinstance(sender, GroupLabel): | |
152 for contact in self._contactList: | |
153 if contact.jid in self.groups[sender.group]: | |
154 contact.addStyleName("selected") | |
155 | |
156 def onMouseLeave(self, sender): | |
157 if isinstance(sender, GroupLabel): | |
158 for contact in self._contactList: | |
159 if contact.jid in self.groups[sender.group]: | |
160 contact.removeStyleName("selected") | |
0 | 161 |
6 | 162 class EmptyPanel(DropWidget, SimplePanel): |
163 """Empty dropable panel""" | |
164 | |
9 | 165 def __init__(self, host, data): |
6 | 166 SimplePanel.__init__(self) |
9 | 167 self.host = host |
168 self.data = data | |
6 | 169 _panel = HTMLPanel(" ") |
170 self.add(_panel) | |
171 self.setHeight('100%') | |
172 DropWidget.__init__(self) | |
173 | |
174 def onDragEnter(self, event): | |
175 self.addStyleName('dragover') | |
176 DOM.eventPreventDefault(event) | |
177 | |
178 def onDragLeave(self, event): | |
179 self.removeStyleName('dragover') | |
180 | |
181 def onDragOver(self, event): | |
182 DOM.eventPreventDefault(event) | |
183 | |
184 def onDrop(self, event): | |
9 | 185 print "Empty Panel: onDrop" |
6 | 186 dt = event.dataTransfer |
187 #'text', 'text/plain', and 'Text' are equivalent. | |
188 try: | |
189 item = dt.getData("text/plain") | |
190 print "message: %s" % item | |
191 except: | |
192 print "no message found" | |
9 | 193 item=' ' |
6 | 194 DOM.eventPreventDefault(event) |
9 | 195 self.host.mpanels.insert(0,MicroblogPanel(item)) |
196 self.host.middle_panel.changePanel(self.data,self.host.mpanels[0]) | |
6 | 197 |
198 | |
199 | |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
200 class MicroblogEntry(SimplePanel): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
201 |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
202 def __init__(self, body, author, timestamp): |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
203 SimplePanel.__init__(self) |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
204 |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
205 _datetime = datetime.fromtimestamp(timestamp) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
206 |
6 | 207 panel = HTMLPanel("<div class='mb_entry_header'><span class='mb_entry_author'>%(author)s</span> on <span class='mb_entry_timestamp'>%(timestamp)s</span></div><div class='mb_entry_body'>%(body)s</div>" % |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
208 {"author": author, |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
209 "timestamp": _datetime, |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
210 "body": body} |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
211 ) |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
212 panel.setStyleName('microblogEntry') |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
213 self.add(panel) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
214 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
215 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
216 class MicroblogPanel(VerticalPanel): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
217 |
9 | 218 def __init__(self,title=' '): |
219 title=title.replace('<','<').replace('>','>') | |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
220 VerticalPanel.__init__(self) |
9 | 221 _class = ['mb_panel_header'] |
222 if title == ' ': | |
223 _class.append('empty_header') | |
224 self.add(HTMLPanel("<div class='%s'>%s</div>" % (','.join(_class),title))) | |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
225 self.setStyleName('microblogPanel') |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
226 |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
227 def addEntry(self, text, author=None, timestamp=None): |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
228 """Add an entry to the panel |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
229 @param text: main text of the entry |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
230 @param author: who wrote the entry |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
231 @param date: when the entry was written""" |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
232 _entry = MicroblogEntry(text, author, timestamp) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
233 self.add(_entry) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
234 |
0 | 235 class MiddlePannel(HorizontalPanel): |
236 | |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
237 def __init__(self, host): |
1 | 238 self.host=host |
0 | 239 HorizontalPanel.__init__(self) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
240 self._left = self.host.contactPanel |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
241 self._right = Grid(1,3) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
242 self._right.setWidth('100%') |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
243 self._right.setHeight('100%') |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
244 self.add(self._left) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
245 self.setCellWidth(self._left, "15%") |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
246 self.add(self._right) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
247 self.setCellWidth(self._right, "85%") |
6 | 248 self.setHeight('100%') |
0 | 249 |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
250 def changePanel(self, idx, panel): |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
251 print "panel:",panel |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
252 print "idx:",idx |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
253 self._right.setWidget(0,idx,panel) |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
254 |
0 | 255 class MainPanel(VerticalPanel): |
256 | |
1 | 257 def __init__(self, host): |
258 self.host=host | |
0 | 259 VerticalPanel.__init__(self) |
260 | |
261 self.setHorizontalAlignment(HasAlignment.ALIGN_LEFT) | |
262 self.setVerticalAlignment(HasAlignment.ALIGN_TOP) | |
263 | |
264 menu = Menu() | |
1 | 265 magic_box = host.magicBox |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
266 self.middle_panel = MiddlePannel(self.host) |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
267 self.middle_panel.setWidth('100%') |
0 | 268 |
269 self.add(menu) | |
270 self.add(magic_box) | |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
271 self.add(self.middle_panel) |
0 | 272 |
273 self.setCellHeight(menu, "5%") | |
274 self.setCellHeight(magic_box, "5%") | |
275 self.setCellVerticalAlignment(magic_box, HasAlignment.ALIGN_CENTER) | |
276 self.setCellHorizontalAlignment(magic_box, HasAlignment.ALIGN_CENTER) | |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
277 self.setCellHeight(self.middle_panel, "90%") |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
278 self.setCellWidth(self.middle_panel, "100%") |
0 | 279 |
280 self.setWidth("100%") | |
281 self.setHeight("100%") | |
282 | |
283 class SatWebFrontend: | |
284 def onModuleLoad(self): | |
1 | 285 self.magicBox = MagicBox() |
286 self.contactPanel = ContactPanel(self) | |
287 self.panel = MainPanel(self) | |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
288 self.middle_panel = self.panel.middle_panel |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
289 self.mpanels = [MicroblogPanel()] |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
290 self.middle_panel.changePanel(1,self.mpanels[0]) |
9 | 291 self.middle_panel.changePanel(0,EmptyPanel(self, 0)) |
292 self.middle_panel.changePanel(2,EmptyPanel(self, 2)) | |
0 | 293 self._dialog = None |
294 RootPanel().add(self.panel) | |
295 self._register = RegisterCall() | |
1 | 296 self._register.call('isRegistered',self._isRegisteredCB) |
0 | 297 |
1 | 298 def _isRegisteredCB(self, registered): |
0 | 299 if not registered: |
300 self._dialog = RegisterBox(self.logged,centered=True) | |
301 self._dialog.show() | |
302 else: | |
1 | 303 self._register.call('isConnected', self._isConnectedCB) |
0 | 304 |
1 | 305 def _isConnectedCB(self, connected): |
0 | 306 if not connected: |
307 self._register.call('connect',self.logged) | |
308 else: | |
309 self.logged() | |
310 | |
311 def logged(self): | |
312 if self._dialog: | |
313 self._dialog.hide() | |
314 del self._dialog # don't work if self._dialog is None | |
1 | 315 |
316 #it's time to fill the page | |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
317 bridge = BridgeCall() |
1 | 318 bridge.call('getContacts', self._getContactsCB) |
319 | |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
320 bridge_signals = BridgeSignals() |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
321 bridge_signals.call('getSignals', self._getSignalsCB) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
322 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
323 |
1 | 324 def _getContactsCB(self, contacts_data): |
325 for contact in contacts_data: | |
326 jid, attributes, groups = contact | |
327 self.contactPanel.addContact(jid, attributes, groups) | |
0 | 328 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
329 def _getSignalsCB(self, signal_data): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
330 bridge_signals = BridgeSignals() |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
331 bridge_signals.call('getSignals', self._getSignalsCB) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
332 print('Got signal ==> name: %s, params: %s' % (signal_data[0],signal_data[1])) |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
333 name,args = signal_data |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
334 if name == 'personalEvent': |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
335 self._personalEventCb(*args) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
336 |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
337 ## Signals callbacks ## |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
338 |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
339 def _personalEventCb(self, sender, event_type, data, profile): |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
340 if event_type == "MICROBLOG": |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
341 if not data.has_key('content'): |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
342 print ("WARNING: No content found in microblog data") |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
343 return |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
344 for panel in self.mpanels: |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
345 if isinstance(panel,MicroblogPanel): |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
346 content = data['content'] |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
347 author = data.get('author') |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
348 print "timestamp: %s" % data.get('timestamp') |
9 | 349 timestamp = float(data.get('timestamp',0)) #XXX: int doesn't work here |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
350 panel.addEntry(content, author, timestamp) |
0 | 351 |
352 if __name__ == '__main__': | |
1 | 353 pyjd.setup("http://localhost:8080/libervia.html") |
0 | 354 app = SatWebFrontend() |
355 app.onModuleLoad() | |
356 pyjd.run() | |
357 |