Add a bunch of Rael plugins.
[matthijs/upstream/blosxom-plugins.git] / general / breadcrumbs
1 # Blosxom Plugin: breadcrumbs
2 # Author(s): Rael Dornfest <rael@oreilly.com> 
3 # Version: 2003-12-29
4 # Documentation: See the bottom of this file or type: perldoc readme
5
6 package breadcrumbs;
7
8 # --- Configurable variables -----
9
10 # Should I prepend a link back home to the path?
11 # Specify a word to use for the link back to $blosxom::url or leave blank
12 # to exclude it
13
14 my $home = 'home';
15
16 # What divider should I use between path components (e.g. a > path > to...)
17 my $divider = " :: ";
18
19 # --------------------------------
20
21 $breadcrumbs; # use as $breadcrumbs::breadcrumbs in flavour templates
22
23 use FileHandle;
24
25 my $fh = new FileHandle;
26
27 sub start {
28   1;
29 }
30
31 sub head {
32   my($pkg, $path, $head_ref) = @_;
33
34   $path or return 0;
35   $path =~ s/\.$blosxom::flavour$//;
36
37   my(@p, $p);
38   $home and push @p, qq{<a href="$blosxom::url/index.$blosxom::flavour">$home</a>};
39
40   foreach ( split /\//, $path ) {
41     $p .= "/$_";
42
43     push @p, 
44       $p ne "/$path"
45       ? qq{<a href="$blosxom::url$p/index.$blosxom::flavour">$_</a>}
46       : qq{$_};
47   }
48
49   $breadcrumbs = join $divider, @p;
50
51   return 1;
52 }
53
54 1;
55
56 __END__
57
58 =head1 NAME
59
60 Blosxom Plug-in: breadcrumbs
61
62 =head1 SYNOPSIS
63
64 Populates $breadcrumbs::breadcrumbs with a clickable trail to
65 your current path in the weblog hierarchy (a la Yahoo!).
66
67 e.g. a/path/to/somewhere becomes 
68 <a href="/a">a</a> :: <a href="/a/path">path</a> :: ...
69
70 Optionally prepends the path with a link back to home.  Alter $home
71 as you please, leaving it blank to turn off the link to home.
72
73 =head1 VERSION
74
75 2003-12-29
76
77 Version number coincides with the version of Blosxom with which the 
78 current version was first bundled.
79
80 =head1 AUTHOR
81
82 Rael Dornfest  <rael@oreilly.com>, http://www.raelity.org/
83
84 =head1 SEE ALSO
85
86 Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/
87
88 Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml
89
90 =head1 BUGS
91
92 Address bug reports and comments to the Blosxom mailing list 
93 [http://www.yahoogroups.com/group/blosxom].
94
95 =head1 LICENSE
96
97 Blosxom and this Blosxom Plug-in
98 Copyright 2003, Rael Dornfest 
99
100 Permission is hereby granted, free of charge, to any person obtaining a
101 copy of this software and associated documentation files (the "Software"),
102 to deal in the Software without restriction, including without limitation
103 the rights to use, copy, modify, merge, publish, distribute, sublicense,
104 and/or sell copies of the Software, and to permit persons to whom the
105 Software is furnished to do so, subject to the following conditions:
106
107 The above copyright notice and this permission notice shall be included
108 in all copies or substantial portions of the Software.
109
110 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
111 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
112 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
113 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
114 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
115 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
116 OTHER DEALINGS IN THE SOFTWARE.