Add Fletcher Penney plugins to general.
[matthijs/upstream/blosxom-plugins.git] / general / hide
1 # Blosxom Plugin: hide
2 # Author(s): Fletcher T. Penney http://fletcher.freeshell.org
3 # Version: 0.1
4 # Based on exclude plug-in by Breyten Ernsting
5
6 # Modified version to only hide files when find plugin is not active.
7 # In other words, allow files to be shown when searching, but not browsing...
8
9 package hide;
10
11 # --- Configurable variables -----
12
13 $ign_file = 'hide';
14
15 # --------------------------------
16 use CGI qw/:standard/;
17
18 sub start {
19   $ign_fp = ($blosxom::path_info) ? "$blosxom::datadir/$blosxom::path_info" : "$blosxom::datadir";
20   $ign_ext = (-e "$ign_fp/${ign_file}.${blosxom::flavour}") ? ".${blosxom::flavour}" : "";
21   $ign_fn = "$ign_fp/$ign_file$ign_ext";
22   @excludes = ();
23   open(EXCLUDE, "< $ign_fn") or 1;
24   while (<EXCLUDE>) {
25     chomp;
26     push(@excludes, "$ign_fp/$_") if $_;
27   }
28   close(EXCLUDE);
29   1;
30 }
31
32 sub filter {
33   my ($pkg, $files_ref) = @_;
34   my @files_list = keys %$files_ref;
35
36   return 0 if ((param('plugin') eq 'find') || (param('find')));
37
38   foreach $exclude (@excludes) {
39     foreach $ign_cf (@files_list) {
40       $ign_cf !~ m/^$exclude/ or delete $files_ref->{$ign_cf};
41     }
42   }
43
44   1;
45 }
46
47 1;
48
49
50
51 =head1 NAME
52
53 Blosxom Plug-in: hide
54
55 =head1 SYNOPSIS
56
57 Purpose: Allows you to hide stories and categories from view while browsing, but still allow them to appear in the results of a search via my find plugin
58
59 =head1 VERSION
60
61 0.1
62
63 =head1 AUTHOR
64
65 Fletcher T. Penney
66 http://fletcher.freeshell.org
67
68
69 =head1 CONFIGURATION
70
71 C<$ign_file> name to use for hide files. Defaults to
72 C<hide>.
73
74 =head1 EXAMPLE
75
76 Your C<hide> should look like this:
77
78 apps/
79 life/about.txt
80
81 One entry per line. You should be able to use regexes.  Works just like exclude in this regard.
82
83 =head1 LICENSE
84
85 original exclude Blosxom Plug-in
86 Copyright 2003, Breyten Ernsting
87
88 (This license is the same as Blosxom's)
89
90 Permission is hereby granted, free of charge, to any person obtaining a
91 copy of this software and associated documentation files (the "Software"),
92 to deal in the Software without restriction, including without limitation
93 the rights to use, copy, modify, merge, publish, distribute, sublicense,
94 and/or sell copies of the Software, and to permit persons to whom the
95 Software is furnished to do so, subject to the following conditions:
96
97 The above copyright notice and this permission notice shall be included
98 in all copies or substantial portions of the Software.
99
100 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
101 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
102 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
103 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
104 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
105 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
106 OTHER DEALINGS IN THE SOFTWARE.