tagging: Allow using titles in for related stories.
[matthijs/upstream/blosxom-plugins.git] / general / flavourdir
1 # Blosxom Plugin: flavourdir
2 # Author(s): Rael Dornfest <rael@oreilly.com> 
3 # Version: 2003-03-13
4 # Documentation: See the bottom of this file or type: perldoc flavourdir
5
6 package flavourdir;
7
8 # --- Configurable variables -----
9
10 # Where might I find your flavours?
11 my $flavour_dir = "$blosxom::datadir/flavours";
12
13 # Should I fall back to looking in your Blosxom datadir before using the 
14 # default built-in templates?
15 # 0 = no; 1 = yes
16 my $fallback_to_datadir = 0;
17
18 # --------------------------------
19
20 use FileHandle;
21 my $fh = new FileHandle;
22
23 sub start {
24   1;
25 }
26
27 sub template {
28   return sub {
29     my ($path, $chunk, $flavour) = @_;
30     
31     $path =~ s!^/*!!; $path = "/$path";
32
33     my $p = $path;
34     do {
35       return join '', <$fh> if $fh->open("< $flavour_dir/$p/$chunk.$flavour");
36     } while ($p =~ s/(\/*[^\/]*)$// and $1);
37
38     $p = $path;
39     $fallback_to_datadir and do {
40       return join '', <$fh> if $fh->open("< $blosxom::datadir/$p/$chunk.$flavour");
41     } while ($p =~ s/(\/*[^\/]*)$// and $1);
42
43     return join '', ($blosxom::template{$flavour}{$chunk} || $blosxom::template{error}{$chunk} || '');
44   };
45 }
46   
47 1;
48
49 __END__
50
51 =head1 NAME
52
53 Blosxom Plug-in: flavourdir
54
55 =head1 SYNOPSIS
56
57 Keep your flavours in a separate flavour directory rather than alongside all of your weblog entries.  Optionally falls back to the default of looking in your Blosxom datadir.
58
59 Overrides Blosxom's default template() subroutine.
60
61 Respects the Blosxom concept of finding flavours along specific paths, expecting to find these paths echoed in your flavour directory.
62
63 =head1 INSTALLATION AND CONFIGURATION
64
65 Drop the flavourdir plug-in into your Blosxom plugins folder.
66
67 The plug-in is preconfigured to assume a flavour directory beneath your Blosxom data directory.  Alter the $flavour_dir configurable variable to move it elsewhere.
68
69 If you'd like the plug-in to fall back to looking in your Blosxom data directory if it doesn't find the appropriate flavour in your flavour directory, set the $fallback_to_datadir configurable variable to 1.  Note: This results in additional processing and isn't a particularly efficient use of a plug-in's time.
70
71 =head1 VERSION
72
73 2003-03-13
74
75 =head1 AUTHOR
76
77 Rael Dornfest  <rael@oreilly.com>, http://www.raelity.org/
78
79 This plugin is now maintained by the Blosxom Sourceforge Team,
80 <blosxom-devel@lists.sourceforge.net>.
81
82 =head1 SEE ALSO
83
84 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
85
86 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
87
88 =head1 BUGS
89
90 None known; please send bug reports and feedback to the Blosxom
91 development mailing list <blosxom-devel@lists.sourceforge.net>.
92
93 =head1 LICENSE
94
95 Blosxom and this Blosxom Plug-in
96 Copyright 2003, Rael Dornfest 
97
98 Permission is hereby granted, free of charge, to any person obtaining a
99 copy of this software and associated documentation files (the "Software"),
100 to deal in the Software without restriction, including without limitation
101 the rights to use, copy, modify, merge, publish, distribute, sublicense,
102 and/or sell copies of the Software, and to permit persons to whom the
103 Software is furnished to do so, subject to the following conditions:
104
105 The above copyright notice and this permission notice shall be included
106 in all copies or substantial portions of the Software.
107
108 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
109 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
110 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
111 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
112 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
113 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
114 OTHER DEALINGS IN THE SOFTWARE.