tagging: Allow using titles in for related stories.
[matthijs/upstream/blosxom-plugins.git] / general / buy_from_amazon
1 # Blosxom Plugin: buy_from_amazon
2 # Author(s): Rael Dornfest <rael@oreilly.com> 
3 # Version: 2.0b1
4 # Documentation: See the bottom of this file or type: perldoc buy_from_amazon
5
6 package buy_from_amazon;
7
8 # --- Configurable variables -----
9
10 # What is your Amazon Associate ID?
11 my $associate_id = "raelitybytes-20";
12 # If you're not an Amazon Associate, feel free to leave this as is ;-)
13
14 # --------------------------------
15
16 $amazon; # use as $buy_from_amazon::amazon in flavour templates
17
18 sub start {
19   1;
20 }
21
22 sub story {
23   my($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
24
25   ($amazon) = $$body_ref =~ m!['"]http://www.amazon.com.+?/(\w+)/$associate_id.*?['"]!mg;
26   
27   $amazon and $amazon = qq{<a href="http://buybox.amazon.com/exec/obidos/redirect?tag=$associate_id&link_code=xsc&creative=23424&camp=2025&path=/dt/assoc/tg/aa/xml/assoc/-/$amazon/$associate_id/ref=ac_bb6_,_amazon" onclick="window.open(this.href, 'buy from amazon', 'location=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes,width=380,height=450,screenX=10,screenY=10,top=10,left=10'); return false;">buy from amazon</a>};
28   
29   return 1;
30 }
31
32 1;
33
34 __END__
35
36 =head1 NAME
37
38 Blosxom Plug-in: buy_from_amazon
39
40 =head1 SYNOPSIS
41
42 Purpose: Populates $buy_from_amazon::amazon with a link to 
43 Amazon Quick Click(TM) Buying for the first Amazon product
44 link (if any) found in the current weblog story body.
45
46 =head1 VERSION
47
48 2.0b1
49
50 Version number coincides with the version of Blosxom with which the 
51 current version was first bundled.
52
53 =head1 AUTHOR
54
55 Rael Dornfest <rael@oreilly.com>, http://www.raelity.org/
56
57 This plugin is now maintained by the Blosxom Sourceforge Team,
58 <blosxom-devel@lists.sourceforge.net>.
59
60 =head1 SEE ALSO
61
62 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
63
64 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
65
66 =head1 BUGS
67
68 None known; please send bug reports and feedback to the Blosxom
69 development mailing list <blosxom-devel@lists.sourceforge.net>.
70
71 =head1 LICENSE
72
73 Blosxom and this Blosxom Plug-in
74 Copyright 2003, Rael Dornfest 
75
76 Permission is hereby granted, free of charge, to any person obtaining a
77 copy of this software and associated documentation files (the "Software"),
78 to deal in the Software without restriction, including without limitation
79 the rights to use, copy, modify, merge, publish, distribute, sublicense,
80 and/or sell copies of the Software, and to permit persons to whom the
81 Software is furnished to do so, subject to the following conditions:
82
83 The above copyright notice and this permission notice shall be included
84 in all copies or substantial portions of the Software.
85
86 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
87 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
88 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
89 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
90 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
91 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
92 OTHER DEALINGS IN THE SOFTWARE.