Revert rss20 to using $ENV{PATH_INFO} in self link.
[blosxom-plugins.git] / gavinc / hcard
blob9fa0f5b33857e7ee6d09bee3902cb47d36775dec
1 # Blosxom Plugin: hcard
2 # Author(s): Gavin Carr <gavin@openfusion.com.au>
3 # Version: 0.001000
4 # Documentation: 'perldoc hcard'
5 # Requires: metaclear, metamail, uf_hcard_meta
7 package hcard;
9 use strict;
10 use IO::File;
12 # Uncomment next line to enable debug output (don't uncomment debug() lines)
13 #use Blosxom::Debug debug_level => 1;
15 # --- Configuration defaults -----
17 my %config = (
19   # Where is the hcard metadata?
20   hcard_meta_file => "$blosxom::datadir/hcard.yml",
24 # --------------------------------
25 # __END_CONFIG__
27 use vars qw($hcard);
28 $hcard = '';
30 sub start {
31     # Check $hcard_meta_file exists
32     unless (-f $config{hcard_meta_file}) {
33         warn "(hcard) cannot find hcard_meta_file file '$config{hcard_meta_file}' - aborting\n";
34         return 0;
35     }
36     return 1;
39 sub skip {
40     my $hcard_fh = IO::File->new( $config{hcard_meta_file}, 'r' )
41         or warn "(hcard) cannot open hcard_meta_file file '$config{hcard_meta_file}': $! - aborting\n"
42             and return 0;
43     my @hcard_data = <$hcard_fh>;
44     my $hcard_title = $hcard_data[0];
45     chomp $hcard_title;
46     my $hcard_body = join '', @hcard_data[ 1 .. $#hcard_data ];
47     $hcard_fh->close;
48     # debug(1, "hcard_body: $hcard_body");
50     unless ($hcard_body) {
51         warn "(hcard) no data found in hcard_meta_file file '$config{hcard_meta_file}' - aborting\n";
52         return 0;
53     }
54   
55     # Fake story calls to metaclear, metamail and uf_hcard_meta to render the hcard
56     my @story_args = ( undef, undef, undef, undef, \$hcard_title, \$hcard_body );
57     metaclear::story( @story_args );
58     metamail::story( @story_args );
59     uf_hcard_meta::story( @story_args );
61     $hcard = $uf_hcard_meta::hcard;
63     return 0;
68 __END__
70 =head1 NAME
72 hcard - blosxom plugin to set a global $hcard::hcard variable for use in templates
74 =head1 DESCRIPTION
76 L<hcard> is a blosxom plugin to set a global $hcard::hcard variable for use in 
77 templates. It is intended to allow you to set up a global hcard for yourself
78 to be displayed somewhere in your blog template.
80 To use, simply define the set of hcard data you want to use in the 'hcard_meta_file'
81 file ($blosxom::datadir/hcard.yml, by default).
83 =head1 EXAMPLES
85 Here's an example hcard.yml for me:
87     Name: Gavin Carr
88     Organisation: Open Fusion
89     Role: Chief Geek
90     Email: gavin@openfusion.com.au
91     URL: http://www.openfusion.net/
92     Suburb: Wahroonga
93     State: NSW
94     Postcode: 2076
95     Country: Australia
96     Latitude: -33.717718
97     Longitude: 151.117158
98     HCard-Class: nodisplay
99     HCard-Style: div-span
101 =head1 USAGE
103 L<hcard> requires the L<uf_hcard_meta>, L<metaclear>, and L<metamail> plugins, 
104 but has no particular ordering requirements with respect to them.
106 =head1 SEE ALSO
108 L<uf_hcard_meta>, L<metaclear>, L<metamail>.
110 Microformats.org: http://www.microformats.org/, http://microformats.org/wiki/hcard.
112 Blosxom: http://blosxom.sourceforge.net/
114 =head1 AUTHOR
116 Gavin Carr <gavin@openfusion.com.au>, http://www.openfusion.net/
118 =head1 LICENSE
120 Copyright 2007, Gavin Carr.
122 This plugin is licensed under the same terms as blosxom itself i.e.
124 Permission is hereby granted, free of charge, to any person obtaining a
125 copy of this software and associated documentation files (the "Software"),
126 to deal in the Software without restriction, including without limitation
127 the rights to use, copy, modify, merge, publish, distribute, sublicense,
128 and/or sell copies of the Software, and to permit persons to whom the
129 Software is furnished to do so, subject to the following conditions:
131 The above copyright notice and this permission notice shall be included
132 in all copies or substantial portions of the Software.
134 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
135 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
136 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
137 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
138 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
139 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
140 OTHER DEALINGS IN THE SOFTWARE.
142 =cut
144 # vim:ft=perl:sw=4