1 # Blosxom Plugin: storytags
2 # Author(s): Gavin Carr <gavin@openfusion.com.au>
4 # Documentation: See the bottom of this file or type: perldoc storytags
12 # Uncomment next line to enable debug output (don't uncomment debug() lines)
13 #use Blosxom::Debug debug_level => 1;
15 use vars qw(%config $taglist @taglist);
17 # --- Configuration variables -----
22 $config{prefix} = 'Tags: ';
23 $config{suffix} = '. ';
25 # ---------------------------------
34 my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
36 return 1 unless $tags::tag_cache
37 && ref $tags::tag_cache
38 && keys %{ $tags::tag_cache };
39 return 1 unless defined $tags::tag_cache->{"$path/$filename"};
42 @taglist = sort { lc $a cmp lc $b } split /\s*,\s*/,
43 $tags::tag_cache->{"$path/$filename"}->{tags}
44 if defined $tags::tag_cache->{"$path/$filename"}->{tags};
45 $taglist = _format_taglist( \@taglist );
52 return '' unless @$tags;
53 return $config{prefix}
55 map { qq(<a href="$blosxom::url/tags/$_" rel="tag">$_</a>) }
67 storytags - blosxom plugin to format a per-story $storytags::taglist string
68 and @storytags::taglist array of tags
72 L<storytags> is a blosxom plugin to format a per-story $storytags::taglist
73 string, and a @storytags::taglist array of tags. The $taglist is a
74 comma-separated list of the tags defined for the story, prefixed by
75 $config{prefix}, and suffixed by $config{suffix}. If no tags are
76 defined, then $taglist will be the empty string '' (i.e. no prefix and
77 suffix are added). @taglist is a simple array of the tags for the story,
78 and an empty array if none are set.
80 The default values for 'prefix' and 'suffix' are 'Tags: ' and '. '
81 respectively, so a typical $taglist might look like:
83 Tags: dogs, cats, pets.
87 L<storytags> requires the L<tags> plugin, and should be loaded AFTER
88 L<tags>. It has no other ordering dependencies.
90 =head1 ACKNOWLEDGEMENTS
92 This plugin was inspired by xtaran's excellent L<tagging> plugin,
93 which includes similar functionality.
97 L<tags>, L<tagcloud>, xtaran's L<tagging>.
99 Blosxom: http://blosxom.sourceforge.net/
103 Gavin Carr <gavin@openfusion.com.au>, http://www.openfusion.net/
107 Copyright 2007, Gavin Carr.
109 This plugin is licensed under the same terms as blosxom itself i.e.
111 Permission is hereby granted, free of charge, to any person obtaining a
112 copy of this software and associated documentation files (the "Software"),
113 to deal in the Software without restriction, including without limitation
114 the rights to use, copy, modify, merge, publish, distribute, sublicense,
115 and/or sell copies of the Software, and to permit persons to whom the
116 Software is furnished to do so, subject to the following conditions:
118 The above copyright notice and this permission notice shall be included
119 in all copies or substantial portions of the Software.
121 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
122 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
123 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
124 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
125 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
126 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
127 OTHER DEALINGS IN THE SOFTWARE.