Merge lp:~ken-vandine/gwibber/lp_826323 into lp:gwibber

Proposed by Ken VanDine
Status: Merged
Merged at revision: 1288
Proposed branch: lp:~ken-vandine/gwibber/lp_826323
Merge into: lp:gwibber
Diff against target: 78 lines (+32/-8)
2 files modified
gwibber/microblog/plugins/facebook/__init__.py (+22/-3)
libgwibber/streams.vala (+10/-5)
To merge this branch: bzr merge lp:~ken-vandine/gwibber/lp_826323
Reviewer Review Type Date Requested Status
Sebastien Bacher (community) Approve
Review via email: mp+94234@code.launchpad.net

Description of the change

 * facebook: make sure we do something if the status is of type "checkin" to help prevent empty and duplicate posts in the timeline(LP: #826323)
 * filter out <p> and <b> tags in the html content, pango doesn't like them (LP: #826323)

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Seems fine to me

review: Approve
lp:~ken-vandine/gwibber/lp_826323 updated
1288. By Ken VanDine

merged fix for facebook dupes and empty posts (LP: #826323)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gwibber/microblog/plugins/facebook/__init__.py'
2--- gwibber/microblog/plugins/facebook/__init__.py 2012-02-10 10:06:59 +0000
3+++ gwibber/microblog/plugins/facebook/__init__.py 2012-02-22 17:33:25 +0000
4@@ -143,12 +143,27 @@
5
6 m["type"] = data["type"]
7
8- if data["type"] == "photo":
9+ if data["type"] == "checkin":
10+ m["location"] = {}
11+ if isinstance(data["place"], dict):
12+ m["location"]["id"] = data["place"]["id"]
13+ m["location"]["name"] = data["place"].get("name", None)
14+ if m["location"]["name"]:
15+ m["html"] += " " + _("at") + " <p><b>%s</b></p>" % m["location"]["name"]
16+ m["content"] = m["html"]
17+ m["text"] += " " + _("at") + " " + m["location"]["name"]
18+ if data["place"].has_key("location"):
19+ m["location"]["latitude"] = data["place"]["location"].get("latitude", None)
20+ m["location"]["longitude"] = data["place"]["location"].get("longitude", None)
21+ m["location"]["city"] = data["place"]["location"].get("city", None)
22+ m["location"]["state"] = data["place"]["location"].get("state", None)
23+ m["location"]["country"] = data["place"]["location"].get("country", None)
24+ elif data["type"] == "photo":
25 m["photo"] = {}
26 m["photo"]["picture"] = data.get("picture", None)
27 m["photo"]["url"] = data.get("link", None)
28 m["photo"]["name"] = data.get("name", None)
29- if data["type"] == "video":
30+ elif data["type"] == "video":
31 m["video"] = {}
32 m["video"]["picture"] = data.get("picture", None)
33 m["video"]["source"] = data.get("source", None)
34@@ -156,7 +171,7 @@
35 m["video"]["name"] = data.get("name", None)
36 m["video"]["icon"] = data.get("icon", None)
37 m["video"]["properties"] = data.get("properties", {})
38- if data["type"] == "link":
39+ elif data["type"] == "link":
40 m["link"] = {}
41 m["link"]["picture"] = data.get("picture", None)
42 m["link"]["name"] = data.get("name", None)
43@@ -165,6 +180,10 @@
44 m["link"]["icon"] = data.get("icon", None)
45 m["link"]["caption"] = data.get("caption", None)
46 m["link"]["properties"] = data.get("properties", {})
47+ elif data["type"] == "status":
48+ pass
49+ else:
50+ log.logger.error ("facebook: unexpected type %s", data["type"])
51
52 if data.has_key("privacy"):
53 m["privacy"] = {}
54
55=== modified file 'libgwibber/streams.vala'
56--- libgwibber/streams.vala 2012-02-11 06:18:27 +0000
57+++ libgwibber/streams.vala 2012-02-22 17:33:25 +0000
58@@ -681,11 +681,16 @@
59
60 /* FIXME: hacky scrubbing of the html, we should find a
61 better way */
62- _html = _html.replace("&query", "&amp;query");
63- _html = _html.replace("&name", "&amp;name");
64- _html = _html.replace("class=\"nick\"", "");
65- _html = _html.replace("class=\"hash\"", "");
66- //debug ("_html: %s", _html);
67+ if (_html != null)
68+ _html = _html.replace("&query", "&amp;query");
69+ _html = _html.replace("&name", "&amp;name");
70+ _html = _html.replace("class=\"nick\"", "");
71+ _html = _html.replace("class=\"hash\"", "");
72+ _html = _html.replace("<p>", "");
73+ _html = _html.replace("</p>", "");
74+ _html = _html.replace("<b>", "");
75+ _html = _html.replace("</b>", "");
76+ //debug ("_html: %s", _html);
77
78 string _t = utils.generate_time_string(_time);
79