# Blosxom Plugin: categories # Author: Todd Larason (jtl@molehill.org) # Version: 1.1 # Blosxom Home/Docs/Licensing: http://www.blosxom.com/ # This plugin is simplified version of "categories" plugin. # "categories" plugin maybe found at: # http://www.blosxom.com/plugins/category/categories.htm package categories; use strict; use vars qw($categories $title $name); # --- Configuration Variables ---------- # should the story-count add up? my $add_up_story_count = 1; # should the story-count display? my $display_story_count = 0; # directories to include, but not children of -- full name under $datadir my @prune_dirs = qw!/draft /old /freeze!; # friendly name of directories my %friendly_name = ( 'alt-shell' => 'Alternative Shell', 'blog' => 'blog', 'blosxom' => 'blosxom', 'coding' => 'Coding', 'foaf' => 'FOAF', 'gadget' => 'Gadget', 'game' => 'Game', 'internet' => 'Internet', 'media' => 'Media', 'misc' => 'Misc', 'rss' => 'RSS', 'software' => 'Software', 'sports' => 'Sports', 'webdesign' => 'Web Design', ); # separator string between $blog_title and $categories::name my $title_sep = " - "; # separater string between each name of category my $name_sep = " » "; # --- Plug-in package variables -------- my %children; my %stories; my %seen; # -------------------------------------- sub start { return 1; } sub filter { my($pkg, $files) = @_; foreach (keys %$files) { my($dir, $file) = m!(.*)/(.*)!; my $child; $stories{$dir}++; while ($dir ne $blosxom::datadir) { ($dir, $child) = ($dir =~ m!(.*)/(.*)!); $stories{$dir}++ if $add_up_story_count; if (!$seen{"$dir/$child"}++) { push @{$children{$dir}}, $child; } } } $categories = report_root(); return 1; } sub head { if (!$blosxom::path_info_yr and $blosxom::path_info and ($blosxom::path_info !~ m|.*?/?\w+\.\w+$|)) { $title = ''; my @path_info = split(/\//, $blosxom::path_info); foreach (@path_info) { next if !$_; $_ = %friendly_name->{$_} if %friendly_name->{$_}; $title .= qq!$name_sep$_!; } } $title =~ s!^$name_sep!$title_sep!; return 1; } sub story { my($pkg, $path, $fn, $story_ref, $title_ref, $body_ref) = @_; $name = ''; my @name = split(/\//, $path); foreach (@name) { next if !$_; $_ = %friendly_name->{$_} if %friendly_name->{$_}; $name .= qq!$name_sep$_!; } $name =~ s!^$name_sep!!; return 1; } sub report_root { my $results = report_categories_start(); # $results .= report_dir_start('', 'all entries', $stories{$blosxom::datadir}); foreach (sort @{$children{$blosxom::datadir}}) { $results .= report_dir('/', $_); } # $results .= report_dir_end(); $results .= report_categories_end(); return $results; } sub report_categories_start { return qq!