~ubuntu-branches/ubuntu/quantal/gwibber/quantal-proposed

« back to all changes in this revision

Viewing changes to gwibber/microblog/plugins/twitter/__init__.py

  • Committer: Package Import Robot
  • Author(s): Ken VanDine
  • Date: 2012-04-03 17:03:45 UTC
  • mfrom: (1.1.75)
  • Revision ID: package-import@ubuntu.com-20120403170345-0pdne56s246lr91x
Tags: 3.4.0-0ubuntu1
* New upstream release
  - Check shorten-urls setting in the dispatcher before attempting to
    shorten, patch thanks to Martin T. (LP: #896639)
  - Removing unnecessary 'Image' link from entries with images obtained
    through imgpreview() (Mark Tully) (LP: #966285)
  - Replace all instances of a hashtag's occurance in a tweet at once
    rather than one at a time (Mark Tully) (LP: #966467)
  - Replace all instances of a nick's occurance in a tweet at once rather
    than one at a time (Mark Tully) (LP: #966467)
  - Catch errors from creating the pixbuf separately from sending the
    notification (LP: #940182)
  - Encode URLs to UTF8 before using them. (LP: #954374)

Show diffs side-by-side

added added

removed removed

Lines of Context:
89
89
 
90
90
        #Get mention entries
91
91
        if data["entities"].has_key("user_mentions"):
 
92
          names = []
92
93
          for mention in data["entities"]["user_mentions"]:
93
 
            try:
94
 
              screen_name  = mention["screen_name"].lower()
95
 
              startindex = m["content"].lower().index("@" + screen_name) + 1
96
 
              endindex   = startindex + len(screen_name)
97
 
              start      = m["content"][0:startindex]
98
 
              end        = m["content"][endindex:]
99
 
              m["content"] = start + "<a href='gwibber:/user?acct=" + m["account"] + "&name=@" + mention["screen_name"] + "'>" + mention["screen_name"] + "</a>" + end
100
 
            except:
101
 
              pass
102
 
              
 
94
            if not mention["screen_name"] in names:
 
95
              try:
 
96
                m["content"] = m["content"].replace("@" + mention["screen_name"], "@<a href='gwibber:/user?acct=" + m["account"] + "&name=@" + mention["screen_name"] + "'>" + mention["screen_name"] + "</a>")
 
97
              except:
 
98
                pass
 
99
            names.append(mention["screen_name"])  
 
100
 
103
101
        #Get hashtag entities
104
102
        if data["entities"].has_key("hashtags"):
105
 
          for tags in data["entities"]["hashtags"]:
106
 
            try:
107
 
              text       = tags["text"]
108
 
              startindex = m["content"].index("#" + text) + 1
109
 
              endindex   = startindex + len(text)
110
 
              start      = m["content"][0:startindex]
111
 
              end        = m["content"][endindex:]
112
 
              m["content"] = start + "<a href='gwibber:/tag?acct=" + m["account"] + "&query=" + text + "'>" + text + "</a>" + end
113
 
            except:
114
 
              pass
 
103
          hashtags = []
 
104
          for tag in data["entities"]["hashtags"]:
 
105
            if not tag["text"] in hashtags:
 
106
              try:
 
107
                m["content"] = m["content"].replace("#" + tag["text"], "#<a href='gwibber:/tag?acct=" + m["account"] + "&query=#" + tag["text"] + "'>" + tag["text"] + "</a>")
 
108
              except:
 
109
                pass
 
110
            hashtags.append(tag["text"])
115
111
        
116
112
        # Get url entities - These usually go in the link stream, but if they're picturesor videos, they should go in the proper stream
117
113
        if data["entities"].has_key("urls"):