pricecharts

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

commit ebbbc56843c7b37361ffe60a9ae0e06f1deb686b
parent 14f62a0b4ae5e934ea097dd18c708bacdc69f7ad
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Thu, 19 Mar 2015 04:07:23 -0600

gen_static: also generate product pages

Diffstat:
Mgen_static | 13+++++++------
Mtt/chart_list.tt | 5+++--
Mtt/index.tt | 3++-
3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/gen_static b/gen_static @@ -35,7 +35,7 @@ my $template = Template->new($config) # manufacturers.html, manufacturers/* my $manufacturers_sql = "select distinct manufacturer from products"; -my $parts_sql = "select part_num, manufacturer, description from products where manufacturer = ?"; +my $parts_sql = "select part_num, lower(manufacturer), description from products where manufacturer = ?"; my $m = gen_link_page($manufacturers_sql, $parts_sql, "manufacturers", "Manufacturers"); # vendors.html, vendors/* @@ -43,15 +43,17 @@ my $vendor_sql = "select distinct vendor from prices"; $parts_sql = "select distinct part_num from prices where vendor = ?"; my $v = gen_link_page($vendor_sql, $parts_sql, "vendors", "Retailers"); -# index.html -my $sql = "select count(part_num) from products"; -my ($p) = $dbh->selectrow_array($sql); +# 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"); # get a list of products added within the last week my $time = time - (7 * 24 * 60 * 60); -$sql = "select description from products where first_seen > $time"; +my $sql = "select manufacturer, part_num, lower(part_num) from products where first_seen > $time"; my $new_products = $dbh->selectall_arrayref($sql); +# index.html my $n = @$new_products; my $vars = { num_vendors => $v, @@ -96,7 +98,6 @@ sub gen_link_page push @manicured_list, [$result, $result_lc]; } - # manufacturers.html my $vars = { name => $case_normal, name_lc => $dir_prefix, diff --git a/tt/chart_list.tt b/tt/chart_list.tt @@ -2,8 +2,9 @@ <h1>[% name %]</h1> [% FOREACH part_num IN products %] <div class="product"> - <b>[% part_num.1 %]</b> [% part_num.0 %]<br> - [% part_num.2 %] <br> + <img class="logo_small" src="/logo/[% part_num.1 %].svg"></img> + [% part_num.2 %]<br> + [% part_num.0 %]<br> <object data="/svg/[% part_num.0 %].svg" type="image/svg+xml"> </object> </div> diff --git a/tt/index.tt b/tt/index.tt @@ -39,7 +39,8 @@ <h1>New Products ([% num_new %])</h1> <ul> [% FOREACH new_product IN new_products %] - <li>[% new_product.0 %] + <li><a href="/products/[% new_product.2 %].html"> + [% new_product.0 %] [% new_product.1 %]</a> [% END %] </ul> </div>