Add various plugins from Mark Ivey.
[matthijs/upstream/blosxom-plugins.git] / general / fullcategory
1 # Blosxom Plugin: fullcategory
2 # Author(s): Mark Ivey <zovirl@zovirl.com>
3 # Version: 0.0.2
4 # Documentation: See the bottom of this file or type: perldoc fullcategory
5
6 package fullcategory;
7
8 # --- Configurable variables -----
9
10 # --------------------------------
11
12 # print debug messages or not?
13 my $debug = 1;
14
15 sub start 
16 {
17     return 1;
18 }
19
20 sub filter 
21 {
22     my($pkg, $files_ref) = @_;
23     
24     my $path = "$blosxom::datadir/$blosxom::path_info";
25     
26     # if there is a flavor, this is a story and we don't have to help blosxom
27     return if ($path =~ m!\.[^/]*?$!); 
28     
29     # the / on the end of $path is what prevents partial matches
30     $path .= "/";
31     $path =~ s!//$!/!;  # remove extra trailing /'s 
32
33     warn "fullcategory: path is [$path]\n" if $debug >= 1; 
34     
35     foreach my $file (keys %$files_ref)
36     {
37         my $string = "fullcategory: checking file [$file]: ";
38         unless ($file =~ m!^$path!)
39         {
40             delete $files_ref->{$file};
41             $string .= "deleted\n";
42         }
43         else
44         {
45             $string .= "kept\n";
46         }
47         warn $string if $debug >= 1;
48         
49     }
50
51     return 1;
52 }
53
54
55 1;
56
57 __END__
58
59 =head1 NAME
60
61 Blosxom Plug-in: fullcategory
62
63 =head1 SYNOPSIS
64
65 Changes blosxom behavior so full category names are required (partial names
66 will no longer work)
67
68 =head1 VERSION
69
70 0.0.2
71
72 =head1 AUTHOR
73
74 Mark Ivey <zovirl@zovirl.com>, http://zovirl.com
75
76 =head1 DESCRIPTION
77
78 fullcategory fixes blosxom so only complete category names will work.
79 By default, blosxom will return results for partial category name matches.
80 For example, if "telephone" is a category, these would all return posts about
81 telephones:
82 http://example.com/telephone
83 http://example.com/telepho
84 http://example.com/tele
85
86 (If "television" was also a category, that last example would include
87 posts from both the television & telephone categories)
88
89 =head1 SEE ALSO
90
91 Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/
92
93 Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml
94
95 parsedate() taken from Fletcher T. Penney's entriescache plugin:
96 http://www.blosxom.com/plugins/indexing/entries_cache.htm
97
98 =head1 BUGS
99
100 Address bug reports and comments to the Blosxom mailing list 
101 [http://www.yahoogroups.com/group/blosxom].
102
103 =head1 LICENSE
104
105 fullcategory Blosxom Plugin Copyright 2004, Mark Ivey
106
107 Permission is hereby granted, free of charge, to any person obtaining a
108 copy of this software and associated documentation files (the "Software"),
109 to deal in the Software without restriction, including without limitation
110 the rights to use, copy, modify, merge, publish, distribute, sublicense,
111 and/or sell copies of the Software, and to permit persons to whom the
112 Software is furnished to do so, subject to the following conditions:
113
114 The above copyright notice and this permission notice shall be included
115 in all copies or substantial portions of the Software.
116
117 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
118 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
119 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
120 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
121 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
122 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
123 OTHER DEALINGS IN THE SOFTWARE.