# Blosxom Plugin: storytags # Author(s): Gavin Carr # Version: 0.003000 # Documentation: See the bottom of this file or type: perldoc storytags # Requires: tags # Follows: tags package storytags; use strict; # Uncomment next line to enable debug output (don't uncomment debug() lines) #use Blosxom::Debug debug_level => 1; use vars qw(%config $taglist @taglist); # --- Configuration variables ----- %config = (); # Formatting strings $config{prefix} = 'Tags: '; $config{suffix} = '. '; # --------------------------------- # __END_CONFIG__ $taglist = ''; sub start { 1 } # Set $taglist sub story { my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; return 1 unless $tags::tag_cache && ref $tags::tag_cache && keys %{ $tags::tag_cache }; return 1 unless defined $tags::tag_cache->{"$path/$filename"}; @taglist = (); @taglist = sort { lc $a cmp lc $b } split /\s*,\s*/, $tags::tag_cache->{"$path/$filename"}->{tags} if defined $tags::tag_cache->{"$path/$filename"}->{tags}; $taglist = _format_taglist( \@taglist ); return 1; } sub _format_taglist { my ($tags) = @_; return '' unless @$tags; return $config{prefix} . join(', ', map { qq() } @$tags ) . $config{suffix}; } 1; __END__ =head1 NAME storytags - blosxom plugin to format a per-story $storytags::taglist string and @storytags::taglist array of tags =head1 DESCRIPTION L is a blosxom plugin to format a per-story $storytags::taglist string, and a @storytags::taglist array of tags. The $taglist is a comma-separated list of the tags defined for the story, prefixed by $config{prefix}, and suffixed by $config{suffix}. If no tags are defined, then $taglist will be the empty string '' (i.e. no prefix and suffix are added). @taglist is a simple array of the tags for the story, and an empty array if none are set. The default values for 'prefix' and 'suffix' are 'Tags: ' and '. ' respectively, so a typical $taglist might look like: Tags: dogs, cats, pets. =head1 USAGE L requires the L plugin, and should be loaded AFTER L. It has no other ordering dependencies. =head1 ACKNOWLEDGEMENTS This plugin was inspired by xtaran's excellent L plugin, which includes similar functionality. =head1 SEE ALSO L, L, xtaran's L. Blosxom: http://blosxom.sourceforge.net/ =head1 AUTHOR Gavin Carr , http://www.openfusion.net/ =head1 LICENSE Copyright 2007, Gavin Carr. This plugin is licensed under the same terms as blosxom itself i.e. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =cut # vim:ft=perl:sw=4