Add a bunch of Rael plugins.
[blosxom-plugins.git] / general / postheadprefoot
blobea82725720b57898b876f5a6e4cee0194a3ec72a
1 # Blosxom Plugin: postheadprefoot
2 # Author(s): Rael Dornfest <rael@oreilly.com> 
3 # Version: 2.0b4-5
4 # Documentation: See the bottom of this file or type: perldoc postheadprefoot
6 package postheadprefoot;
8 # --- Configurable variables -----
10 # How should I decorate my posthead, if at all?
11 # A dressed up version might look like: 
12 # my $posthead = '<span class="head">$posthead</span>';
13 # The default is plain and simple:
14 my $posthead = '$posthead';
16 # How should I decorate my prefoot, if at all?
17 # A dressed up version might look like: 
18 # my $prefoot = '<span class="foot">$prefoot</span>';
19 # The default is plain and simple:
20 my $prefoot = '$prefoot';
22 # --------------------------------
24 use FileHandle;
26 my $fh = new FileHandle;
28 sub start {
29   1;
32 sub head {
33   my($pkg, $path, $head_ref) = @_;
34   
35   $posthead =~ s!\$posthead!load($path, 'posthead')!eis;
36   $$head_ref .= $posthead;
37   
38   1;
41 sub foot {
42   my($pkg, $path, $foot_ref) = @_;
43   
44   $prefoot =~ s!\$prefoot!load($path, 'prefoot')!eis;
45   $$foot_ref = $prefoot . $$foot_ref;
46   
47   1;
50 sub load { 
51   my($path, $chunk) = @_;
53   my($path,$fn) = $path =~ m!^(?:(.*)/)?(.*)\.$blosxom::flavour!;
55   $path =~ s!^/*!!; $path &&= "/$path";
57   do {
58     $fh->open("< $blosxom::datadir$path/$chunk") || $fh->open("< $blosxom::datadir$path/$chunk.$blosxom::flavour") and return join '', <$fh>;
59   } while ($path =~ s/(\/*[^\/]*)$// and $1);
65 __END__
67 =head1 NAME
69 Blosxom Plug-in: postheadprefoot
71 =head1 SYNOPSIS
73 Appends the contents of any posthead.flavour (specific to a particular flavour) 
74 or posthead (general, regardless of flavour) file found along a particular 
75 category path/directory to the head.flavour.
77 Prepends the contents of any prefoot.flavour (specific to a particular flavour) 
78 or prefoot (general, regardless of flavour) file found along a particular 
79 category path/directory to the foot.flavour.
81 In both cases, the plug-in prefers the posthead or prefoot  found closest to 
82 the point of the path at hand.  Also, preference is given to the flavour
83 specific versus general version.
85 =head1 VERSION
87 2.0b4-5
89 Version number coincides with the version of Blosxom with which the 
90 current version was first bundled.
92 =head1 AUTHOR
94 Rael Dornfest  <rael@oreilly.com>, http://www.raelity.org/
96 =head1 INSTALLATION
98 Drop into your Blosxom plug-in directory ($plugin_dir).
100 Optionally, you can gussie up the included posthead or prefoot
101 by altering the $posthead and $prefoot variables in the 
102 Configurable Variables section.  Just be sure to include 
103 $posthead and $prefoot where the respective includes should go.
105 =head1 SEE ALSO
107 Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/
109 Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml
111 =head1 BUGS
113 Address bug reports and comments to the Blosxom mailing list 
114 [http://www.yahoogroups.com/group/blosxom].
116 =head1 LICENSE
118 Blosxom and this Blosxom Plug-in
119 Copyright 2003, Rael Dornfest 
121 Permission is hereby granted, free of charge, to any person obtaining a
122 copy of this software and associated documentation files (the "Software"),
123 to deal in the Software without restriction, including without limitation
124 the rights to use, copy, modify, merge, publish, distribute, sublicense,
125 and/or sell copies of the Software, and to permit persons to whom the
126 Software is furnished to do so, subject to the following conditions:
128 The above copyright notice and this permission notice shall be included
129 in all copies or substantial portions of the Software.
131 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
132 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
133 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
134 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
135 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
136 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
137 OTHER DEALINGS IN THE SOFTWARE.