# Blosxom Plugin: meta_head -*-cperl-*- # Author: Jason Blevins # Documentation: Read below or type "perldoc meta_head". # Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net package meta_head; use Date::Parse; use POSIX qw(strftime); sub start { 1; } sub head { my ($p, $dir, $head) = @_; my $filename; # Is this a proper filename with extension? if ($dir =~ m#(.*?)/?([\-\.\w]+)\.(\w+)$#) { # Construct the complete filename and path $filename = join('/', $blosxom::datadir, $1, "$2.$blosxom::file_extension"); } elsif ($blosxom::plugins{'index_override'} and $index_override::override) { $filename = join('/', $blosxom::datadir, $dir, "$index_override::indexfile.$blosxom::file_extension"); } if (defined $filename) { # For each meta key stored by the entries_cache_meta plugin foreach my $key (keys %{$entries_cache_meta::cache{$filename}}) { # Create a meta_head::$key variable available in the head template ${"$key"} = $entries_cache_meta::cache{$filename}{$key}; if ($key eq 'mtime') { $created_iso = strftime("%Y-%m-%d", (localtime $mtime)[0..5]); } elsif ($key eq 'modified') { $modified_iso = strftime("%Y-%m-%d", (localtime Date::Parse::str2time($modified))[0..5]); } } } } 1; __END__ =head1 NAME Blosxom Plug-in: meta_head =head1 SYNOPSIS This plugin makes meta tags available in head templates. This is useful for including a description, keywords, or dates in your block. The entries_cache_meta plugin is required in order to provide the meta tags. This plugin caches the meta tags in each story in order to avoid repeatedly reading each story file. This plugin is also designed to work with the index_override plugin. To reference metadata in a head template, simply use $meta_head::tag where tag is the corresponding meta variable. In addition to providing all user-defined meta variables, the plugin also automatically generates $meta_head::created_iso (a date of the form YYYY-MM-DD). If there is a meta-modified date tag, a corresponding $meta_head::modified_iso variable is also generated. =head1 VERSION 2007-12-05 =head1 AUTHORS Jason Blevins =head1 BUGS Send bug reports and comments to Jason Blevins . =head1 HISTORY 2007-12-05: Initial revision. =head1 LICENSE Copyright (C) 2007 Jason Blevins 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.