tagging: Allow using titles in for related stories.
[matthijs/upstream/blosxom-plugins.git] / general / iconset
1 # Bloxsom Plugin:IconSet
2 # Author: Fletcher T. Penney
3 # Version: 0.2
4
5 package iconset;
6
7 # --- Configurable variables ----
8
9 # Where are your icon image files?
10 $logos_url = "/images";
11
12 # Where is the icon definition page
13 # Note that this is optional
14 $icon_file = "$blosxom::datadir/iconlist";
15
16 # Is the icons plugin enabled
17 $use_icons_plugin = 1;
18
19 # -------------------------------
20
21 $iconset="";
22
23 sub start {
24         open (ICONS, $icon_file);
25         @iconslist = <ICONS>;
26         close ICONS;
27 1;
28 }
29
30 sub story {
31         my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
32
33         $iconset = "";
34         foreach $iconpair (@iconslist) {
35                 if ($iconpair =~ /(.*)=(.*)/) {
36                         $categ=$1;
37                         $icon=$2;
38                 $iconset= qq!<img src="$logos_url/$icon" alt="logo">! if ($path =~ /^$categ/i);
39                 }
40         }
41
42         if ($$body_ref =~ /<!-- iconset\s*(\S*)\s*-->/i) {
43                 $iconset= qq!<img src="$logos_url/$1" alt="logo">! if $1 ne"";
44         }
45
46         if ($use_icons_plugin eq 1) {
47                 $icons::icons = $iconset if ($iconset ne "");
48         }
49
50         1;
51 }
52
53 1;
54
55
56 __END__
57
58 =head1 NAME
59
60 Blosxom Plug-in: iconset
61
62 =head1 DESCRIPTION
63
64 IconSet allows you to set an icon to be used within a particular story.  Set the $logos_url to the url for your icons.  You then use the <!-- iconset ### --> directive within a story to set an icon to be displayed for that story.  If a default icon is set by the icons plug-in, it will be overridden.
65
66 If the icons plugin is present, then you may continue to use the $icons::icons variable.  Otherwise, you can use the $iconset::iconset variable.
67
68 The $icon_file allows you to set an icon for any story in a category by using a definitions file.  This allows you to set an icon for any category, whether it is top level or not, without having a world readable datadir.  (The original icons plugin cannot do this.)
69
70 The format for iconfile is:
71 path=iconfile
72
73 and uses regexp's for either expression. So, 
74 /computers/blosxom=blosxom.gif will set the icon to blosxom.gif for any file in the computers/blosxom directory, or any of its subdirectories.
75
76 If you later defined:
77 /computers/blosxom/newstuff=cool.png, then anything in this one subdirectory will have a different icon.  The line that matches last is the one that "sticks."
78
79 By using this technique, you can replace the icons plugin altogether by replacing $iconset::iconset in your templates wherever you used to use $icons::icons.  If you do this, then change the $use_icons_plugin variable.
80
81 =head1 BUGS
82
83 None known; please send bug reports and feedback to the Blosxom
84 development mailing list <blosxom-devel@lists.sourceforge.net>.
85
86 =head1 AUTHOR
87
88 Fletcher T. Penney - http://fletcher.freeshell.org
89
90 This plugin is now maintained by the Blosxom Sourceforge Team,
91 <blosxom-devel@lists.sourceforge.net>.
92
93 =head1 LICENSE
94
95 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 and Gregory Bair for his original work would be appreciated.
96
97 THIS SOFTWARE IS PROVIDED AS IS AND WITHOUT ANY WARRANTY OF ANY KIND.  USE AT YOUR OWN RISK!