Add Fletcher Penney plugins to general.
[matthijs/upstream/blosxom-plugins.git] / general / zlocaldepth
1 # Blosxom Plugin: zlocaldepth
2 # Author: Fletcher T. Penney
3 # Version: 0.3
4
5 package zlocaldepth;
6
7 $localdepth = 0;
8
9 sub start {
10         1;
11 }
12
13 sub filter {
14         my ($pkg, $files) = @_;
15
16         if ($localdepth ne 0) {
17                 @files_list = sort keys %$files;
18
19                 $myroot = $blosxom::datadir ."/" . $blosxom::path_info;
20                 $myroot =~ s/\/$//;
21                 $myroot =~ s/\/[^\/]+\.[^\/]+$//;
22                 
23                 foreach (@files_list) {
24                         if ($_ !~ /$myroot([^\/]*\/[^\/]*){0,$localdepth}$/) {
25                                 delete $files->{$_};
26                         }
27                 }
28         }
29         
30 1;
31 }
32
33
34 1;
35
36
37 __END__
38
39 =head1 NAME
40
41 Blosxom Plug-in: zlocaldepth
42
43 =head1 DESCRIPTION
44
45 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.
46
47
48 BTW, the name starts with a z so that it will follow other plugins that affect 
49 filters and abide by their settings.
50
51 =head1 AUTHOR
52
53 Fletcher T. Penney - http://fletcher.freeshell.org
54
55 =head1 VERSION HISTORY
56
57 =item 0.2
58
59 Corrected an issue with a depth of 1 and the root directory.
60
61 =head1 LICENSE
62
63 This source is submitted to the public domain.  Feel free to use and modify  
64 it.  If you like, a comment in your modified source attributing credit to 
65 myself for my work would be appreciated.
66
67 THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY OF ANY KIND.  USE AT 
68 YOUR OWN RISK!