tagging: Allow using titles in for related stories.
[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 CONFIGURATION
64
65 C<$ign_file> name to use for hide files. Defaults to
66 C<hide>.
67
68 =head1 EXAMPLE
69
70 Your C<hide> should look like this:
71
72 apps/
73 life/about.txt
74
75 One entry per line. You should be able to use regexes.  Works just like exclude in this regard.
76
77 =head1 BUGS
78
79 None known; please send bug reports and feedback to the Blosxom
80 development mailing list <blosxom-devel@lists.sourceforge.net>.
81
82 =head1 AUTHOR
83
84 Fletcher T. Penney, http://fletcher.freeshell.org
85
86 This plugin is now maintained by the Blosxom Sourceforge Team,
87 <blosxom-devel@lists.sourceforge.net>.
88
89 =head1 LICENSE
90
91 original exclude Blosxom Plug-in
92 Copyright 2003, Breyten Ernsting
93
94 (This license is the same as Blosxom's)
95
96 Permission is hereby granted, free of charge, to any person obtaining a
97 copy of this software and associated documentation files (the "Software"),
98 to deal in the Software without restriction, including without limitation
99 the rights to use, copy, modify, merge, publish, distribute, sublicense,
100 and/or sell copies of the Software, and to permit persons to whom the
101 Software is furnished to do so, subject to the following conditions:
102
103 The above copyright notice and this permission notice shall be included
104 in all copies or substantial portions of the Software.
105
106 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
107 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
108 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
109 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
110 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
111 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
112 OTHER DEALINGS IN THE SOFTWARE.