Created
July 12, 2011 13:05
-
-
Save averrin/1077936 to your computer and use it in GitHub Desktop.
outwiker+instapaper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?',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