tagging: Allow using titles in for related stories.
[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 This plugin is now maintained by the Blosxom Sourceforge Team,
97 <blosxom-devel@lists.sourceforge.net>.
98
99 =head1 INSTALLATION
100
101 Drop into your Blosxom plug-in directory ($plugin_dir).
102
103 Optionally, you can gussie up the included posthead or prefoot
104 by altering the $posthead and $prefoot variables in the 
105 Configurable Variables section.  Just be sure to include 
106 $posthead and $prefoot where the respective includes should go.
107
108 =head1 SEE ALSO
109
110 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
111
112 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
113
114 =head1 BUGS
115
116 None known; please send bug reports and feedback to the Blosxom
117 development mailing list <blosxom-devel@lists.sourceforge.net>.
118
119 =head1 LICENSE
120
121 Blosxom and this Blosxom Plug-in
122 Copyright 2003, Rael Dornfest 
123
124 Permission is hereby granted, free of charge, to any person obtaining a
125 copy of this software and associated documentation files (the "Software"),
126 to deal in the Software without restriction, including without limitation
127 the rights to use, copy, modify, merge, publish, distribute, sublicense,
128 and/or sell copies of the Software, and to permit persons to whom the
129 Software is furnished to do so, subject to the following conditions:
130
131 The above copyright notice and this permission notice shall be included
132 in all copies or substantial portions of the Software.
133
134 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
135 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
136 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
137 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
138 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
139 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
140 OTHER DEALINGS IN THE SOFTWARE.