My relatives think I'm hard to buy for, they never know what I want. I recently started an Amazon Wish List but it didn't make anything easier, they couldn't find it! Fair enough, Net::Amazon to the rescue. You need two pieces of information from Amazon.
Below is the code I use at my new "Wish List" page, http://caseywest.com/wishes.html. It's Mason, but easily adaptable.
Enjoy!
<%method .title><& PARENT:.title &> · Wish List</%method>
% foreach (@wishes) {
<& SELF:.list_wish, wish => $_ &>
% }
<%method .list_wish>
<%args>
$wish
</%args>
<div class="title-secondary">
<div class="blog-interact">
<% $wish->Manufacturer %>
</div>
<% $cat %> · <% $title %>
</div>
<div class="blog-entry">
<p>
% if ( $wish->ImageUrlMedium ) {
<a href="<% $wish->url %>"><img style="float:right" src="<% $wish->ImageUrlMedium %>" alt="<% $wish->ProductName %>" /></a>
% }
% if ( ref($wish) =~ /Book/ ) {
<& SELF:.book_detail, book => $wish &>
% } elsif ( ref($wish) =~ /DVD/ ) {
<& SELF:.dvd_detail, dvd => $wish &>
% } elsif ( ref($wish) =~ /Music/ ) {
<& SELF:.music_detail, music => $wish &>
% } else {
<& SELF:.general_detail, product => $wish &>
% }
<br clear="all" />
</p>
</div>
<%init>
my $title = $wish->ProductName;
$title = (split /:/, $title)[0] if length $title > 70;
my $cat = (split /::/, ref($wish))[-1];
$cat = 'Product' if $cat eq 'Property';
</%init>
</%method>
<%method .general_detail>
<%args>
$product
</%args>
<& SELF:.detail, props => $props &>
<%init>
my $props = [
Released => $product->ReleaseDate,
Availability => $product->Availability,
Details => sprintf('<a href="%s">Amazon</a>',$product->url),
];
</%init>
</%method>
<%method .music_detail>
<%args>
$music
</%args>
<& SELF:.detail, props => $props &>
<%init>
my $a_title = $music->artists > 1 ? "Artists" : "Artist";
my $props = [
$a_title => join( '; ', $music->artists),
Released => $music->ReleaseDate,
Availability => $music->Availability,
Details => sprintf('<a href="%s">Amazon</a>',$music->url),
];
</%init>
</%method>
<%method .dvd_detail>
<%args>
$dvd
</%args>
<& SELF:.detail, props => $props &>
<%init>
my $d_title = $dvd->directors > 1 ? "Directors" : "Director";
my $props = [
$d_title => join( '; ', $dvd->directors),
Rating => $dvd->mpaa_rating,
Released => $dvd->ReleaseDate,
Availability => $dvd->Availability,
Details => sprintf('<a href="%s">Amazon</a>',$dvd->url),
];
</%init>
</%method>
<%method .book_detail>
<%args>
$book
</%args>
<& SELF:.detail, props => $props &>
<%init>
my $a_title = $book->authors > 1 ? "Authors" : "Author";
my $props = [
$a_title => join( '; ', $book->authors),
Released => $book->ReleaseDate,
Availability => $book->Availability,
Details => sprintf('<a href="%s">Amazon</a>',$book->url),
];
</%init>
</%method>
<%method .detail>
<%args>
@props
</%args>
<% $table %>
<%init>
use HTML::Table;
use List::Group qw[group];
my $table = HTML::Table->new(
-data => [group \@props, cols => 2],
-class => 'hft-tables-nohead',
);
</%init>
</%method>
<%init>
return if $m->cache_self(expires_in => '1 hour', key => 'self');
my $TOKEN = qw[XXXX];
my $ID = qw[YYYY];
use Net::Amazon;
use Net::Amazon::Request::Wishlist;
my $ua = Net::Amazon->new(token => $TOKEN);
my $req = Net::Amazon::Request::Wishlist->new(id => $ID);
my $res = $ua->request($req);
return unless $res->is_success;
my @wishes = sort {
( (split/::/,ref($a))[-1] cmp (split/::/,ref($b))[-1] )
||
( $a->ProductName cmp $b->ProductName )
} $res->properties;
</%init>
Posted from caseywest.com, comment here.