Merge lp:~markjtully/gwibber/multiplenicks into lp:gwibber

Proposed by Mark Tully
Status: Merged
Merged at revision: 1326
Proposed branch: lp:~markjtully/gwibber/multiplenicks
Merge into: lp:gwibber
Diff against target: 49 lines (+16/-20)
1 file modified
gwibber/microblog/plugins/twitter/__init__.py (+16/-20)
To merge this branch: bzr merge lp:~markjtully/gwibber/multiplenicks
Reviewer Review Type Date Requested Status
Ken VanDine Approve
Review via email: mp+99618@code.launchpad.net

Description of the change

Fixes an issue where multiple occurances of the same twitter name in the same tweet are not properly formatted, leading to a blank tweet in the stream.

To post a comment you must log in.
lp:~markjtully/gwibber/multiplenicks updated
1324. By Mark Tully

Replace all instances of a hashtag's occurance in a tweet at once rather than one at a time. (Prevents replacement of a second instance of a hashtag being put in the wrong place leading to malformed html)

Revision history for this message
Ken VanDine (ken-vandine) wrote :

There is a missing ">" in the mentions replace, I am fixing it in my merge.

Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'gwibber/microblog/plugins/twitter/__init__.py'
--- gwibber/microblog/plugins/twitter/__init__.py 2012-03-06 17:26:55 +0000
+++ gwibber/microblog/plugins/twitter/__init__.py 2012-03-28 00:37:21 +0000
@@ -89,29 +89,25 @@
8989
90 #Get mention entries90 #Get mention entries
91 if data["entities"].has_key("user_mentions"):91 if data["entities"].has_key("user_mentions"):
92 names = []
92 for mention in data["entities"]["user_mentions"]:93 for mention in data["entities"]["user_mentions"]:
93 try:94 if not mention["screen_name"] in names:
94 screen_name = mention["screen_name"].lower()95 try:
95 startindex = m["content"].lower().index("@" + screen_name) + 196 m["content"] = m["content"].replace("@" + mention["screen_name"], "@<a href='gwibber:/user?acct=" + m["account"] + "&name=@" + mention["screen_name"] + "'>" + mention["screen_name"] + "</a")
96 endindex = startindex + len(screen_name)97 except:
97 start = m["content"][0:startindex]98 pass
98 end = m["content"][endindex:]99 names.append(mention["screen_name"])
99 m["content"] = start + "<a href='gwibber:/user?acct=" + m["account"] + "&name=@" + mention["screen_name"] + "'>" + mention["screen_name"] + "</a>" + end100
100 except:
101 pass
102
103 #Get hashtag entities101 #Get hashtag entities
104 if data["entities"].has_key("hashtags"):102 if data["entities"].has_key("hashtags"):
105 for tags in data["entities"]["hashtags"]:103 hashtags = []
106 try:104 for tag in data["entities"]["hashtags"]:
107 text = tags["text"]105 if not tag["text"] in hashtags:
108 startindex = m["content"].index("#" + text) + 1106 try:
109 endindex = startindex + len(text)107 m["content"] = m["content"].replace("#" + tag["text"], "#<a href='gwibber:/tag?acct=" + m["account"] + "&query=#" + tag["text"] + "'>" + tag["text"] + "</a>")
110 start = m["content"][0:startindex]108 except:
111 end = m["content"][endindex:]109 pass
112 m["content"] = start + "<a href='gwibber:/tag?acct=" + m["account"] + "&query=" + text + "'>" + text + "</a>" + end110 hashtags.append(tag["text"])
113 except:
114 pass
115 111
116 # Get url entities - These usually go in the link stream, but if they're picturesor videos, they should go in the proper stream112 # Get url entities - These usually go in the link stream, but if they're picturesor videos, they should go in the proper stream
117 if data["entities"].has_key("urls"):113 if data["entities"].has_key("urls"):

Subscribers

People subscribed via source and target branches