X-Git-Url: https://git.stderr.nl/gitweb?p=matthijs%2Fupstream%2Fblosxom-plugins.git;a=blobdiff_plain;f=general%2Fbreadcrumbs;h=bc7b3029a61a8d4fe32c6715df22c07de0bf68c7;hp=1709cead80e4abc8be3e05cf40c1a7c6d518fe00;hb=68040af8c0303fec24d9409a2990f5bede66bd72;hpb=be5ad6fe0a7af437f3f26394a792d2e1020a8108 diff --git a/general/breadcrumbs b/general/breadcrumbs index 1709cea..bc7b302 100644 --- a/general/breadcrumbs +++ b/general/breadcrumbs @@ -16,6 +16,21 @@ my $home = 'home'; # What divider should I use between path components (e.g. a > path > to...) my $divider = " :: "; +# True or false: should we show a breadcrumb containing only $home +# when looking at $blosxom::url? Optional; default is false. +my $home_breadcrumb = 0; + +# Code reference which is applied to each path name to make it more +# user friendly. Example : { ucfirst } to capitalize first letter. +# Value to modify is in $_; change $_ to what should be displayed. +# Optional; set to undef for no action. +# +# Example: Convert each word to upper case, and change - or _ to space: +# my $pretty = sub { my @words = split /[-_]+/; +# $_=join(" ", map { ucfirst} @words ) }; +my $pretty = sub { my @words = split /[-_]+/; + $_=join(" ", map { ucfirst} @words ) }; + # -------------------------------- $breadcrumbs; # use as $breadcrumbs::breadcrumbs in flavour templates @@ -31,7 +46,11 @@ sub start { sub head { my($pkg, $path, $head_ref) = @_; - $path or return 0; + unless($path) { + $breadcrumbs = $home if $home && $home_breadcrumb; + return 0; + } + $path =~ s/\.$blosxom::flavour$//; my(@p, $p); @@ -40,7 +59,8 @@ sub head { foreach ( split /\//, $path ) { $p .= "/$_"; - push @p, + &$pretty if ref $pretty eq "CODE"; + push @p, $p ne "/$path" ? qq{$_} : qq{$_};