Giles Turnbull asked if anyone had written an equivalent of the overenthusiastic hyperlinker for Mac as an OS X Service. I never worked out how to get Services to work, but a while back I did hack up something for Cory for BBEdit . It worked fine on my borrowed ibook, but I didn’t have time to work out how to get it to find Python libraries on his machine. Then the ibook broke :(. Here’s the code – stick it in /Applications/BBEdit 6.5/BBEdit Support/Unix Support/Unix Filters/ then spend ages trying to get it to find the pygoogle libraries (which you also need to download and install). Then give it out as a DMG for others to use. Yay!
1 |
#!/sw/bin/python import google import sys import re def main(argv): search=open(argv[0],"r").readline() data = google.doGoogleSearch(search) if (data.results[0].summary): title = data.results[0].summary else: title = data.results[0].title title = re.sub('</*b>','',title) print '<a href="%s" title="%s">%s</a>' % (data.results[0].URL, title, search) if __name__ == '__main__': main(sys.argv[1:]) |
Just select the text in BBEdit, and then – oh, I forget what you do. Some BBEdit option marked “Unix Filters” I imagine. I’m such a tease.
Here’s another from the bag of tricks I sent Cory – this automatically creates a new QuickTopic and subscribes you to it. Save it in the same place and give it a go. Just select the text you want as a title, and let her rip (you’ll need to change the yourname/yourmail stuff in it). It’ll spit out the URL for your discussion. I think Cory still uses this. It used to drive me crazy watching him jump through all these manual loops just to post one damn Boing Boing post. Like the boy hasn’t enough things to do.
1 |
#!/sw/bin/python import xmlrpclib import sys yourname = 'Your Name Here' yourmail = 'your@email.address.example.com' # ---------------------------------------------------------------------- print len(sys.argv) title=open(sys.argv[1],"r").readline() if (title == ''): title = "Boing Boing Discussion" quicktopic = xmlrpclib.Server("http://www.quicktopic.com/cgi-bin/xmlrpc.pl") result = quicktopic.tio.newTopic( yourname, # user name for topic creator yourmail, # email for creator 'boing', # forum ID (the part before the /H/ in the URL) title, # topic name '', # first message 1, # subscribe: get email for every post '', #linkfrom -- linked forum/topic '', #linksubject linked topic name 0, #privacy (currently unused option) '', #language (default is English) ) url = result.split(",")[0] print ' <a href="%s">Discuss</a>' % url |