tagging: Allow using titles in for related stories.
[matthijs/upstream/blosxom-plugins.git] / xtaran / multcat
1 # -*- perl -*-
2 # Blosxom Plugin: multcat
3 # Author(s): Axel Beckert <blosxom@deuxchevaux.org>
4 # Version: 0.01
5 # Licensing: GPL v2 or newer, http://www.gnu.org/licenses/gpl.txt
6 # multcat web page: http://noone.org/blosxom/multcat
7 # Blosxom web page: http://www.blosxom.com/
8
9 ### Documentation:
10 #
11 # This is a plugin for blosxom.
12 #
13 # Installation:
14 #
15 #  Just drop it into your blosxoms plugin directory and it should start
16 #  working. It needs a symbolic link supporting operating system, so it
17 #  may not work under Windows. Unices should work fine, if you don't do
18 #  ugly things with file systems. ;-)
19
20 # What it does:
21 #
22 #  It allows to have postings in multiple categories without having
23 #  them multiple times on the main page or any category's page which
24 #  includes at least two categories, the posting appears in. Designed
25 #  to work together with categorytree, which still counts all
26 #  occurrences of a posting.
27 #
28 # Plugin Order:
29 #
30 #  If you change the plugin order and have the categorytree plugin
31 #  installed, it must come before multcat to work as intended.
32 #
33 #  If you have the moreentries plugin installed, you may change it's
34 #  position in the plugin order to run after multcat.
35 #
36 # Version History:
37 #
38 #  0.01: Initial release
39 #
40
41 package multcat;
42
43 use File::Basename;
44
45 sub start { 1; }
46
47 sub filter {
48     my ($pkg, $files_ref) = @_;
49
50     my @keys = 
51         #grep { m(^$blosxom::datadir/?$blosxom::path_info) }
52         keys %$files_ref;
53     my %localfiles = ();
54     my %debug = ();
55     my %debug2 = ();
56     my %debug3 = ();
57
58     foreach (@keys) {
59         $localfiles{$_} = $files_ref->{$_} if m(/$blosxom::path_info);
60     }
61
62     foreach my $key ( @keys ) {
63         if (-l $key) {
64             my $dest = readlink($key);
65             $debug{$key} = 
66             $dest = dirname($key)."/$dest";
67             while ($dest =~ m(/../)) {
68                 $dest =~ s(/[^/]+/\.\./)(/);
69             }
70             $debug2{$key} = $dest;
71
72             $debug3{$key} = 
73             my $destdate = $localfiles{$dest};
74
75             # The found symlink is not a story which is to be
76             # displayed, so we don't need to extinct it from the
77             # website
78             next unless $destdate;
79             
80             delete($files_ref->{$key});
81         }
82     }
83
84     use Data::Dumper;
85     $debug = Dumper $blosxom::path_info, $files_ref, \@keys, \%localfiles, \%debug, \%debug2, \%debug3;
86
87     1;
88 }
89
90 1;