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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
3
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
4 """
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
5 Libervia: a Salut à Toi frontend
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
6 Copyright (C) 2011 Jérôme Poisson (goffi@goffi.org)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
7
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
8 This program is free software: you can redistribute it and/or modify
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
9 it under the terms of the GNU Affero General Public License as published by
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
10 the Free Software Foundation, either version 3 of the License, or
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
11 (at your option) any later version.
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
12
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
13 This program is distributed in the hope that it will be useful,
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
16 GNU Affero General Public License for more details.
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
17
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
18 You should have received a copy of the GNU Affero General Public License
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
20 """
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
21
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
22 import pyjd # this is dummy in pyjs
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from pyjamas.ui.SimplePanel import SimplePanel
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from pyjamas.ui.RootPanel import RootPanel
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from pyjamas.ui.VerticalPanel import VerticalPanel
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
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
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from pyjamas.ui.Label import Label
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
30 from pyjamas.ui import HasAlignment
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
31 from pyjamas.ui.MenuBar import MenuBar
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
32 from pyjamas.ui.MenuItem import MenuItem
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
33 from pyjamas.ui.AutoComplete import AutoCompleteTextBox
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
34 from pyjamas.ui.DropWidget import DropWidget
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
35 from pyjamas import Window
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
36 from pyjamas.JSONService import JSONProxy
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
37 from register import RegisterPanel, RegisterBox
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
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
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
41
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
42
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
43 class LiberviaJsonProxy(JSONProxy):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
44 def __init__(self, *args, **kwargs):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
45 JSONProxy.__init__(self, *args, **kwargs)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
46 self.handler=self
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
47 self.cb={}
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
48
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
49 def call(self, method, cb, *args):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
50 self.cb[method] = cb
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
51 self.callMethod(method,args)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
52
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
53 def onRemoteResponse(self, response, request_info):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
54 if self.cb.has_key(request_info.method):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
55 self.cb[request_info.method](response)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
56 del self.cb[request_info.method]
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
57
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
58 def onRemoteError(self, code, errobj, request_info):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
59 if code != 0:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
60 Window.alert("Internal server error")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
61 else:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
62 if isinstance(errobj['message'],dict):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
63 Window.alert("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString']))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
64 else:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
65 Window.alert("Error: %s" % errobj['message'])
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
66
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
67 class RegisterCall(LiberviaJsonProxy):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
68 def __init__(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
69 LiberviaJsonProxy.__init__(self, "/register_api",
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
70 ["isRegistered","isConnected","connect"])
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
71 self.handler=self
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
72 self.cb={}
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
73
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
74 class BridgeCall(LiberviaJsonProxy):
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
75 def __init__(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
76 LiberviaJsonProxy.__init__(self, "/json_api",
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
77 ["getContacts"])
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
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
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
84 class MenuCmd:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
85
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
86 def __init__(self, object, handler):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
87 self._object = object
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
88 self._handler = handler
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
89
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
90 def execute(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
91 handler = getattr(self._object, self._handler)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
92 handler()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
93
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
94 class Menu(SimplePanel):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
95
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
96 def __init__(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
97 SimplePanel.__init__(self)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
98
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
99 menu_general = MenuBar(vertical=True)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
100 menu_general.addItem("Properties", MenuCmd(self, "onProperties"))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
101
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
102 menu_games = MenuBar(vertical=True)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
103 menu_games.addItem("Tarot", MenuCmd(self, "onTarotGame"))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
104 menu_games.addItem("Xiangqi", MenuCmd(self, "onXiangqiGame"))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
105
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
106 menubar = MenuBar(vertical=False)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
107 menubar.addItem(MenuItem("General", menu_general))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
108 menubar.addItem(MenuItem("Games", True, menu_games))
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
109 self.add(menubar)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
110
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
111 def onProperties(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
112 Window.alert("Properties selected")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
113
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
114 def onTarotGame(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
115 Window.alert("Tarot selected")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
116
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
117 def onXiangqiGame(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
118 Window.alert("Xiangqi selected")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
119
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
120 class MagicBox(AutoCompleteTextBox):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
121
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
122 def __init__(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
123 AutoCompleteTextBox.__init__(self)
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
124
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
125 def addKey(self, key):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
126 self.getCompletionItems().completions.append(key)
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
127
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
128 def addContact(self, jid, attributes, groups):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
129 """Add a contact to the panel
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
130 @param jid: jid
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
131 @attributes: cf SàT Bridge API's newContact
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
132 @param groups: list of groups"""
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
133 for group in groups:
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
134 if not self.groups.has_key(group):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
135 self.groups[group] = set()
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
136 self._groupList.add(group)
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
137 self.host.magicBox.addKey("@%s: " % group)
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
138 self.groups[group].add(jid)
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
139 self._contactList.add(jid)
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
140
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
141 def onMouseMove(self, sender, x, y):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
142 pass
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
143
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
144 def onMouseDown(self, sender, x, y):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
145 pass
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
146
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
147 def onMouseUp(self, sender, x, y):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
148 pass
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
149
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
150 def onMouseEnter(self, sender):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
151 if isinstance(sender, GroupLabel):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
152 for contact in self._contactList:
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
153 if contact.jid in self.groups[sender.group]:
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
154 contact.addStyleName("selected")
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
155
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
156 def onMouseLeave(self, sender):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
157 if isinstance(sender, GroupLabel):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
158 for contact in self._contactList:
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
159 if contact.jid in self.groups[sender.group]:
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
160 contact.removeStyleName("selected")
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
161
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
162 class EmptyPanel(DropWidget, SimplePanel):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
163 """Empty dropable panel"""
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
164
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
165 def __init__(self, host, data):
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
166 SimplePanel.__init__(self)
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
167 self.host = host
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
168 self.data = data
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
169 _panel = HTMLPanel("&nbsp;")
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
170 self.add(_panel)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
171 self.setHeight('100%')
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
172 DropWidget.__init__(self)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
173
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
174 def onDragEnter(self, event):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
175 self.addStyleName('dragover')
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
176 DOM.eventPreventDefault(event)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
177
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
178 def onDragLeave(self, event):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
179 self.removeStyleName('dragover')
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
180
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
181 def onDragOver(self, event):
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
182 DOM.eventPreventDefault(event)
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
183
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
184 def onDrop(self, event):
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
185 print "Empty Panel: onDrop"
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
186 dt = event.dataTransfer
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
187 #'text', 'text/plain', and 'Text' are equivalent.
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
188 try:
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
189 item = dt.getData("text/plain")
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
190 print "message: %s" % item
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
191 except:
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
192 print "no message found"
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
193 item='&nbsp;'
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
194 DOM.eventPreventDefault(event)
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
195 self.host.mpanels.insert(0,MicroblogPanel(item))
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
196 self.host.middle_panel.changePanel(self.data,self.host.mpanels[0])
6
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
197
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
198
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
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
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
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
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
218 def __init__(self,title='&nbsp;'):
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
219 title=title.replace('<','&lt;').replace('>','&gt;')
2
669c531a857e signals handling and first draft of microblogging
Goffi <goffi@goffi.org>
parents: 1
diff changeset
220 VerticalPanel.__init__(self)
9
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
221 _class = ['mb_panel_header']
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
222 if title == '&nbsp;':
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
223 _class.append('empty_header')
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
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
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
235 class MiddlePannel(HorizontalPanel):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
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
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
238 self.host=host
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
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
a663b9955cf3 drap and drop first draft
Goffi <goffi@goffi.org>
parents: 4
diff changeset
248 self.setHeight('100%')
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
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
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
255 class MainPanel(VerticalPanel):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
256
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
257 def __init__(self, host):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
258 self.host=host
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
259 VerticalPanel.__init__(self)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
260
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
261 self.setHorizontalAlignment(HasAlignment.ALIGN_LEFT)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
262 self.setVerticalAlignment(HasAlignment.ALIGN_TOP)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
263
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
264 menu = Menu()
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
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
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
268
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
269 self.add(menu)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
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
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
272
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
273 self.setCellHeight(menu, "5%")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
274 self.setCellHeight(magic_box, "5%")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
275 self.setCellVerticalAlignment(magic_box, HasAlignment.ALIGN_CENTER)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
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
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
279
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
280 self.setWidth("100%")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
281 self.setHeight("100%")
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
282
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
283 class SatWebFrontend:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
284 def onModuleLoad(self):
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
285 self.magicBox = MagicBox()
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
286 self.contactPanel = ContactPanel(self)
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
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
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
291 self.middle_panel.changePanel(0,EmptyPanel(self, 0))
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
292 self.middle_panel.changePanel(2,EmptyPanel(self, 2))
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
293 self._dialog = None
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
294 RootPanel().add(self.panel)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
295 self._register = RegisterCall()
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
296 self._register.call('isRegistered',self._isRegisteredCB)
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
297
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
298 def _isRegisteredCB(self, registered):
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
299 if not registered:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
300 self._dialog = RegisterBox(self.logged,centered=True)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
301 self._dialog.show()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
302 else:
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
303 self._register.call('isConnected', self._isConnectedCB)
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
304
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
305 def _isConnectedCB(self, connected):
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
306 if not connected:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
307 self._register.call('connect',self.logged)
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
308 else:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
309 self.logged()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
310
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
311 def logged(self):
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
312 if self._dialog:
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
313 self._dialog.hide()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
314 del self._dialog # don't work if self._dialog is None
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
315
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
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
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
318 bridge.call('getContacts', self._getContactsCB)
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
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
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
324 def _getContactsCB(self, contacts_data):
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
325 for contact in contacts_data:
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
326 jid, attributes, groups = contact
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
327 self.contactPanel.addContact(jid, attributes, groups)
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
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
c80b75bf2e91 browser: misc appearance change
Goffi <goffi@goffi.org>
parents: 6
diff changeset
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
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
351
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
352 if __name__ == '__main__':
1
0a7c685faa53 ContactPanel: first draft
Goffi <goffi@goffi.org>
parents: 0
diff changeset
353 pyjd.setup("http://localhost:8080/libervia.html")
0
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
354 app = SatWebFrontend()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
355 app.onModuleLoad()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
356 pyjd.run()
140cec48224a Initial commit
Goffi <goffi@goffi.org>
parents:
diff changeset
357