tagging: Allow using titles in for related stories.
[matthijs/upstream/blosxom-plugins.git] / general / meta
1 # Blosxom Plugin: meta
2 # Author(s): Rael Dornfest <rael@oreilly.com> 
3 # Version: 2.0b4
4 # Documentation: See the bottom of this file or type: perldoc readme
5
6 package meta;
7
8 # --- Configurable variables -----
9
10 # What prefix should I expect prepended to each meta tag?
11 my $meta_prefix = 'meta-';
12
13 # --------------------------------
14
15 sub start {
16   1;
17 }
18
19 sub story {
20   my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
21
22   $$_ = undef foreach @keys;
23   @keys = ();
24
25   my($body, $in_header) = ('', 1);
26   foreach ( split /\n/, $$body_ref ) {
27     /^\s*$/ and $in_header = 0 and next;
28     if ( $in_header ) {
29       my($key, $value) = m!^$meta_prefix(.+?)\s*:\s*(.+)$!;
30       $key =~ /^\w+$/ and push(@keys,$key) and $$key = $value and next;
31     }
32     $body .= $_ . "\n";
33   }
34   $$body_ref = $body;
35
36   return 1;
37 }
38
39 1;
40
41 __END__
42
43 =head1 NAME
44
45 Blosxom Plug-in: meta
46
47 =head1 SYNOPSIS
48
49 Purpose: Populates the $meta namespace with variables corresponding to meta tags found in the "header" (anything before a blank line) of a weblog post, removing the meta tags along the way.  These variables are available to plug-ins and flavour templates as $meta::variablename.
50
51 =head1 VERSION
52
53 2.0b4
54
55 Version number coincides with the version of Blosxom with which the 
56 current version was first bundled.
57
58 =head1 AUTHOR
59
60 Rael Dornfest  <rael@oreilly.com>, http://www.raelity.org/
61
62 This plugin is now maintained by the Blosxom Sourceforge Team,
63 <blosxom-devel@lists.sourceforge.net>.
64
65 =head1 SEE ALSO
66
67 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
68
69 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
70
71 =head1 BUGS
72
73 None known; please send bug reports and feedback to the Blosxom
74 development mailing list <blosxom-devel@lists.sourceforge.net>.
75
76 =head1 LICENSE
77
78 Blosxom and this Blosxom Plug-in
79 Copyright 2003, Rael Dornfest 
80
81 Permission is hereby granted, free of charge, to any person obtaining a
82 copy of this software and associated documentation files (the "Software"),
83 to deal in the Software without restriction, including without limitation
84 the rights to use, copy, modify, merge, publish, distribute, sublicense,
85 and/or sell copies of the Software, and to permit persons to whom the
86 Software is furnished to do so, subject to the following conditions:
87
88 The above copyright notice and this permission notice shall be included
89 in all copies or substantial portions of the Software.
90
91 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
92 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
93 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
94 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
95 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
96 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
97 OTHER DEALINGS IN THE SOFTWARE.