Add Fletcher Penney plugins to general.
[matthijs/upstream/blosxom-plugins.git] / general / hide
diff --git a/general/hide b/general/hide
new file mode 100644 (file)
index 0000000..cb7c3ea
--- /dev/null
@@ -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 (<EXCLUDE>) {
+    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<hide>.
+
+=head1 EXAMPLE
+
+Your C<hide> 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.