Plugin: Twitter Tools – Nice Links

If you use Twitter, WordPress, and the digest feature from Alex King’s Twitter Tools together for linkblogging, you’ve probably seen your posts getting cluttered up with unreadable links like http://bit.ly/blrD2i. That’s OK for one tweet at a time, but it can get ugly for a whole list.

This plugin hooks into the Twitter Tools digests and calls out to replace those short URLs.

  • It follows redirects to update the post with the final URL.
  • It tries to retrieve the title from the remote site and use it for the link text.
  • If it can’t retrieve the title, it will use the hostname.
  • If it can’t connect to the remote site within a few seconds, it will leave the link unchanged.

Download the latest version:
ktv-twitter-tools-nicelinks-0.9.zip

Known Issues

  • It doesn’t try to convert character sets, so if you link to a page using a different charset, the title may end up messed up.
  • In testing, I noticed duplicate digests popping up a bit more often than usual. I don’t know if the time spent calling out to remote sites is contributing to a race condition or if it’s a coincidence.
  • No attempt is made to alter or shorten the title. It should be safe from XSS attacks because Twitter Tools runs the tweet through WordPress’ character filter after this runs, and it should be safe from broken HTML because it stops as soon as it hits another tag, regardless of whether it’s the end of the title or something else. But some websites do use very long titles, which can lead to unwieldy links. At least they’ll be more readable than http://bit.ly/9MhKVv.

Requirements

History:

See also: Twitter Tools Skip FB Plugin.

8 thoughts on “Plugin: Twitter Tools – Nice Links

  1. ***Dave

    Ooooh … I have just the blog to try this with (my MMO one). An excellent idea — I love using bit.ly, for example, to do quick tweets and aggregate data for the blog, but I remain mildly concerned about the long-term health of any of the link-shorteners. This should make the Net better.

    Reply
  2. Pingback: Around the web | alexking.org

  3. ***Dave

    Quick question: I’d prefer not to have the full title show up in the TT digest. My ideal would be just print “Link” and have the title show up as the alt/title tooltip, i.e.,

    {a href=”underlying url” title=”full title or whatever we can glean”}Link{/a}

    Making for neater digests and less conflicting verbiage in the digest, but still allowing folks to see what the link is going to.

    I think it would be something like:

    return ‘[~~url=’ . $finalURL . ‘[~~tit=’ . $title . ‘~~]’ . ‘Link’ . ‘/~~/’

    and then earlier do a
    str_replace ‘[~~tit’ for ‘” title=”‘

    for the second $post_data = str_replace

    Does that look right?

    Reply
  4. Pingback: Nicer Twitter archive links | ***Dave Does the Blog

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>