tagging: Allow using titles in for related stories.
[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 This plugin is now maintained by the Blosxom Sourceforge Team,
73 <blosxom-devel@lists.sourceforge.net>.
74
75 =head1 SEE ALSO
76
77 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
78
79 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
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 LICENSE
87
88 Blosxom and this Blosxom Plug-in
89 Copyright 2003, Rael Dornfest 
90
91 Permission is hereby granted, free of charge, to any person obtaining a
92 copy of this software and associated documentation files (the "Software"),
93 to deal in the Software without restriction, including without limitation
94 the rights to use, copy, modify, merge, publish, distribute, sublicense,
95 and/or sell copies of the Software, and to permit persons to whom the
96 Software is furnished to do so, subject to the following conditions:
97
98 The above copyright notice and this permission notice shall be included
99 in all copies or substantial portions of the Software.
100
101 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
104 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
105 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
106 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
107 OTHER DEALINGS IN THE SOFTWARE.