Add a bunch of Rael plugins.
[matthijs/upstream/blosxom-plugins.git] / general / postheadprefoot
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
5
6 package postheadprefoot;
7
8 # --- Configurable variables -----
9
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';
15
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';
21
22 # --------------------------------
23
24 use FileHandle;
25
26 my $fh = new FileHandle;
27
28 sub start {
29   1;
30 }
31
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;
39 }
40
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;
48 }
49  
50 sub load { 
51   my($path, $chunk) = @_;
52
53   my($path,$fn) = $path =~ m!^(?:(.*)/)?(.*)\.$blosxom::flavour!;
54
55   $path =~ s!^/*!!; $path &&= "/$path";
56
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);
60
61 }
62
63 1;
64
65 __END__
66
67 =head1 NAME
68
69 Blosxom Plug-in: postheadprefoot
70
71 =head1 SYNOPSIS
72
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.
76
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.
80
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.
84
85 =head1 VERSION
86
87 2.0b4-5
88
89 Version number coincides with the version of Blosxom with which the 
90 current version was first bundled.
91
92 =head1 AUTHOR
93
94 Rael Dornfest  <rael@oreilly.com>, http://www.raelity.org/
95
96 =head1 INSTALLATION
97
98 Drop into your Blosxom plug-in directory ($plugin_dir).
99
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.
104
105 =head1 SEE ALSO
106
107 Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/
108
109 Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml
110
111 =head1 BUGS
112
113 Address bug reports and comments to the Blosxom mailing list 
114 [http://www.yahoogroups.com/group/blosxom].
115
116 =head1 LICENSE
117
118 Blosxom and this Blosxom Plug-in
119 Copyright 2003, Rael Dornfest 
120
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:
127
128 The above copyright notice and this permission notice shall be included
129 in all copies or substantial portions of the Software.
130
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.