1709cead80e4abc8be3e05cf40c1a7c6d518fe00
[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 This plugin is now maintained by the Blosxom Sourceforge Team,
85 <blosxom-devel@lists.sourceforge.net>.
86
87 =head1 SEE ALSO
88
89 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
90
91 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
92
93 =head1 BUGS
94
95 None known; please send bug reports and feedback to the Blosxom
96 development mailing list <blosxom-devel@lists.sourceforge.net>.
97
98 =head1 LICENSE
99
100 Blosxom and this Blosxom Plug-in
101 Copyright 2003, Rael Dornfest 
102
103 Permission is hereby granted, free of charge, to any person obtaining a
104 copy of this software and associated documentation files (the "Software"),
105 to deal in the Software without restriction, including without limitation
106 the rights to use, copy, modify, merge, publish, distribute, sublicense,
107 and/or sell copies of the Software, and to permit persons to whom the
108 Software is furnished to do so, subject to the following conditions:
109
110 The above copyright notice and this permission notice shall be included
111 in all copies or substantial portions of the Software.
112
113 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
114 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
115 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
116 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
117 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
118 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
119 OTHER DEALINGS IN THE SOFTWARE.