X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fblosxom-plugins.git;a=blobdiff_plain;f=gavinc%2Fstorytags;h=1665dbf5fb11e39074cf901a0210844b4d1133a0;hp=148a48f5c2d70dc24d048efec69b527231c334f1;hb=ad3af3cccc6f2e50b250bd3ca8d98e2a1a58e994;hpb=8e0324e7a66d95f254920991f60045d12b07e24e diff --git a/gavinc/storytags b/gavinc/storytags index 148a48f..1665dbf 100644 --- a/gavinc/storytags +++ b/gavinc/storytags @@ -1,6 +1,6 @@ # Blosxom Plugin: storytags # Author(s): Gavin Carr -# Version: 0.001000 +# Version: 0.002000 # Documentation: See the bottom of this file or type: perldoc storytags # Requires: tags # Follows: tags @@ -12,7 +12,7 @@ use strict; # Uncomment next line to enable debug output (don't uncomment debug() lines) #use Blosxom::Debug debug_level => 1; -use vars qw($taglist); +use vars qw($taglist @taglist); # --- Configuration variables ----- @@ -21,6 +21,7 @@ my $prefix = 'Tags: '; my $suffix = '. '; # --------------------------------- +# __END_CONFIG__ $taglist = ''; @@ -31,24 +32,26 @@ 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 }; + && ref $tags::tag_cache + && keys %{ $tags::tag_cache }; return 1 unless defined $tags::tag_cache->{"$path/$filename"}; - $taglist = _format_taglist($tags::tag_cache->{"$path/$filename"}->{tags}); + @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) = @_; - $tags = '' unless defined $tags; - my @tags = sort { lc $a cmp lc $b } split /\s*,\s*/, $tags; - return '' unless @tags; + return '' unless @$tags; return $prefix . join(', ', map { qq() } - @tags + @$tags ) . $suffix; } @@ -60,14 +63,17 @@ __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. The string is a comma-separated list of the tags defined for the -story, prefixed by $storytags::prefix, and suffixed by $storytags::suffix. -If no tags are defined, then $taglist will be the empty string '' (i.e. no -prefix and suffix are added). +string, and a @storytags::taglist array of tags. The $taglist is a +comma-separated list of the tags defined for the story, prefixed by +$storytags::prefix, and suffixed by $storytags::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: