Add a bunch of Rael plugins.
[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*(.+)$!;
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 =head1 SEE ALSO
63
64 Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/
65
66 Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml
67
68 =head1 BUGS
69
70 Address bug reports and comments to the Blosxom mailing list 
71 [http://www.yahoogroups.com/group/blosxom].
72
73 =head1 LICENSE
74
75 Blosxom and this Blosxom Plug-in
76 Copyright 2003, Rael Dornfest 
77
78 Permission is hereby granted, free of charge, to any person obtaining a
79 copy of this software and associated documentation files (the "Software"),
80 to deal in the Software without restriction, including without limitation
81 the rights to use, copy, modify, merge, publish, distribute, sublicense,
82 and/or sell copies of the Software, and to permit persons to whom the
83 Software is furnished to do so, subject to the following conditions:
84
85 The above copyright notice and this permission notice shall be included
86 in all copies or substantial portions of the Software.
87
88 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
89 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
90 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
91 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
92 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
93 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
94 OTHER DEALINGS IN THE SOFTWARE.