2005-03-13

New blosxom plugin: Technorati tags

I have written a small blosxom plugin that generates Technorati tag links. It requires the meta plugin. In order to use the plugin, you need to enter a line containing meta-tags: tag1 tag2 tag3… in your entry’s header, and to insert the variable $tags::tags at the appropriate place in your story template.

# Blosxom Plugin: tags
# Author(s): Beat Bolli <bbolli@ewanet.ch>
# Version: 2005-03-12
# Documentation:
#   Generates a <span> containing links to the technorati tag pages
#   of the tags defined by the meta-tags variable.
#   The span can be inserted in the story template with $tags::tags.
#   Requires the meta plugin.
#

package tags;

# ---- configurable variables ----

# The URL prefix prepended to each tag link
$url_prefix = 'http://technorati.com/tag/';
# uncomment the next line to generate del.icio.us links
# $url_prefix = 'http://del.icio.us/tag/';
# uncomment the next line to generate Flickr links
# $url_prefix = 'http://flickr.com/photos/tags/';

# The text that is generated at the beginning of the tag list
$tag_prefix = "Tags:\n";

# The HTML element that contains all tags
$tag_element = 'span';

# The CSS class of the above HTML element containing all tags
$tag_class = 'blosxomTags';

# --------------------------------

$tags = '';

sub start {
  1;
}

sub story {

  $tags = '';
  if ($meta::tags ne '') {
    foreach (split(/ +/, $meta::tags)) {
      $tags .= "<a rel=\"tag\" href=\"$url_prefix$_\">$_</a>\n";
    }
    $tags = "<$tag_element class=\"$tag_class\">$tag_prefix$tags</$tag_element>\n";
  }
  
  1;
}

1;

You can configure the text and URL prefixed to your tags, as well as the generated HTML element and its CSS class.

[Update]: Fixed the flickr URL, wrote a plugin update

01:13 [/software/blog] Google Trackback
Tags: