# Blosxom Plugin: submit_to_reddit
# Author: Dean Wilson 
# Version: 0.1 (20060128)
# Plugin Homepage:
# http://www.unixdaemon.net/blosxom_plugins.html#submit_to_reddit
# License: GPL
# Documentation: Please see the end of this file.

package submit_to_reddit;
use strict;

sub start {
  1;
}


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

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

  my $title = $$title_ref;

  my $link_desc = 'reddit this!';
  my $base_url = q{http://reddit.com/submit?};
  my $full_url = "url=$post_url&title=$title";

  # heavy weight. Not a problem if you cache the run and server static site
  my $q = new CGI($full_url);
  my $post_esc = $q->query_string;

  $$body_ref .= qq{<br /><br />};
  $$body_ref .= qq{<a href="$base_url$post_esc">$link_desc</a>};

  1;
}

1;

__END__

=head1 NAME

Blosxom Plugin: submit_to_reddit

=head1 SYNOPSIS


This extension adds a 'reddit this!' link to the bottom
of every blog post and RSS item. 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

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
