# Blosxom Plugin: metamail
# Author(s): Gavin Carr <gavin@openfusion.com.au>
-# Version: 0.001000
+# Version: 0.002000
# Documentation: 'perldoc metamail'
# Requires: metaclear
# Follows: metaclear
package metamail;
use strict;
+use vars qw(%config);
#use Blosxom::Debug debug_level => 1;
# --- Configurable variables -----
+%config = ();
+
# Headers to consider titles
-my @title_headers = qw(Title Subject);
+$config{title_headers} = [ qw(Title Subject) ];
# Headers to keep in the body (required by later plugins, for instance)
-my @keep_in_body_headers = qw(Tags);
+$config{keep_in_body_headers} = qw(Tags);
# Whether to unfold (join) multi-line headers
-my $unfold_headers = 1;
+$config{unfold_headers} = 1;
# --------------------------------
# __END_CONFIG__
}
# For backwards compatibility, assume a header without a : is a title
else {
- $key = @title_headers[0] || 'Title';
+ $key = $config{title_headers}->[0] || 'Title';
$value = $header;
}
chomp $value;
# Unfold
- $value =~ s/\n //g if $unfold_headers;
+ $value =~ s/\n //g if $config{unfold_headers};
# Cache header
$header{$key} = $value;
# Update $$title_ref to the first title_header we can find
$$title_ref = '';
- for (@title_headers) {
+ for (@{$config{title_headers}}) {
$$title_ref = $header{$_} and last if $header{$_};
}
# Update body_ref
- if (my @keep_headers = grep { defined $header{$_} } @keep_in_body_headers) {
+ if (my @keep_headers = grep { defined $header{$_} } @{$config{keep_in_body_headers}}) {
$$body_ref = join("\n", map { "$_: $header{$_}" } @keep_headers) . "\n" . $body;
}
else {
For backwards compatibility purposes, L<metamail> will treat any header
not containing a colon (which is typically the first line title) as the
-'Title' of the post, and store it with the first key in @title_headers
+'Title' of the post, and store it with the first key in 'title_headers'
(default is 'Title'). L<metamail> supports the title being anywhere in
the headers, and will report it properly to blosxom, but any plugins
that look directly at the post file may still expect the title
# Author(s): Gavin Carr <gavin@openfusion.com.au>
# (based on work by Frank Hecker <hecker@hecker.org>
# and Bob Schumaker <cobblers@pobox.com>)
-# Version: 0.002000
+# Version: 0.003000
# Documentation: See the bottom of this file or type: perldoc storydate
package storydate;
use strict;
+use vars qw(%config);
use File::stat;
# Uncomment next line to enable debug output (don't uncomment debug() lines)
# --- Configuration variables -----
+%config = ();
+
# Perl modules to use for strftime, in search order
-my @strftime_modules = qw(Time::Piece Date::Format POSIX);
+$config{strftime_modules} = [ qw(Time::Piece Date::Format POSIX) ];
# ---------------------------------
# __END_CONFIG__
return $date;
}
-# strftime wrapper, using the first strftime() it finds in @strftime_modules
+# strftime wrapper, using the first strftime() it finds in 'strftime_modules'
my %cache = ();
my $strftime_module = '';
sub strftime {
# Search for a strftime module, and load
if (! $strftime_module) {
- for my $module (@strftime_modules) {
+ for my $module (@{$config{strftime_modules}}) {
if (eval "require $module") {
$strftime_module = $module;
# debug(2, "strftime_module: $strftime_module");
# Blosxom Plugin: storytags
# Author(s): Gavin Carr <gavin@openfusion.com.au>
-# Version: 0.002000
+# Version: 0.003000
# Documentation: See the bottom of this file or type: perldoc storytags
# Requires: tags
# Follows: tags
# Uncomment next line to enable debug output (don't uncomment debug() lines)
#use Blosxom::Debug debug_level => 1;
-use vars qw($taglist @taglist);
+use vars qw(%config $taglist @taglist);
# --- Configuration variables -----
+%config = ();
+
# Formatting strings
-my $prefix = 'Tags: ';
-my $suffix = '. ';
+$config{prefix} = 'Tags: ';
+$config{suffix} = '. ';
# ---------------------------------
# __END_CONFIG__
sub _format_taglist {
my ($tags) = @_;
return '' unless @$tags;
- return $prefix
+ return $config{prefix}
. join(', ',
map { qq(<a href="$blosxom::url/tags/$_" rel="tag">$_</a>) }
@$tags
)
- . $suffix;
+ . $config{suffix};
}
1;
L<storytags> 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
-$storytags::prefix, and suffixed by $storytags::suffix. If no tags are
+$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 '. '
+The default values for 'prefix' and 'suffix' are 'Tags: ' and '. '
respectively, so a typical $taglist might look like:
Tags: dogs, cats, pets.
# Blosxom Plugin: tags
# Author(s): Gavin Carr <gavin@openfusion.com.au>
-# Version: 0.001000
+# Version: 0.002000
# Documentation: See the bottom of this file or type: perldoc tags
package tags;
# Uncomment next line to enable debug output (don't uncomment debug() lines)
#use Blosxom::Debug debug_level => 2;
-use vars qw($tagroot $tag_cache $tag_entries $tag_counts);
+use vars qw(%config $tag_cache $tag_entries $tag_counts);
# --- Configuration variables -----
+%config = ();
+
# What path prefix is used for tag-based queries?
-$tagroot = "/tags";
+$config{tagroot} = "/tags";
# What story header to you use for your tags?
-my $tag_header = 'Tags';
+$config{tag_header} = 'Tags';
# Where is our $tag_cache file?
-my $tag_cache_file = "$blosxom::plugin_state_dir/tag_cache";
+$config{tag_cache_file} = "$blosxom::plugin_state_dir/tag_cache";
# ---------------------------------
# __END_CONFIG__
sub start {
# Load tag_cache
- if (-f $tag_cache_file) {
- my $fh = FileHandle->new( $tag_cache_file, 'r' )
+ if (-f $config{tag_cache_file}) {
+ my $fh = FileHandle->new( $config{tag_cache_file}, 'r' )
or warn "[tags] cannot open cache: $!";
{
local $/ = undef;
my $path_info = "/$blosxom::path_info";
# debug(3, "entries, path_info $path_info");
- if ($path_info =~ m!^$tagroot/(.*)!) {
+ if ($path_info =~ m!^$config{tagroot}/(.*)!) {
$blosxom::flavour = '';
my $taglist = $1;
# debug(3, "entries, path_info matches tagroot (taglist $taglist)");
@path_tags = split /\s*,\s*/, $taglist;
$path_tags_op = ',';
}
- # If $path_info matches $tagroot it's a virtual path, so reset
+ # If $path_info matches tagroot it's a virtual path, so reset
$blosxom::path_info = '';
$blosxom::flavour ||= $blosxom::default_flavour;
}
}
# mtime has changed (or story is new) - compare old and new tagsets
- my $tags_new = $blosxom::meta{$tag_header};
+ my $tags_new = $blosxom::meta{$config{tag_header}};
my $tags_old = $tag_cache->{"$path/$filename"}->{tags};
# debug(2, "tags_new: $tags_new, tags_old: $tags_old");
}
}
- # Save tag caches back to $tag_cache_file
- my $fh = FileHandle->new( $tag_cache_file, 'w' )
- or warn "[tags] cannot open cache '$tag_cache_file': $!"
+ # Save tag caches back to $config{tag_cache_file}
+ my $fh = FileHandle->new( $config{tag_cache_file}, 'w' )
+ or warn "[tags] cannot open cache '$config{tag_cache_file}': $!"
and return 0;
print $fh Data::Dumper->Dump([ $tag_cache, $tag_entries, $tag_counts ],
[ qw(tag_cache tag_entries tag_counts) ]);
L<tags> is a blosxom plugin to read tags from story files, maintain a tag
cache, and allow tag-based filtering.
-Tags are defined in a comma-separated list in a $tag_header header at the
-beginning of a blosxom post, with $tag_header defaulting to 'Tags'. So for
-example, your post might look like:
+Tags are defined in a comma-separated list in a $config{tag_header} header
+at the beginning of a blosxom post, with $tag_header defaulting to 'Tags'.
+So for example, your post might look like:
My Post Title
Tags: dogs, cats, pets
Post text goes here ...
L<tags> uses the L<metamail> plugin to parse story headers, and stores
-the tags in a cache (in $tag_cache_file, which defaults to
+the tags in a cache (in $config{tag_cache_file}, which defaults to
$blosxom::plugin_state_dir/tag_cache). The tag cache is only updated
when the mtime of the story file changes, so L<tags> should perform
pretty well.
L<tags> also supports tag-based filtering. If the blosxom $path_info
-begins with $tagroot ('/tags', by default, e.g. '/tags/dogs'), then
-L<tags> filters the entries list to include only posts with the
+begins with $config{tagroot} ('/tags', by default, e.g. '/tags/dogs'),
+then L<tags> filters the entries list to include only posts with the
specified tag. The following syntaxes are supported (assuming the
-default '/tags' for $tagroot):
+default '/tags' for 'tagroot'):
=over 4