~gmb/gwibber/use-dates-for-indexes

« back to all changes in this revision

Viewing changes to gwibber/gwui.py

Support showing twitter user's timeline in a new tab. Clicking on @username or
avatars will open a new tab with that user's timeline. The external profile can
then be opened in an external browser by using the link at the top of this
new tab.

TODO: identi.ca/laconi.ca not yet done but support will come in a branch _very_
soon.

Merge from lp:~oldman/gwibber/twitter-user-messages-tab

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
    
63
63
    strings = simplejson.dumps(ui_dict)
64
64
    msgs = simplejson.dumps([dict(m.__dict__, message_index=n)
65
 
                             
66
65
      for n, m in enumerate(message_store or self.message_store)],
67
66
        indent=4, default=str)
68
67
    self.execute_script("addMessages(%(msg)s, %(rep)s)" % {"msg": msgs, "rep": strings})
86
85
  def link_handler(self, uri):
87
86
    pass
88
87
 
 
88
class UserView(MessageView):
 
89
  def load_messages(self, message_store = None): # override
 
90
    if (self.message_store and len(self.message_store) > 0):
 
91
      # use info from first message to create user header
 
92
      msg = simplejson.dumps(dict(self.message_store[0].__dict__, message_index=0), sort_keys=True, indent=4, default=str)
 
93
      self.execute_script("addUserHeader(%s)" % msg)
 
94
      # display other messages as normal
 
95
      MessageView.load_messages(self, message_store)
 
96
 
89
97
def image_cache(url, cache_dir = IMG_CACHE_DIR):
90
98
  if not os.path.exists(cache_dir): os.makedirs(cache_dir)
91
99
  encoded_url = hashlib.sha1(url).hexdigest()