X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=general%2Fhide;fp=general%2Fhide;h=cb7c3ea545837bb41261b688cb7b597d767612eb;hb=bdbd50ac8c30082886b3f29e88bfdeb8f088dee6;hp=0000000000000000000000000000000000000000;hpb=eeb750d0481d0cb8e27a7ccef3d39254306e7ce4;p=matthijs%2Fupstream%2Fblosxom-plugins.git diff --git a/general/hide b/general/hide new file mode 100644 index 0000000..cb7c3ea --- /dev/null +++ b/general/hide @@ -0,0 +1,106 @@ +# Blosxom Plugin: hide +# Author(s): Fletcher T. Penney http://fletcher.freeshell.org +# Version: 0.1 +# Based on exclude plug-in by Breyten Ernsting + +# Modified version to only hide files when find plugin is not active. +# In other words, allow files to be shown when searching, but not browsing... + +package hide; + +# --- Configurable variables ----- + +$ign_file = 'hide'; + +# -------------------------------- +use CGI qw/:standard/; + +sub start { + $ign_fp = ($blosxom::path_info) ? "$blosxom::datadir/$blosxom::path_info" : "$blosxom::datadir"; + $ign_ext = (-e "$ign_fp/${ign_file}.${blosxom::flavour}") ? ".${blosxom::flavour}" : ""; + $ign_fn = "$ign_fp/$ign_file$ign_ext"; + @excludes = (); + open(EXCLUDE, "< $ign_fn") or 1; + while () { + chomp; + push(@excludes, "$ign_fp/$_") if $_; + } + close(EXCLUDE); + 1; +} + +sub filter { + my ($pkg, $files_ref) = @_; + my @files_list = keys %$files_ref; + + return 0 if ((param('plugin') eq 'find') || (param('find'))); + + foreach $exclude (@excludes) { + foreach $ign_cf (@files_list) { + $ign_cf !~ m/^$exclude/ or delete $files_ref->{$ign_cf}; + } + } + + 1; +} + +1; + + + +=head1 NAME + +Blosxom Plug-in: hide + +=head1 SYNOPSIS + +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 + +=head1 VERSION + +0.1 + +=head1 AUTHOR + +Fletcher T. Penney +http://fletcher.freeshell.org + + +=head1 CONFIGURATION + +C<$ign_file> name to use for hide files. Defaults to +C. + +=head1 EXAMPLE + +Your C should look like this: + +apps/ +life/about.txt + +One entry per line. You should be able to use regexes. Works just like exclude in this regard. + +=head1 LICENSE + +original exclude Blosxom Plug-in +Copyright 2003, Breyten Ernsting + +(This license is the same as Blosxom's) + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE.