Merge lp:~kprav33n/gwibber/googleshortlinks into lp:~gwibber-committers/gwibber/trunk.merge.backup

Proposed by Praveen Kumar
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
Reviewer Review Type Date Requested Status
Ken VanDine Needs Resubmitting
Praveen Kumar (community) Needs Information
Review via email: mp+11308@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Praveen Kumar (kprav33n) wrote :

Google short links URL shortening support.

413. By Praveen Kumar

Rename 'googleshortlinks' to 'Google short links'.

Revision history for this message
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?

review: Needs Information
Revision history for this message
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!

review: Abstain
Revision history for this message
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!

Revision history for this message
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.

review: Needs Resubmitting

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

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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 errorwin.add(vb)
6 errorwin.show_all()
7
8+ def on_urlshorter_change(self, combobox, glade):
9+ model = combobox.get_model()
10+ active = combobox.get_active()
11+ if active < 0:
12+ return
13+ selected_service = model[active][0]
14+
15+ if selected_service == 'googleshortlinks':
16+ glade.get_widget("buttonURLShorterConfigure").set_sensitive(True)
17+ else:
18+ glade.get_widget("buttonURLShorterConfigure").set_sensitive(False)
19+
20+
21+ def on_urlshorter_configure(self, button):
22+ def on_save(button, dialog):
23+ dialog.destroy()
24+ return
25+
26+ glade = gtk.glade.XML(resources.get_ui_asset("preferences.glade"))
27+ dialog = glade.get_widget("dialog_googleshortlinks")
28+ glade.get_widget("googleshortlinks_btnclose").\
29+ connect("clicked", lambda a: dialog.destroy())
30+ glade.get_widget("googleshortlinks_btnsave").\
31+ connect("clicked", on_save, dialog)
32+ self.preferences.bind(glade.get_widget("googleshortlinks_server"),
33+ "googleshortlinks_server")
34+ self.preferences.bind(glade.get_widget("googleshortlinks_user"),
35+ "googleshortlinks_user")
36+ self.preferences.bind(glade.get_widget("googleshortlinks_secret"),
37+ "googleshortlinks_secret")
38+ dialog.show_all()
39+ return
40+
41 def on_preferences(self, mi):
42 # reset theme to default if no longer available
43 if self.preferences['theme'] not in resources.get_themes():
44@@ -931,7 +964,10 @@
45 theme_selector.show_all()
46
47 # add combo box with url shorter services
48+ glade.get_widget("buttonURLShorterConfigure").\
49+ connect("clicked", self.on_urlshorter_configure)
50 urlshorter_selector = gtk.combo_box_new_text()
51+ urlshorter_selector.connect("changed", self.on_urlshorter_change, glade)
52 for us in sorted(urlshorter.PROTOCOLS.keys()):
53 urlshorter_name = urlshorter.PROTOCOLS[us].PROTOCOL_INFO["name"]
54 urlshorter_selector.append_text(urlshorter_name)
55
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
61-import cligs, isgd, tinyurlcom, trim, ur1ca
62+import cligs, isgd, tinyurlcom, trim, ur1ca, googleshortlinks
63 #import snipurlcom, zima
64
65 PROTOCOLS = {
66@@ -10,4 +10,5 @@
67 "tr.im": trim,
68 "ur1.ca": ur1ca,
69 #"zi.ma": zima,
70+ "googleshortlinks": googleshortlinks
71 }
72
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+
78+"""
79+
80+Google short links interface for Gwibber.
81+kprav33n (Praveen Kumar) - 09/06/2009
82+
83+"""
84+
85+import base64
86+import datetime
87+import hmac
88+import gconf
89+import hashlib
90+import os
91+import time
92+import urllib
93+import urllib2
94+
95+PROTOCOL_INFO = {
96+
97+ 'name' : 'googleshortlinks',
98+ 'version' : 0.1,
99+ 'fqdn' : 'www.google.com'
100+}
101+
102+class URLShorter:
103+
104+ def short(self, url):
105+ # Get Google Short Links configuration.
106+ try:
107+ # FIXME: Is this the right way to get the configuration
108+ # parameters here?
109+ client = gconf.client_get_default()
110+ server = \
111+ client.get_string('/apps/gwibber/preferences/googleshortlinks_server')
112+ user = \
113+ client.get_string('/apps/gwibber/preferences/googleshortlinks_user')
114+ secret = \
115+ client.get_string('/apps/gwibber/preferences/googleshortlinks_secret')
116+ base_url = 'http://%s/js/get_or_create_hash' % server.lower()
117+ except:
118+ return "SHORTENING_FAILURE"
119+
120+ # Generate the query string.
121+ parameters = {'url' : url,
122+ 'user' : user,
123+ 'is_public' : 'true',
124+ 'oauth_signature_method' : 'HMAC-SHA1',
125+ 'timestamp' : \
126+ str(time.mktime(datetime.datetime.now().timetuple()))}
127+ param_array = [(k, v) for k, v in parameters.items()]
128+ param_array.sort()
129+ keyvals = ['%s=%s' % (urllib.quote(a, ''), urllib.quote(str(b), ''))
130+ for a, b in param_array]
131+ query_string = '&'.join(keyvals)
132+
133+ # Sign the query using HMAC-SHA1.
134+ signature_base_string = 'GET&%s&%s' % (urllib.quote(base_url, ''),
135+ urllib.quote(query_string, ''))
136+ signature = \
137+ urllib.quote(base64.b64encode(hmac.new(secret, signature_base_string,
138+ hashlib.sha1).digest()),
139+ '')
140+
141+ # Request for URL shortening.
142+ request_url = '%s?%s&oauth_signature=%s' % \
143+ (base_url, query_string, signature)
144+ response_string = urllib2.urlopen(request_url).read()
145+ short_suffix = eval(response_string.replace('true', '"true"'))['shortcut']
146+ short_url = 'http://%s/%s' % (server, short_suffix)
147+ return short_url
148
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 </child>
154 </widget>
155 <packing>
156+ <property name="top_attach">1</property>
157+ <property name="bottom_attach">2</property>
158+ </packing>
159+ </child>
160+ <child>
161+ <widget class="GtkVBox" id="vboxURLShorterConfiguration">
162+ <property name="visible">True</property>
163+ <property name="orientation">vertical</property>
164+ <child>
165+ <widget class="GtkButton" id="buttonURLShorterConfigure">
166+ <property name="label" translatable="yes">gtk-preferences</property>
167+ <property name="visible">True</property>
168+ <property name="sensitive">False</property>
169+ <property name="can_focus">True</property>
170+ <property name="receives_default">True</property>
171+ <property name="use_stock">True</property>
172+ </widget>
173+ <packing>
174+ <property name="position">0</property>
175+ </packing>
176+ </child>
177+ </widget>
178+ <packing>
179+ <property name="left_attach">1</property>
180 <property name="right_attach">2</property>
181 <property name="top_attach">1</property>
182 <property name="bottom_attach">2</property>
183+ <property name="x_options">GTK_SHRINK</property>
184 </packing>
185 </child>
186 </widget>
187@@ -4884,5 +4909,152 @@
188 </widget>
189 </child>
190 </widget>
191-
192+ <widget class="GtkDialog" id="dialog_googleshortlinks">
193+ <property name="border_width">5</property>
194+ <property name="title" translatable="yes">Edit Google Short Links Configuration</property>
195+ <property name="type_hint">normal</property>
196+ <property name="has_separator">False</property>
197+ <child internal-child="vbox">
198+ <widget class="GtkVBox" id="dialog-vbox19">
199+ <property name="visible">True</property>
200+ <property name="orientation">vertical</property>
201+ <property name="spacing">2</property>
202+ <child>
203+ <widget class="GtkFrame" id="frame_googleshortlinks">
204+ <property name="visible">True</property>
205+ <property name="label_xalign">0</property>
206+ <property name="shadow_type">none</property>
207+ <child>
208+ <widget class="GtkAlignment" id="alignment1">
209+ <property name="visible">True</property>
210+ <property name="left_padding">12</property>
211+ <child>
212+ <widget class="GtkTable" id="table1">
213+ <property name="visible">True</property>
214+ <property name="n_rows">3</property>
215+ <property name="n_columns">2</property>
216+ <child>
217+ <widget class="GtkLabel" id="googleshortlinks_lblserver">
218+ <property name="visible">True</property>
219+ <property name="label" translatable="yes">Server:</property>
220+ </widget>
221+ </child>
222+ <child>
223+ <widget class="GtkLabel" id="googleshortlinks_lbluser">
224+ <property name="visible">True</property>
225+ <property name="label" translatable="yes">User:</property>
226+ </widget>
227+ <packing>
228+ <property name="top_attach">1</property>
229+ <property name="bottom_attach">2</property>
230+ </packing>
231+ </child>
232+ <child>
233+ <widget class="GtkLabel" id="googleshortlinks_lblsecret">
234+ <property name="visible">True</property>
235+ <property name="label" translatable="yes">HMAC secret:</property>
236+ </widget>
237+ <packing>
238+ <property name="top_attach">2</property>
239+ <property name="bottom_attach">3</property>
240+ </packing>
241+ </child>
242+ <child>
243+ <widget class="GtkEntry" id="googleshortlinks_server">
244+ <property name="visible">True</property>
245+ <property name="can_focus">True</property>
246+ <property name="invisible_char">&#x25CF;</property>
247+ </widget>
248+ <packing>
249+ <property name="left_attach">1</property>
250+ <property name="right_attach">2</property>
251+ </packing>
252+ </child>
253+ <child>
254+ <widget class="GtkEntry" id="googleshortlinks_user">
255+ <property name="visible">True</property>
256+ <property name="can_focus">True</property>
257+ <property name="invisible_char">&#x25CF;</property>
258+ </widget>
259+ <packing>
260+ <property name="left_attach">1</property>
261+ <property name="right_attach">2</property>
262+ <property name="top_attach">1</property>
263+ <property name="bottom_attach">2</property>
264+ </packing>
265+ </child>
266+ <child>
267+ <widget class="GtkEntry" id="googleshortlinks_secret">
268+ <property name="visible">True</property>
269+ <property name="can_focus">True</property>
270+ <property name="invisible_char">&#x25CF;</property>
271+ </widget>
272+ <packing>
273+ <property name="left_attach">1</property>
274+ <property name="right_attach">2</property>
275+ <property name="top_attach">2</property>
276+ <property name="bottom_attach">3</property>
277+ </packing>
278+ </child>
279+ </widget>
280+ </child>
281+ </widget>
282+ </child>
283+ <child>
284+ <widget class="GtkLabel" id="label_googleshortlinks">
285+ <property name="visible">True</property>
286+ <property name="label" translatable="yes">&lt;b&gt;Google Short Links Configuration&lt;/b&gt;</property>
287+ <property name="use_markup">True</property>
288+ </widget>
289+ <packing>
290+ <property name="type">label_item</property>
291+ </packing>
292+ </child>
293+ </widget>
294+ <packing>
295+ <property name="position">1</property>
296+ </packing>
297+ </child>
298+ <child internal-child="action_area">
299+ <widget class="GtkHButtonBox" id="dialog-action_area19">
300+ <property name="visible">True</property>
301+ <property name="layout_style">end</property>
302+ <child>
303+ <widget class="GtkButton" id="googleshortlinks_btnclose">
304+ <property name="label" translatable="yes">gtk-close</property>
305+ <property name="visible">True</property>
306+ <property name="can_focus">True</property>
307+ <property name="receives_default">True</property>
308+ <property name="use_stock">True</property>
309+ </widget>
310+ <packing>
311+ <property name="expand">False</property>
312+ <property name="fill">False</property>
313+ <property name="position">0</property>
314+ </packing>
315+ </child>
316+ <child>
317+ <widget class="GtkButton" id="googleshortlinks_btnsave">
318+ <property name="label" translatable="yes">gtk-save</property>
319+ <property name="visible">True</property>
320+ <property name="can_focus">True</property>
321+ <property name="receives_default">True</property>
322+ <property name="use_stock">True</property>
323+ </widget>
324+ <packing>
325+ <property name="expand">False</property>
326+ <property name="fill">False</property>
327+ <property name="position">1</property>
328+ </packing>
329+ </child>
330+ </widget>
331+ <packing>
332+ <property name="expand">False</property>
333+ <property name="pack_type">end</property>
334+ <property name="position">0</property>
335+ </packing>
336+ </child>
337+ </widget>
338+ </child>
339+ </widget>
340 </glade-interface>

Subscribers

People subscribed via source and target branches

to all changes: