Mercurial > libervia-web
annotate libervia.py @ 6:a663b9955cf3
drap and drop first draft
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 14 Feb 2011 01:46:07 +0100 |
parents | 7325e787c22b |
children | c80b75bf2e91 |
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 | |
165 def __init__(self): | |
166 SimplePanel.__init__(self) | |
167 _panel = HTMLPanel(" ") | |
168 #_panel.setHeight('100%') | |
169 #_panel.setWidth('100%') | |
170 self.add(_panel) | |
171 self.setHeight('100%') | |
172 DropWidget.__init__(self) | |
173 | |
174 def onDragEnter(self, event): | |
175 print "Empty Panel: onDragEnter" | |
176 self.addStyleName('dragover') | |
177 DOM.eventPreventDefault(event) | |
178 | |
179 def onDragLeave(self, event): | |
180 print "Empty Panel: onDragLeave" | |
181 self.removeStyleName('dragover') | |
182 | |
183 def onDragOver(self, event): | |
184 print "Empty Panel: onDragOver" | |
185 DOM.eventPreventDefault(event) | |
186 | |
187 def onDrop(self, event): | |
188 print "Empty Panel: onDragOver" | |
189 dt = event.dataTransfer | |
190 #'text', 'text/plain', and 'Text' are equivalent. | |
191 try: | |
192 item = dt.getData("text/plain") | |
193 print "message: %s" % item | |
194 except: | |
195 print "no message found" | |
196 DOM.eventPreventDefault(event) | |
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 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
218 def __init__(self): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
219 VerticalPanel.__init__(self) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
220 self.setStyleName('microblogPanel') |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
221 |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
222 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
|
223 """Add an entry to the panel |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
224 @param text: main text of the entry |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
225 @param author: who wrote the entry |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
226 @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
|
227 _entry = MicroblogEntry(text, author, timestamp) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
228 self.add(_entry) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
229 |
0 | 230 class MiddlePannel(HorizontalPanel): |
231 | |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
232 def __init__(self, host): |
1 | 233 self.host=host |
0 | 234 HorizontalPanel.__init__(self) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
235 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
|
236 self._right = Grid(1,3) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
237 self._right.setWidth('100%') |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
238 self._right.setHeight('100%') |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
239 self.add(self._left) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
240 self.setCellWidth(self._left, "15%") |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
241 self.add(self._right) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
242 self.setCellWidth(self._right, "85%") |
6 | 243 self.setHeight('100%') |
0 | 244 |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
245 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
|
246 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
|
247 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
|
248 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
|
249 |
0 | 250 class MainPanel(VerticalPanel): |
251 | |
1 | 252 def __init__(self, host): |
253 self.host=host | |
0 | 254 VerticalPanel.__init__(self) |
255 | |
256 self.setHorizontalAlignment(HasAlignment.ALIGN_LEFT) | |
257 self.setVerticalAlignment(HasAlignment.ALIGN_TOP) | |
258 | |
259 menu = Menu() | |
1 | 260 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
|
261 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
|
262 self.middle_panel.setWidth('100%') |
0 | 263 |
264 self.add(menu) | |
265 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
|
266 self.add(self.middle_panel) |
0 | 267 |
268 self.setCellHeight(menu, "5%") | |
269 self.setCellHeight(magic_box, "5%") | |
270 self.setCellVerticalAlignment(magic_box, HasAlignment.ALIGN_CENTER) | |
271 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
|
272 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
|
273 self.setCellWidth(self.middle_panel, "100%") |
0 | 274 |
275 self.setWidth("100%") | |
276 self.setHeight("100%") | |
277 | |
278 class SatWebFrontend: | |
279 def onModuleLoad(self): | |
1 | 280 self.magicBox = MagicBox() |
281 self.contactPanel = ContactPanel(self) | |
282 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
|
283 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
|
284 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
|
285 self.middle_panel.changePanel(1,self.mpanels[0]) |
6 | 286 self.middle_panel.changePanel(0,EmptyPanel()) |
287 self.middle_panel.changePanel(2,EmptyPanel()) | |
0 | 288 self._dialog = None |
289 RootPanel().add(self.panel) | |
290 self._register = RegisterCall() | |
1 | 291 self._register.call('isRegistered',self._isRegisteredCB) |
0 | 292 |
1 | 293 def _isRegisteredCB(self, registered): |
0 | 294 if not registered: |
295 self._dialog = RegisterBox(self.logged,centered=True) | |
296 self._dialog.show() | |
297 else: | |
1 | 298 self._register.call('isConnected', self._isConnectedCB) |
0 | 299 |
1 | 300 def _isConnectedCB(self, connected): |
0 | 301 if not connected: |
302 self._register.call('connect',self.logged) | |
303 else: | |
304 self.logged() | |
305 | |
306 def logged(self): | |
307 if self._dialog: | |
308 self._dialog.hide() | |
309 del self._dialog # don't work if self._dialog is None | |
1 | 310 |
311 #it's time to fill the page | |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
312 bridge = BridgeCall() |
1 | 313 bridge.call('getContacts', self._getContactsCB) |
314 | |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
315 bridge_signals = BridgeSignals() |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
316 bridge_signals.call('getSignals', self._getSignalsCB) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
317 |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
318 |
1 | 319 def _getContactsCB(self, contacts_data): |
320 for contact in contacts_data: | |
321 jid, attributes, groups = contact | |
322 self.contactPanel.addContact(jid, attributes, groups) | |
0 | 323 |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
324 def _getSignalsCB(self, signal_data): |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
325 bridge_signals = BridgeSignals() |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
326 bridge_signals.call('getSignals', self._getSignalsCB) |
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
327 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
|
328 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
|
329 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
|
330 self._personalEventCb(*args) |
2
669c531a857e
signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents:
1
diff
changeset
|
331 |
4
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
332 ## Signals callbacks ## |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
333 |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
334 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
|
335 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
|
336 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
|
337 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
|
338 return |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
339 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
|
340 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
|
341 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
|
342 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
|
343 print "timestamp: %s" % data.get('timestamp') |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
344 timestamp = float(data.get('timestamp'),0) #XXX: int doesn't work here |
7325e787c22b
personalEvent management signal first draft, microblogs are now put in a central grid
Goffi <goffi@goffi.org>
parents:
2
diff
changeset
|
345 panel.addEntry(content, author, timestamp) |
0 | 346 |
347 if __name__ == '__main__': | |
1 | 348 pyjd.setup("http://localhost:8080/libervia.html") |
0 | 349 app = SatWebFrontend() |
350 app.onModuleLoad() | |
351 pyjd.run() | |
352 |