Skip to content

Instantly share code, notes, and snippets.

@averrin
Created July 12, 2011 13:05
Show Gist options
  • Save averrin/1077936 to your computer and use it in GitHub Desktop.
Save averrin/1077936 to your computer and use it in GitHub Desktop.
outwiker+instapaper
import urllib, urllib2
import wx, re
def add_link(editor):
dlg = wx.TextEntryDialog(None, "Instapaper",'Insert URL')
if dlg.ShowModal() == wx.ID_OK:
response = dlg.GetValue()
launch='<script>window.onload = function(){loadDefaults(); _width += 240; saveFont(); return false;};</script>'
if re.match('(http|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?',response):
editor.SetText(get_text(response)+launch)
else:
wx.MessageBox('Inserted text isnt URL.')
def get_text(link):
return urllib2.urlopen('http://www.instapaper.com/text?u='+link).read()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment