Maybe you know Yourls, a pretty cool URL shortener which you can set up on your own server very easily. Link shorteners are nice to have because
There are many alternatives like bit.ly, ur1.ca and so on, but Yourls belongs to YOU and you don’t have to pay attention to ToS changes or the provider’s financial status. AND you can use whichever domain you own, for example in my case it’s s.mehl.mx/blabla.
And maybe you also know Turpial, a Twitter client for GNU/Linux systems (I don’t like Twitter’s web page). Until lately I used Choqok, a KDE optimised client, but there were many things which annoyed me: No image previews, slow development, unconvenient reply behaviour and so on. And hey, why not trying something new? So I started to use Turpial which seems to solve all these critic points. Well, like always I missed some preferences to configure. But since it’s Free Software, one is able to look how the software works and to change it – and to share the improvements which I’ll do in the next step!
Turpial already offers some link shorteners but not Yourls. But we can add it manually. To do so, open the file /usr/lib/python2.7/dist-packages/libturpial/lib/services/url/shortypython/shorty.py
as root. Now add the following somewhere between the already existing shorteners
# Yourls
class Yourls(Service):
def shrink(self, bigurl):
resp = request('http://YOUR_DOMAIN/yourls-api.php', {'action': 'shorturl', 'format': 'xml', 'url': bigurl, 'signature': 'YOUR_SIGNATURE'})
returned_data = resp.read()
matched_re = re.search('(http://YOUR_DOMAIN/[^"]+)', returned_data)
if matched_re:
return matched_re.group(1)
else:
raise ShortyError('Failed to shrink url')
yourls = Yourls()
Just replace YOUR_DOMAIN
and YOUR_SIGNATURE
accordingly. The usage of a signature enables you to hide your username and password when sending the shorten requests, like an API key and looks like f51qw35w6
(more about passwordlessAPI). You can retrieve your signature on your Yourls‘ Admin page via Tools.
Then add the new service to the list of shorteners. In the same file search for services = {
(on the bottom) and add somewhere in the following list:
'yourls-instance': yourls,
Well, then just restart Turpial, go to Preferences > Services and choose yourls-instance from the list of Short URL services. Congrats, you should be able to short your URLs with Yourls in Turpial now :)
Any problems or improvements? Drop me a message!
Notes:
/usr/lib/python2.7/dist-packages/turpial/ui/qt/templates/style.css
. There you can change colors, fonts and so on. For example, the Ubuntu font wasn’t installed on my system so I just chose Sans Serif instead.
Comments