X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=general%2Fzlocaldepth;fp=general%2Fzlocaldepth;h=79eb74378a6cb383a7ae84960a50cf0a70e95c01;hb=bdbd50ac8c30082886b3f29e88bfdeb8f088dee6;hp=0000000000000000000000000000000000000000;hpb=eeb750d0481d0cb8e27a7ccef3d39254306e7ce4;p=matthijs%2Fupstream%2Fblosxom-plugins.git diff --git a/general/zlocaldepth b/general/zlocaldepth new file mode 100644 index 0000000..79eb743 --- /dev/null +++ b/general/zlocaldepth @@ -0,0 +1,68 @@ +# Blosxom Plugin: zlocaldepth +# Author: Fletcher T. Penney +# Version: 0.3 + +package zlocaldepth; + +$localdepth = 0; + +sub start { + 1; +} + +sub filter { + my ($pkg, $files) = @_; + + if ($localdepth ne 0) { + @files_list = sort keys %$files; + + $myroot = $blosxom::datadir ."/" . $blosxom::path_info; + $myroot =~ s/\/$//; + $myroot =~ s/\/[^\/]+\.[^\/]+$//; + + foreach (@files_list) { + if ($_ !~ /$myroot([^\/]*\/[^\/]*){0,$localdepth}$/) { + delete $files->{$_}; + } + } + } + +1; +} + + +1; + + +__END__ + +=head1 NAME + +Blosxom Plug-in: zlocaldepth + +=head1 DESCRIPTION + +This plugin restricts entries to those within the $zlocaldepth::localdepth variable, which works just like blosxom's $depth variable. Except that it is always calculated relative to the current directory. This is useful, because unlike the built-in depth variable, it can be appropriately set from a config file via the config plugin to easily allow different depths in different parts of your site. + + +BTW, the name starts with a z so that it will follow other plugins that affect +filters and abide by their settings. + +=head1 AUTHOR + +Fletcher T. Penney - http://fletcher.freeshell.org + +=head1 VERSION HISTORY + +=item 0.2 + +Corrected an issue with a depth of 1 and the root directory. + +=head1 LICENSE + +This source is submitted to the public domain. Feel free to use and modify +it. If you like, a comment in your modified source attributing credit to +myself for my work would be appreciated. + +THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY OF ANY KIND. USE AT +YOUR OWN RISK!