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