X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=general%2Fmenu;fp=general%2Fmenu;h=088d6690858c8ad4a1b4e920d184a78fd208bb32;hb=bdbd50ac8c30082886b3f29e88bfdeb8f088dee6;hp=0000000000000000000000000000000000000000;hpb=eeb750d0481d0cb8e27a7ccef3d39254306e7ce4;p=matthijs%2Fupstream%2Fblosxom-plugins.git
diff --git a/general/menu b/general/menu
new file mode 100644
index 0000000..088d669
--- /dev/null
+++ b/general/menu
@@ -0,0 +1,210 @@
+# Blosxom Plugin: menu
+# Author: Fletcher T. Penney
+# Version: 0.5
+# Exclude functions copied from exclude plugin
+
+package menu;
+
+# --- Configurable variables ----
+
+# HTML code to insert before the menu
+$menustart=qq%%;
+
+# These serve the same purpose as above, but for the root menu
+$rootmenustart = $menustart;
+$rootmenuseparator=qq%
%;
+$rootmenuend=$menuend;
+
+$pretty=1; # Enable "prettying" up category names
+
+# -------------------------------
+
+
+$menu = "";
+$rootmenu = "";
+$path_noflavour = "";
+$pretty_path = "";
+
+$ign_file = $exclude::ign_file;
+$hide_file = $hide::ign_file;
+
+sub start {
+ @excludes = ();
+
+ if ($ign_file) {
+ $ign_fp = "$blosxom::datadir";
+ $ign_fn = "$ign_fp/$ign_file";
+ if (open(EXCLUDE, "< $ign_fn")) {
+ while () {
+ chomp;
+ push(@excludes, "$_") if $_;
+ }
+ close(EXCLUDE);
+ }
+ }
+
+ # Now do the same for hide
+ if ($hide_file) {
+ $ign_fp = "$blosxom::datadir";
+ $ign_fn = "$ign_fp/$hide_file";
+ if (open(EXCLUDE, "< $ign_fn")) {
+ while () {
+ chomp;
+ push(@excludes, "$_") if $_;
+ }
+ close(EXCLUDE);
+ }
+ }
+
+ $path_noflavour = $blosxom::path_info;
+ if ($path_noflavour !~ s/\.[^\.]*$//) {
+ $path_noflavour =~ s/\/$//;
+ $path_noflavour .= "\/index";
+ $path_noflavour =~ s/^([^\/])/$1/;
+ }
+ $path_noflavour =~ s/^\/*//;
+ 1;
+}
+
+sub filter {
+ my ($pkg, $files) = @_;
+
+ @files_list = sort keys %$files;
+ @rootlist = @files_list;
+
+ $myroot = $blosxom::datadir ."/" . $blosxom::path_info;
+ $myurl = $blosxom::url ."/" . $blosxom::path_info;
+ $myurl =~ s/\/$//;
+
+ @dirs = ();
+ @rootdirs = ();
+
+ $lastdir="";
+ $lastroot="";
+
+ foreach (@files_list) {
+ if ($_ =~ s/$myroot//) {
+ # These are subdirectories of the current directory
+ $_ =~ s/^\/?([^\/]+)\/.*/$1/;
+ $_ =~ s/\/?[^\/]+\.txt//;
+ if ($_ and ($lastdir ne $_)) {
+ $lastdir=$_;
+ push(@dirs,$_);
+ }
+ }
+ }
+
+ foreach (@rootlist) {
+ #These are not
+ # $rootmenu.="$_
";
+ if ($_ =~ s/$blosxom::datadir\///) {
+ $_ =~ s/^\/?([^\/]+)\/.*/$1/;
+ $_ =~ s/\/?[^\/]+\.txt//;
+ if ($_ and ($lastroot ne $_)) {
+ $lastroot=$_;
+ push(@rootdirs,$_);
+ }
+ }
+ }
+
+
+ @rootdirs = @dirs if ($blosxom::path_info eq "");
+
+ $menu = $menustart;
+ for ($i=0;$i" . $pretty . "" .$menuseparator;
+ }
+
+ for (;$i" . $pretty . "" ;
+ }
+ $menu.=$menuend;
+
+ $sepholder = "";
+
+ $rootmenu .= $rootmenustart;
+ for ($i=0;$i" . $pretty . "" if $use;
+ }
+
+ $rootmenu.=$rootmenuend;
+
+1;
+}
+
+sub story {
+ my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
+
+ $pretty_path = $path;
+ $pretty_path =~ s/^\/?(.)/\u$1/;
+ $pretty_path =~ s/[_-](.)/ \u$1/g;
+ $pretty_path =~ s/\/(.)/ :: \u$1/g;
+ 1;
+}
+
+sub date {
+ my ($pkg, $date_ref, $mtime, $dw,$mo,$mo_num,$da,$ti,$yr) = @_;
+
+ $pretty_path = $blosxom::path;
+ $pretty_path =~ s/^\/?(.)/\u$1/;
+ $pretty_path =~ s/[_-](.)/ \u$1/g;
+ $pretty_path =~ s/\/(.)/ :: \u$1/g;
+ 1;
+}
+
+1;
+
+
+__END__
+
+=head1 NAME
+
+Blosxom Plug-in: menu
+
+=head1 DESCRIPTION
+
+This creates a menu ($menu::menu)showing the available subdirectories from your current position. A subdirectory, or one of its "descendents" must have a story in it in order to be shown in the menu (ie, it does not lead down "blind alleys"). Additionally, it abides by the excluded sections if the exclude plug-in is enabled.
+
+The default configuration settings at the begin lead to a sort of reversal of the breadcrumbs plug-in.
+
+Additionally, the $menu::rootmenu variable contains the top level directories, regardless of the current page.
+
+=head1 AUTHOR
+
+Fletcher T. Penney - http://fletcher.freeshell.org
+
+
+=head1 LICENSE
+
+This source is submitted to the public domain. Feel free to use and modify it. If you like, a comment in your modified source attributing credit to myself for my work would be appreciated.
+
+THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY OF ANY KIND. USE AT YOUR OWN RISK!
\ No newline at end of file