Add a bunch of Rael plugins.
[matthijs/upstream/blosxom-plugins.git] / general / trackback_counts_display
1 # Blosxom Plugin: trackback_counts_display
2 # Author(s): Rael Dornfest <rael@oreilly.com> 
3 # Version: 2.0b2
4 # Documentation: See the bottom of this file or 
5 # type: perldoc trackback_counts_display
6
7 package trackback_counts_display;
8
9 # --- Configurable variables -----
10
11 # What is the trackbacks base URL?
12 my $trackback_url = "http://www.example/tb.cgi";
13
14 # Where are trackbacks kept?
15 my $trackback_dir = "/Library/WebServer/Data/trackbacks";
16
17 # --------------------------------
18
19 use File::Spec::Functions; 
20
21 $trackback; # use as $trackback_counts_display::trackback in flavour templates
22
23 sub start {
24   -d $trackback_dir or return 0;
25   1;
26 }
27
28 sub story {
29   my($pkg, $path, $filename, $story_ref) = @_;
30   my $trackback_id = "$path/$filename"; 
31   $trackback_id =~ s!^/!!;
32   $trackback_id =~ tr/a-zA-Z0-9/_/cs;
33
34   require Storable;
35   my $trackback_count = -e "$trackback_dir/$trackback_id.stor" ? @{Storable::retrieve("$trackback_dir/$trackback_id.stor")} : 0;
36   my $trackback_text = $trackback_count == 1 ? 'trackback' : 'trackbacks';
37  
38   $trackback = qq{<a href="$trackback_url?__mode=list&tb_id=$trackback_id" onclick="window.open(this.href, 'trackbacks', 'width=640,height=480,scrollbars=yes,status=yes'); return false">$trackback_count $trackback_text</a>};
39
40   1;
41 }
42
43 1;
44
45 __END__
46
47 =head1 NAME
48
49 Blosxom Plug-in: trackback_counts_display
50
51 =head1 SYNOPSIS
52
53 Purpose: Incorporates TrackBack [http://www.movabletype.org/trackback/]
54 counts into Blosxom flavours. Populates $trackback_counts_display::trackback 
55 with "n trackback(s)", n being the number of trackbacks associated with a
56 particular story.  Further provides a popup link to the TrackBack CGI
57 for a view of current trackbacks for a particular story.
58
59 Assumes the MT Standalone TrackBack implementation is already up and running.
60
61 =head1 VERSION
62
63 2.0b2
64
65 Version number coincides with the version of Blosxom with which the 
66 current version was first bundled.
67
68 =head1 AUTHOR
69
70 Rael Dornfest  <rael@oreilly.com>, http://www.raelity.org/
71
72 =head1 SEE ALSO
73
74 Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/
75
76 Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml
77
78 =head1 BUGS
79
80 Address bug reports and comments to the Blosxom mailing list 
81 [http://www.yahoogroups.com/group/blosxom].
82
83 =head1 LICENSE
84
85 Blosxom and this Blosxom Plug-in
86 Copyright 2003, Rael Dornfest 
87
88 Permission is hereby granted, free of charge, to any person obtaining a
89 copy of this software and associated documentation files (the "Software"),
90 to deal in the Software without restriction, including without limitation
91 the rights to use, copy, modify, merge, publish, distribute, sublicense,
92 and/or sell copies of the Software, and to permit persons to whom the
93 Software is furnished to do so, subject to the following conditions:
94
95 The above copyright notice and this permission notice shall be included
96 in all copies or substantial portions of the Software.
97
98 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
99 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
100 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
101 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
102 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
103 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
104 OTHER DEALINGS IN THE SOFTWARE.