pricecharts

track prices of consumer electronics
Log | Files | Refs | README

commit 10a92028d7d9f497530711452712e5569f583328
parent f65e84c8c732934377c95ef2e9438e17cdf0d134
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Sun, 22 Mar 2015 17:08:59 -0600

gen_static: make better product pages

Diffstat:
Mgen_static | 17+++++++++++++----
Att/product.tt | 12++++++++++++
2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/gen_static b/gen_static @@ -44,13 +44,22 @@ $parts_sql = "select distinct part_num from prices where vendor = ?"; my $v = gen_link_page($retailers_sql, $parts_sql, "retailers", "Retailers"); # products.html, products/* -my $product_sql = "select part_num from products"; -$parts_sql = "select part_num, lower(manufacturer), description from products where part_num = ?"; -my $p = gen_link_page($product_sql, $parts_sql, "products", "Products"); +xmkdir "$work_dir/products"; +my $sql = "select * from products"; +my $products = $dbh->selectall_hashref($sql, "part_num"); +for my $part_num (keys %$products) { + my $part_num_lc = lc($part_num); + + # xmkdir("$work_dir/products/$result_lc.html", $args{v}); + $template->process("product.tt", $products->{$part_num}, + "products/$part_num_lc.html") or print $template->error() . "\n"; +} +my $p = scalar keys %$products; +print "info: products/ generated $p pages\n" if ($args{v}); # get a list of products added within the last week my $time = time - (7 * 24 * 60 * 60); -my $sql = "select manufacturer, part_num, lower(part_num) from products where first_seen > $time"; +$sql = "select manufacturer, part_num, lower(part_num) from products where first_seen > $time"; my $new_products = $dbh->selectall_arrayref($sql); # index.html diff --git a/tt/product.tt b/tt/product.tt @@ -0,0 +1,12 @@ +[% WRAPPER wrapper.tt %] + <h1>[% part_num %]</h1> + <div class="product"> + Manufacturer: [% manufacturer %]<br> + Description: [% description %]<br> + First Seen: [% first_seen %]<br> + Last Seen: [% last_seen %]<br> + Type: [% type %]<br> + <object data="/svg/[% part_num %].svg" type="image/svg+xml"> + </object> + </div> +[% END %]