Lately I’ve been linkblogging via Twitter, and using Alex King’s Twitter Tools to build a weekly digest in WordPress. The problem is that since I’m pulling the posts from Twitter, I’m stuck with Twitter’s limitations: Short descriptions, cryptic URLs, and unreadable links.
So I wrote a plugin to process the links. When Twitter Tools builds a digest, the plugin calls out to the remote site, follows redirects, retrieves the final URL and (if possible) extracts the page title. Then it replaces the cryptic-looking link with a human-readable link, transforming this:
Check out this site: http://bit.ly/9MhKVv
into this:
Check out this site: Flash: Those Who Ride the Lightning
If it can’t retrieve a title, it uses the final hostname. If it can’t connect at all, it leaves the link unchanged.
The download is here, and that’s where I’ll put future versions:
» Plugin: Twitter Tools – Nice Links.
Future
One thing I’d like to add at some point is cleaning up the title a bit. They can get really long, even without people trying to stuff keywords and descriptions in for SEO purposes. All it takes is a page title plus a site title, like this one. That’s a much more complicated problem, though, since there isn’t any sort of standard for which part of a title is the most important. I suppose I could just clip it to the first few words.
I’d also like to clean up duplicate text. Often the link title and tweet content are going to be the same, or at least overlap, especially if it’s generated by a sharing button or extension. That should be easier to check.
Well, tried it out on one blog and it worked fine. TT can be such a fragile beast, it will bear monitoring for a while, but …
One possible future feature cuts through some of the complexity of what you were discussing above. I wouldn’t at all mind (in fact think I would prefer) having the reformed link simply have “Link” as its text, and throw the page title in as a title tag, e.g.,
[a href=”http://coolsite.com/page-i-linked-to/” title=”A Cool Idea | Fred’s Blog”]Link[/a]
That gets all the cross-referencing info in there without visually dealing with overly-long or duplicative page titles.
Hmm, that should work. I’ll give it a try when I have a chance. Time to learn how to create an options page!