comparison libervia.py @ 239:b911f2b43fd4

browser_side: added input history in the unibox: This functionality uses a file from the sat project: use the -I parameter of pyjsbuild to add sat library to your PYJSPATH. To ease also possible to use your sat source directory instead of the library, you just need to trick pyjsbuild with a symbolic link: SAT=~/workspace/sat if [[ ! -e $SAT/sat ]]; then ln -sf $SAT/src $SAT/sat; fi This will allow you to import like that in libervia.py: from sat.tools.frontend.misc import InputHistory And then you can build with: $PYJS/bin/pyjsbuild libervia --no-compile-inplace -m -I $SAT
author souliane <souliane@mailoo.org>
date Mon, 14 Oct 2013 20:54:13 +0200
parents b304cdf13a3b
children a25aa882e09a
comparison
equal deleted inserted replaced
238:dec76d4536ad 239:b911f2b43fd4
31 from browser_side.base_widget import WidgetsPanel 31 from browser_side.base_widget import WidgetsPanel
32 from browser_side.panels import MicroblogItem 32 from browser_side.panels import MicroblogItem
33 from browser_side import panels, dialog 33 from browser_side import panels, dialog
34 from browser_side.jid import JID 34 from browser_side.jid import JID
35 from browser_side.tools import html_sanitize 35 from browser_side.tools import html_sanitize
36 from sat.tools.frontend.misc import InputHistory
36 37
37 38
38 MAX_MBLOG_CACHE = 500 # Max microblog entries kept in memories 39 MAX_MBLOG_CACHE = 500 # Max microblog entries kept in memories
39 40
40 # Set to true to not create a new LiberviaWidget when a similar one 41 # Set to true to not create a new LiberviaWidget when a similar one
94 print ("Internal server error") 95 print ("Internal server error")
95 """for o in code, error, request_info: 96 """for o in code, error, request_info:
96 dump(o)""" 97 dump(o)"""
97 else: 98 else:
98 if isinstance(errobj['message'], dict): 99 if isinstance(errobj['message'], dict):
99 print("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString'])) 100 print("Error %s: %s" % (errobj['message']['faultCode'], errobj['message']['faultString']))
100 else: 101 else:
101 print("Error: %s" % errobj['message']) 102 print("Error: %s" % errobj['message'])
103
102 104
103 class RegisterCall(LiberviaJsonProxy): 105 class RegisterCall(LiberviaJsonProxy):
104 def __init__(self): 106 def __init__(self):
105 LiberviaJsonProxy.__init__(self, "/register_api", 107 LiberviaJsonProxy.__init__(self, "/register_api",
106 ["isRegistered", "isConnected", "connect"]) 108 ["isRegistered", "isConnected", "connect"])
109
107 110
108 class BridgeCall(LiberviaJsonProxy): 111 class BridgeCall(LiberviaJsonProxy):
109 def __init__(self): 112 def __init__(self):
110 LiberviaJsonProxy.__init__(self, "/json_api", 113 LiberviaJsonProxy.__init__(self, "/json_api",
111 ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment", 114 ["getContacts", "addContact", "sendMessage", "sendMblog", "sendMblogComment",
144 def _timerCb(): 147 def _timerCb():
145 self.host.bridge_signals.call('getSignals', self.host._getSignalsCB) 148 self.host.bridge_signals.call('getSignals', self.host._getSignalsCB)
146 Timer(notify=_timerCb).schedule(self.retry_delay) 149 Timer(notify=_timerCb).schedule(self.retry_delay)
147 self.retry_delay *= 2 150 self.retry_delay *= 2
148 151
149 class SatWebFrontend: 152
153 class SatWebFrontend(InputHistory):
150 def onModuleLoad(self): 154 def onModuleLoad(self):
151 print "============ onModuleLoad ==============" 155 print "============ onModuleLoad =============="
152 panels.ChatPanel.registerClass() 156 panels.ChatPanel.registerClass()
153 panels.MicroblogPanel.registerClass() 157 panels.MicroblogPanel.registerClass()
154 self.whoami = None 158 self.whoami = None
646 lib_wid.state_machine.started = True 650 lib_wid.state_machine.started = True
647 elif (lib_wid.type == 'group'): 651 elif (lib_wid.type == 'group'):
648 # TODO: chat state notification for groupchat 652 # TODO: chat state notification for groupchat
649 pass 653 pass
650 654
655
651 if __name__ == '__main__': 656 if __name__ == '__main__':
652 pyjd.setup("http://localhost:8080/libervia.html") 657 pyjd.setup("http://localhost:8080/libervia.html")
653 app = SatWebFrontend() 658 app = SatWebFrontend()
654 app.onModuleLoad() 659 app.onModuleLoad()
655 pyjd.run() 660 pyjd.run()