# Blosxom Plugin: Immediate Action Feeds
# Author: Dean Wilson 
# Version: 0.1 (2006028)
# Plugin Homepage: # # http://www.unixdaemon.net/blosxom_plugins.html#ia_feeds
# License: GPL
# Documentation: Please see the end of this file.
# TODO: This has a lot of duplication in the code. Convert to a hash and
# iterate through the keys.

package ia_feeds;
use vars qw($blosxom::url $blosxom::path $blosxom::fn $blosxom::flavour);
use strict;

sub start {
  1;
}


sub story {
  my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;

  #################################################
  # these are used for each link
  #################################################

  # change this to match your permalink format.
  my $post_url
    = "$blosxom::url$blosxom::path/$blosxom::fn.$blosxom::flavour";

  my $title = $$title_ref;

  #################################################
  # Submit to reddit!
  #################################################
  my $re_link_desc = 'reddit this!';
  my $re_base_url = q{http://reddit.com/submit?};
  my $re_qs = "url=$post_url&amp;title=$title";


  #################################################
  # Add to del.icio.us!
  #################################################
  my $del_link_desc = 'Add to del.icio.us!';
  my $del_base_url = q{http://del.icio.us/post?};
  my $del_qs = "url=$post_url&amp;title=$title";


  #################################################
  # Digg Me!
  #################################################
  my $digg_link_desc = 'Digg Me!';
  my $digg_base_url = q{http://www.digg.com/submit?};
  my $digg_qs = "url=$post_url&amp;title=$title&amp;phase=3";

  # add some space to avoid clutter.
  $$body_ref .= qq{<br /><br />Like this post? - };

  $$body_ref .= qq{<a href="$digg_base_url$digg_qs">$digg_link_desc</a> | };
  $$body_ref .= qq{<a href="$del_base_url$del_qs">$del_link_desc</a> | };
  $$body_ref .= qq{<a href="$re_base_url$re_qs">$re_link_desc</a>};

  1;
}

1;

__END__

=head1 NAME

Blosxom Plugin: Immediate Action Feeds (ia_feeds)

=head1 SYNOPSIS


This extension adds a number of Immediate Action feeds to each Blosxom
post, both the HTML and RSS versions. It was inspired by an XML.com
article on Immediate Action Feeds:

http://www.xml.com/lpt/a/2005/12/14/putting-rss-to-work-immediate-action-feeds.html

It currently puts "Digg Me!", "Submit to reddit!" and "Add to
del.icio.us!" links in at the bottom of the entry.

Notes:

If you plan to use this on your own blosxom powered site you'll probably
need to change $post_url to suit your own permalink style.

This plugin currently creates a CGI object way too often. If you build a
static version of your site this won't be a problem. If your
site is completely dynamic it's worth watching.

=head1 VERSION

0.1

=head1 AUTHOR

Dean Wilson 

=head1 LICENSE

GPL

=cut
