Commits

Horacio Durán committed e46ec83

Started Gui wireframes and HTTP server
Fixed tnt bugs
Tried to migrate urwid

  • Participants
  • Parent commits 4fc4e92
  • Branches graph_structure

Comments (0)

Files changed (3)

         """
         TODO: Build the chidren tree,not clearly necessary now
         """
-        this_tweet = self._friendsTL.message(mid)
+        this_tweet = self.message(mid)
         top_parent_mid = this_tweet.getListPath()[0]
         """
         Thanks Facundo Batista for this snippet
         """
         TODO: Build the chidren tree,not clearly necessary now
         """
-        this_tweet = self._friendsTL.message(mid)
+        this_tweet = self.message(mid)
         branch = [this_tweet]
         for each_mid in this_tweet.getListPath():
-            branch.append(self._friendsTL.message(each_mid))
+            branch.append(self.message(each_mid))
         return branch            
         
 
         self.executeRefresh = True
         
     def getThreadFor(self, mid, tree=False):
-        return tree and self._friendsTL.retrieveTree() or self._friendsTL.retrieveBranch()
+        return tree and self._friendsTL.retrieveTree(mid) or self._friendsTL.retrieveBranch(mid)
 
 class Tnt(object):
     def __init__(self, guiHandle):
+import sys
 from tnt import Tnt
+from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
+from threading import Thread
+
+class TntHTTPRequestHandler(BaseHTTPRequestHandler):
+    def do_GET(self, *args, **kwargs):
+        global gui_serv
+        self.send_response(200)
+        self.send_header('Content-type',	'text/html')
+        self.end_headers()
+        algo = "<html><head><title>petete</title></head><body><a href='http://www.google.com'>algo</a></body></html>"
+        self.wfile.write(algo)
+        
+    def do_POST(self, *args, **kwargs):
+        pass
+    
 
 class TntGuiServ(object):
-    def __init__(self):
+    def __init__(self, port=14267, bind_addr='127.0.0.1'):
+        self.port = port
+        self.bind_addr = bind_addr
+        self._tnt = Tnt(self)
         super(TntGuiServ, self).__init__()
-        self._tnt = Tnt(self)
-        self.main()
-    
+        self._http_server = HTTPServer((self.bind_addr, self.port), TntHTTPRequestHandler)
+        self._http_server_thread = Thread(target=self._http_server.serve_forever)
+        self._http_server_thread.start()
+            
     def updated(self, updated_threads, tntacct):
-        print updated_threads
-        print tntacct._friendsTL.messages
-        pass
-        
-    def updatedDms(self, tntacct):
-        print updated_threads
-        print tntacct._friendsTL.messages
-        pass
-        
-    def updatedMentions(self, tntacct):
+        #NO this goes into the GET and here we should call the js for update.
+        #We do not need to hold a local representation of the three, html does
+        print "updated\n"
         print updated_threads
         print tntacct._friendsTL.messages
         pass
 
+    def updatedDms(self, tntacct):
+        print "updated DMS\n"
+        print updated_threads
+        print tntacct._friendsTL.messages
+        pass
+
+    def updatedMentions(self, tntacct):
+        print updated_threads
+        print "updated Mentions\n"
+        print tntacct._friendsTL.messages
+        pass
+        
     def main(self):
-        action = raw_input('')
+        action = raw_input('Input aca: ')
+        self.exit()
+    
+    def exit(self):
+        self._http_server.shutdown()
+        self._http_server_thread.join()
+        sys.exit(0)
 
-TntGuiServ()
+if __name__ == "__main__":
+    gui_serv = TntGuiServ(6969,u"127.0.0.1")
+    try:
+        gui_serv.main()
+    except KeyboardInterrupt:
+        gui_serv.exit()
+
+

File tnt_urwid.py

 #    Copyright (C) 2004-2007  Ian Ward
 #Both Licenced under GPL
 
-import sys, os
-import datetime
-import pickle
-from tnt import Tnt
-from tnt import TNT_PATH
-from threading import Thread
 try:
     import urwid
     import urwid.curses_display
     """
     sys.exit(1)
 
+
+import sys, os
+import datetime
+import pickle
+from tnt import Tnt
+from tnt import TNT_PATH
+from threading import Thread
+    
+DIALOG_DISPLAY_PALETTE = [
+    ('body','black','light gray', 'standout'),
+    ('border','black','dark blue'),
+    ('shadow','white','black'),
+    ('selectable','black', 'dark cyan'),
+    ('focus','white','dark blue','bold'),
+    ('focustext','light gray','dark blue'),
+    ]
+    
+TWITTER_DISPLAY_PALETTE = [
+    ('body','light gray','black', 'standout'),
+    ('foot','light gray', 'black', None),
+    ('key','light cyan', 'black', 'underline'),
+    ('title', 'white', 'black', None),
+    ('nickname','light green','black', 'standout'),
+    ('hour','light gray', 'black', None),
+    ('twitnumber','light cyan', 'black', ),
+    ('thread_indicator','dark red', 'black', 'standout'),
+    ('text', 'white', 'black', None),
+    ('text_mentioned','yellow','black', 'standout'),
+    ('hilight', 'black', 'light gray', None),
+    ('text_mine','light green','black', 'standout'),
+    ]
+
+
+
 class DialogExit(Exception):
     pass
 
 #------------------------------------------------------------------
 class DialogDisplay(object):
-    palette = [
-        ('body','black','light gray', 'standout'),
-        ('border','black','dark blue'),
-        ('shadow','white','black'),
-        ('selectable','black', 'dark cyan'),
-        ('focus','white','dark blue','bold'),
-        ('focustext','light gray','dark blue'),
-        ]
+    palette = DIALOG_DISPLAY_PALETTE
         
     def __init__(self, text, height, width, body=None):
         width = int(width)
         self.focus = focus
         self._modified()
 
+    def updatedDms(self):
+        pass
+        
+    def updatedMentions(self):
+        pass
+
     def updated(self, update_len=None, size=(0,)):
         screen_height = size[0]-2 #minus the message composition line and the info line
         twitt_list_length = self.tnt.getLength() 
         return self._get_at_pos(focus)   
 
 class TwitterDisplay(object):
-    palette = [
-        ('body','light gray','black', 'standout'),
-        ('foot','light gray', 'black', None),
-        ('key','light cyan', 'black', 'underline'),
-        ('title', 'white', 'black', None),
-        ('nickname','light green','black', 'standout'),
-        ('hour','light gray', 'black', None),
-        ('twitnumber','light cyan', 'black', ),
-        ('thread_indicator','dark red', 'black', 'standout'),
-        ('text', 'white', 'black', None),
-        ('text_mentioned','yellow','black', 'standout'),
-        ('hilight', 'black', 'light gray', None),
-        ('text_mine','light green','black', 'standout'),
-        ]
-
+    palette = TWITTER_DISPLAY_PALETTE
         
     footer_text = [
         ('title', "TNT Urwid Frontend"), "    ",