Merge lp:~kprav33n/gwibber/googleshortlinks into lp:~gwibber-committers/gwibber/trunk.merge.backup
- googleshortlinks
- Merge into trunk.merge.backup
Status: | Needs review |
---|---|
Proposed branch: | lp:~kprav33n/gwibber/googleshortlinks |
Merge into: | lp:~gwibber-committers/gwibber/trunk.merge.backup |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~kprav33n/gwibber/googleshortlinks |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ken VanDine | Needs Resubmitting | ||
Praveen Kumar (community) | Needs Information | ||
Review via email: mp+11308@code.launchpad.net |
Commit message
Description of the change
- 413. By Praveen Kumar
-
Rename 'googleshortlinks' to 'Google short links'.
Praveen Kumar (kprav33n) wrote : | # |
> Google short links URL shortening support.
Is there something wrong with these changes? Any idea on when it is going to be merged?
Ken VanDine (ken-vandine) wrote : | # |
We have been focusing on stabilizing 2.0 for release, post 2.0 we will look at merging this. Thanks!
Praveen Kumar (kprav33n) wrote : | # |
> We have been focusing on stabilizing 2.0 for release, post 2.0 we will look at
> merging this. Thanks!
Is there still a plan to merge this branch into the master? Thanks!
Ken VanDine (ken-vandine) wrote : | # |
Please resubmit your branch against current trunk. Your branch was proposed for a branch that had to be moved out of the way because of some bzr problems we had a few months back.
Unmerged revisions
- 413. By Praveen Kumar
-
Rename 'googleshortlinks' to 'Google short links'.
- 412. By Praveen Kumar
-
Use gconf stored settings for Google short links URL shortening.
- 411. By Praveen Kumar
-
Hook Google short links configuration with gconf.
- 410. By Praveen Kumar
-
Add Google short links configuration dialog and hook it up.
- 409. By Praveen Kumar
-
Add initial support for Google short links configuration.
- 408. By Praveen Kumar
-
Add initial support for Google short links URL shortening service.
Preview Diff
1 | === modified file 'gwibber/client.py' | |||
2 | --- gwibber/client.py 2009-09-04 00:07:09 +0000 | |||
3 | +++ gwibber/client.py 2009-09-07 14:24:19 +0000 | |||
4 | @@ -892,6 +892,39 @@ | |||
5 | 892 | errorwin.add(vb) | 892 | errorwin.add(vb) |
6 | 893 | errorwin.show_all() | 893 | errorwin.show_all() |
7 | 894 | 894 | ||
8 | 895 | def on_urlshorter_change(self, combobox, glade): | ||
9 | 896 | model = combobox.get_model() | ||
10 | 897 | active = combobox.get_active() | ||
11 | 898 | if active < 0: | ||
12 | 899 | return | ||
13 | 900 | selected_service = model[active][0] | ||
14 | 901 | |||
15 | 902 | if selected_service == 'googleshortlinks': | ||
16 | 903 | glade.get_widget("buttonURLShorterConfigure").set_sensitive(True) | ||
17 | 904 | else: | ||
18 | 905 | glade.get_widget("buttonURLShorterConfigure").set_sensitive(False) | ||
19 | 906 | |||
20 | 907 | |||
21 | 908 | def on_urlshorter_configure(self, button): | ||
22 | 909 | def on_save(button, dialog): | ||
23 | 910 | dialog.destroy() | ||
24 | 911 | return | ||
25 | 912 | |||
26 | 913 | glade = gtk.glade.XML(resources.get_ui_asset("preferences.glade")) | ||
27 | 914 | dialog = glade.get_widget("dialog_googleshortlinks") | ||
28 | 915 | glade.get_widget("googleshortlinks_btnclose").\ | ||
29 | 916 | connect("clicked", lambda a: dialog.destroy()) | ||
30 | 917 | glade.get_widget("googleshortlinks_btnsave").\ | ||
31 | 918 | connect("clicked", on_save, dialog) | ||
32 | 919 | self.preferences.bind(glade.get_widget("googleshortlinks_server"), | ||
33 | 920 | "googleshortlinks_server") | ||
34 | 921 | self.preferences.bind(glade.get_widget("googleshortlinks_user"), | ||
35 | 922 | "googleshortlinks_user") | ||
36 | 923 | self.preferences.bind(glade.get_widget("googleshortlinks_secret"), | ||
37 | 924 | "googleshortlinks_secret") | ||
38 | 925 | dialog.show_all() | ||
39 | 926 | return | ||
40 | 927 | |||
41 | 895 | def on_preferences(self, mi): | 928 | def on_preferences(self, mi): |
42 | 896 | # reset theme to default if no longer available | 929 | # reset theme to default if no longer available |
43 | 897 | if self.preferences['theme'] not in resources.get_themes(): | 930 | if self.preferences['theme'] not in resources.get_themes(): |
44 | @@ -931,7 +964,10 @@ | |||
45 | 931 | theme_selector.show_all() | 964 | theme_selector.show_all() |
46 | 932 | 965 | ||
47 | 933 | # add combo box with url shorter services | 966 | # add combo box with url shorter services |
48 | 967 | glade.get_widget("buttonURLShorterConfigure").\ | ||
49 | 968 | connect("clicked", self.on_urlshorter_configure) | ||
50 | 934 | urlshorter_selector = gtk.combo_box_new_text() | 969 | urlshorter_selector = gtk.combo_box_new_text() |
51 | 970 | urlshorter_selector.connect("changed", self.on_urlshorter_change, glade) | ||
52 | 935 | for us in sorted(urlshorter.PROTOCOLS.keys()): | 971 | for us in sorted(urlshorter.PROTOCOLS.keys()): |
53 | 936 | urlshorter_name = urlshorter.PROTOCOLS[us].PROTOCOL_INFO["name"] | 972 | urlshorter_name = urlshorter.PROTOCOLS[us].PROTOCOL_INFO["name"] |
54 | 937 | urlshorter_selector.append_text(urlshorter_name) | 973 | urlshorter_selector.append_text(urlshorter_name) |
55 | 938 | 974 | ||
56 | === modified file 'gwibber/urlshorter/__init__.py' | |||
57 | --- gwibber/urlshorter/__init__.py 2009-04-15 22:56:03 +0000 | |||
58 | +++ gwibber/urlshorter/__init__.py 2009-09-07 08:53:16 +0000 | |||
59 | @@ -1,5 +1,5 @@ | |||
60 | 1 | 1 | ||
62 | 2 | import cligs, isgd, tinyurlcom, trim, ur1ca | 2 | import cligs, isgd, tinyurlcom, trim, ur1ca, googleshortlinks |
63 | 3 | #import snipurlcom, zima | 3 | #import snipurlcom, zima |
64 | 4 | 4 | ||
65 | 5 | PROTOCOLS = { | 5 | PROTOCOLS = { |
66 | @@ -10,4 +10,5 @@ | |||
67 | 10 | "tr.im": trim, | 10 | "tr.im": trim, |
68 | 11 | "ur1.ca": ur1ca, | 11 | "ur1.ca": ur1ca, |
69 | 12 | #"zi.ma": zima, | 12 | #"zi.ma": zima, |
70 | 13 | "googleshortlinks": googleshortlinks | ||
71 | 13 | } | 14 | } |
72 | 14 | 15 | ||
73 | === added file 'gwibber/urlshorter/googleshortlinks.py' | |||
74 | --- gwibber/urlshorter/googleshortlinks.py 1970-01-01 00:00:00 +0000 | |||
75 | +++ gwibber/urlshorter/googleshortlinks.py 2009-09-07 14:27:14 +0000 | |||
76 | @@ -0,0 +1,71 @@ | |||
77 | 1 | |||
78 | 2 | """ | ||
79 | 3 | |||
80 | 4 | Google short links interface for Gwibber. | ||
81 | 5 | kprav33n (Praveen Kumar) - 09/06/2009 | ||
82 | 6 | |||
83 | 7 | """ | ||
84 | 8 | |||
85 | 9 | import base64 | ||
86 | 10 | import datetime | ||
87 | 11 | import hmac | ||
88 | 12 | import gconf | ||
89 | 13 | import hashlib | ||
90 | 14 | import os | ||
91 | 15 | import time | ||
92 | 16 | import urllib | ||
93 | 17 | import urllib2 | ||
94 | 18 | |||
95 | 19 | PROTOCOL_INFO = { | ||
96 | 20 | |||
97 | 21 | 'name' : 'googleshortlinks', | ||
98 | 22 | 'version' : 0.1, | ||
99 | 23 | 'fqdn' : 'www.google.com' | ||
100 | 24 | } | ||
101 | 25 | |||
102 | 26 | class URLShorter: | ||
103 | 27 | |||
104 | 28 | def short(self, url): | ||
105 | 29 | # Get Google Short Links configuration. | ||
106 | 30 | try: | ||
107 | 31 | # FIXME: Is this the right way to get the configuration | ||
108 | 32 | # parameters here? | ||
109 | 33 | client = gconf.client_get_default() | ||
110 | 34 | server = \ | ||
111 | 35 | client.get_string('/apps/gwibber/preferences/googleshortlinks_server') | ||
112 | 36 | user = \ | ||
113 | 37 | client.get_string('/apps/gwibber/preferences/googleshortlinks_user') | ||
114 | 38 | secret = \ | ||
115 | 39 | client.get_string('/apps/gwibber/preferences/googleshortlinks_secret') | ||
116 | 40 | base_url = 'http://%s/js/get_or_create_hash' % server.lower() | ||
117 | 41 | except: | ||
118 | 42 | return "SHORTENING_FAILURE" | ||
119 | 43 | |||
120 | 44 | # Generate the query string. | ||
121 | 45 | parameters = {'url' : url, | ||
122 | 46 | 'user' : user, | ||
123 | 47 | 'is_public' : 'true', | ||
124 | 48 | 'oauth_signature_method' : 'HMAC-SHA1', | ||
125 | 49 | 'timestamp' : \ | ||
126 | 50 | str(time.mktime(datetime.datetime.now().timetuple()))} | ||
127 | 51 | param_array = [(k, v) for k, v in parameters.items()] | ||
128 | 52 | param_array.sort() | ||
129 | 53 | keyvals = ['%s=%s' % (urllib.quote(a, ''), urllib.quote(str(b), '')) | ||
130 | 54 | for a, b in param_array] | ||
131 | 55 | query_string = '&'.join(keyvals) | ||
132 | 56 | |||
133 | 57 | # Sign the query using HMAC-SHA1. | ||
134 | 58 | signature_base_string = 'GET&%s&%s' % (urllib.quote(base_url, ''), | ||
135 | 59 | urllib.quote(query_string, '')) | ||
136 | 60 | signature = \ | ||
137 | 61 | urllib.quote(base64.b64encode(hmac.new(secret, signature_base_string, | ||
138 | 62 | hashlib.sha1).digest()), | ||
139 | 63 | '') | ||
140 | 64 | |||
141 | 65 | # Request for URL shortening. | ||
142 | 66 | request_url = '%s?%s&oauth_signature=%s' % \ | ||
143 | 67 | (base_url, query_string, signature) | ||
144 | 68 | response_string = urllib2.urlopen(request_url).read() | ||
145 | 69 | short_suffix = eval(response_string.replace('true', '"true"'))['shortcut'] | ||
146 | 70 | short_url = 'http://%s/%s' % (server, short_suffix) | ||
147 | 71 | return short_url | ||
148 | 0 | 72 | ||
149 | === modified file 'ui/preferences.glade' | |||
150 | --- ui/preferences.glade 2009-08-16 05:49:21 +0000 | |||
151 | +++ ui/preferences.glade 2009-09-07 14:24:19 +0000 | |||
152 | @@ -287,9 +287,34 @@ | |||
153 | 287 | </child> | 287 | </child> |
154 | 288 | </widget> | 288 | </widget> |
155 | 289 | <packing> | 289 | <packing> |
156 | 290 | <property name="top_attach">1</property> | ||
157 | 291 | <property name="bottom_attach">2</property> | ||
158 | 292 | </packing> | ||
159 | 293 | </child> | ||
160 | 294 | <child> | ||
161 | 295 | <widget class="GtkVBox" id="vboxURLShorterConfiguration"> | ||
162 | 296 | <property name="visible">True</property> | ||
163 | 297 | <property name="orientation">vertical</property> | ||
164 | 298 | <child> | ||
165 | 299 | <widget class="GtkButton" id="buttonURLShorterConfigure"> | ||
166 | 300 | <property name="label" translatable="yes">gtk-preferences</property> | ||
167 | 301 | <property name="visible">True</property> | ||
168 | 302 | <property name="sensitive">False</property> | ||
169 | 303 | <property name="can_focus">True</property> | ||
170 | 304 | <property name="receives_default">True</property> | ||
171 | 305 | <property name="use_stock">True</property> | ||
172 | 306 | </widget> | ||
173 | 307 | <packing> | ||
174 | 308 | <property name="position">0</property> | ||
175 | 309 | </packing> | ||
176 | 310 | </child> | ||
177 | 311 | </widget> | ||
178 | 312 | <packing> | ||
179 | 313 | <property name="left_attach">1</property> | ||
180 | 290 | <property name="right_attach">2</property> | 314 | <property name="right_attach">2</property> |
181 | 291 | <property name="top_attach">1</property> | 315 | <property name="top_attach">1</property> |
182 | 292 | <property name="bottom_attach">2</property> | 316 | <property name="bottom_attach">2</property> |
183 | 317 | <property name="x_options">GTK_SHRINK</property> | ||
184 | 293 | </packing> | 318 | </packing> |
185 | 294 | </child> | 319 | </child> |
186 | 295 | </widget> | 320 | </widget> |
187 | @@ -4884,5 +4909,152 @@ | |||
188 | 4884 | </widget> | 4909 | </widget> |
189 | 4885 | </child> | 4910 | </child> |
190 | 4886 | </widget> | 4911 | </widget> |
192 | 4887 | 4912 | <widget class="GtkDialog" id="dialog_googleshortlinks"> | |
193 | 4913 | <property name="border_width">5</property> | ||
194 | 4914 | <property name="title" translatable="yes">Edit Google Short Links Configuration</property> | ||
195 | 4915 | <property name="type_hint">normal</property> | ||
196 | 4916 | <property name="has_separator">False</property> | ||
197 | 4917 | <child internal-child="vbox"> | ||
198 | 4918 | <widget class="GtkVBox" id="dialog-vbox19"> | ||
199 | 4919 | <property name="visible">True</property> | ||
200 | 4920 | <property name="orientation">vertical</property> | ||
201 | 4921 | <property name="spacing">2</property> | ||
202 | 4922 | <child> | ||
203 | 4923 | <widget class="GtkFrame" id="frame_googleshortlinks"> | ||
204 | 4924 | <property name="visible">True</property> | ||
205 | 4925 | <property name="label_xalign">0</property> | ||
206 | 4926 | <property name="shadow_type">none</property> | ||
207 | 4927 | <child> | ||
208 | 4928 | <widget class="GtkAlignment" id="alignment1"> | ||
209 | 4929 | <property name="visible">True</property> | ||
210 | 4930 | <property name="left_padding">12</property> | ||
211 | 4931 | <child> | ||
212 | 4932 | <widget class="GtkTable" id="table1"> | ||
213 | 4933 | <property name="visible">True</property> | ||
214 | 4934 | <property name="n_rows">3</property> | ||
215 | 4935 | <property name="n_columns">2</property> | ||
216 | 4936 | <child> | ||
217 | 4937 | <widget class="GtkLabel" id="googleshortlinks_lblserver"> | ||
218 | 4938 | <property name="visible">True</property> | ||
219 | 4939 | <property name="label" translatable="yes">Server:</property> | ||
220 | 4940 | </widget> | ||
221 | 4941 | </child> | ||
222 | 4942 | <child> | ||
223 | 4943 | <widget class="GtkLabel" id="googleshortlinks_lbluser"> | ||
224 | 4944 | <property name="visible">True</property> | ||
225 | 4945 | <property name="label" translatable="yes">User:</property> | ||
226 | 4946 | </widget> | ||
227 | 4947 | <packing> | ||
228 | 4948 | <property name="top_attach">1</property> | ||
229 | 4949 | <property name="bottom_attach">2</property> | ||
230 | 4950 | </packing> | ||
231 | 4951 | </child> | ||
232 | 4952 | <child> | ||
233 | 4953 | <widget class="GtkLabel" id="googleshortlinks_lblsecret"> | ||
234 | 4954 | <property name="visible">True</property> | ||
235 | 4955 | <property name="label" translatable="yes">HMAC secret:</property> | ||
236 | 4956 | </widget> | ||
237 | 4957 | <packing> | ||
238 | 4958 | <property name="top_attach">2</property> | ||
239 | 4959 | <property name="bottom_attach">3</property> | ||
240 | 4960 | </packing> | ||
241 | 4961 | </child> | ||
242 | 4962 | <child> | ||
243 | 4963 | <widget class="GtkEntry" id="googleshortlinks_server"> | ||
244 | 4964 | <property name="visible">True</property> | ||
245 | 4965 | <property name="can_focus">True</property> | ||
246 | 4966 | <property name="invisible_char">●</property> | ||
247 | 4967 | </widget> | ||
248 | 4968 | <packing> | ||
249 | 4969 | <property name="left_attach">1</property> | ||
250 | 4970 | <property name="right_attach">2</property> | ||
251 | 4971 | </packing> | ||
252 | 4972 | </child> | ||
253 | 4973 | <child> | ||
254 | 4974 | <widget class="GtkEntry" id="googleshortlinks_user"> | ||
255 | 4975 | <property name="visible">True</property> | ||
256 | 4976 | <property name="can_focus">True</property> | ||
257 | 4977 | <property name="invisible_char">●</property> | ||
258 | 4978 | </widget> | ||
259 | 4979 | <packing> | ||
260 | 4980 | <property name="left_attach">1</property> | ||
261 | 4981 | <property name="right_attach">2</property> | ||
262 | 4982 | <property name="top_attach">1</property> | ||
263 | 4983 | <property name="bottom_attach">2</property> | ||
264 | 4984 | </packing> | ||
265 | 4985 | </child> | ||
266 | 4986 | <child> | ||
267 | 4987 | <widget class="GtkEntry" id="googleshortlinks_secret"> | ||
268 | 4988 | <property name="visible">True</property> | ||
269 | 4989 | <property name="can_focus">True</property> | ||
270 | 4990 | <property name="invisible_char">●</property> | ||
271 | 4991 | </widget> | ||
272 | 4992 | <packing> | ||
273 | 4993 | <property name="left_attach">1</property> | ||
274 | 4994 | <property name="right_attach">2</property> | ||
275 | 4995 | <property name="top_attach">2</property> | ||
276 | 4996 | <property name="bottom_attach">3</property> | ||
277 | 4997 | </packing> | ||
278 | 4998 | </child> | ||
279 | 4999 | </widget> | ||
280 | 5000 | </child> | ||
281 | 5001 | </widget> | ||
282 | 5002 | </child> | ||
283 | 5003 | <child> | ||
284 | 5004 | <widget class="GtkLabel" id="label_googleshortlinks"> | ||
285 | 5005 | <property name="visible">True</property> | ||
286 | 5006 | <property name="label" translatable="yes"><b>Google Short Links Configuration</b></property> | ||
287 | 5007 | <property name="use_markup">True</property> | ||
288 | 5008 | </widget> | ||
289 | 5009 | <packing> | ||
290 | 5010 | <property name="type">label_item</property> | ||
291 | 5011 | </packing> | ||
292 | 5012 | </child> | ||
293 | 5013 | </widget> | ||
294 | 5014 | <packing> | ||
295 | 5015 | <property name="position">1</property> | ||
296 | 5016 | </packing> | ||
297 | 5017 | </child> | ||
298 | 5018 | <child internal-child="action_area"> | ||
299 | 5019 | <widget class="GtkHButtonBox" id="dialog-action_area19"> | ||
300 | 5020 | <property name="visible">True</property> | ||
301 | 5021 | <property name="layout_style">end</property> | ||
302 | 5022 | <child> | ||
303 | 5023 | <widget class="GtkButton" id="googleshortlinks_btnclose"> | ||
304 | 5024 | <property name="label" translatable="yes">gtk-close</property> | ||
305 | 5025 | <property name="visible">True</property> | ||
306 | 5026 | <property name="can_focus">True</property> | ||
307 | 5027 | <property name="receives_default">True</property> | ||
308 | 5028 | <property name="use_stock">True</property> | ||
309 | 5029 | </widget> | ||
310 | 5030 | <packing> | ||
311 | 5031 | <property name="expand">False</property> | ||
312 | 5032 | <property name="fill">False</property> | ||
313 | 5033 | <property name="position">0</property> | ||
314 | 5034 | </packing> | ||
315 | 5035 | </child> | ||
316 | 5036 | <child> | ||
317 | 5037 | <widget class="GtkButton" id="googleshortlinks_btnsave"> | ||
318 | 5038 | <property name="label" translatable="yes">gtk-save</property> | ||
319 | 5039 | <property name="visible">True</property> | ||
320 | 5040 | <property name="can_focus">True</property> | ||
321 | 5041 | <property name="receives_default">True</property> | ||
322 | 5042 | <property name="use_stock">True</property> | ||
323 | 5043 | </widget> | ||
324 | 5044 | <packing> | ||
325 | 5045 | <property name="expand">False</property> | ||
326 | 5046 | <property name="fill">False</property> | ||
327 | 5047 | <property name="position">1</property> | ||
328 | 5048 | </packing> | ||
329 | 5049 | </child> | ||
330 | 5050 | </widget> | ||
331 | 5051 | <packing> | ||
332 | 5052 | <property name="expand">False</property> | ||
333 | 5053 | <property name="pack_type">end</property> | ||
334 | 5054 | <property name="position">0</property> | ||
335 | 5055 | </packing> | ||
336 | 5056 | </child> | ||
337 | 5057 | </widget> | ||
338 | 5058 | </child> | ||
339 | 5059 | </widget> | ||
340 | 4888 | </glade-interface> | 5060 | </glade-interface> |
Google short links URL shortening support.