commit 14237ff3f6ca4bfe4517b3a13896580b1f7221a4
parent ae77851a34ce16a5954940b0a2bace525ea76037
Author: Kyle Milz <kyle@getaddrinfo.net>
Date: Sun, 8 Feb 2015 19:14:11 -0700
gen_index: add debugging output, remove hardcoded paths
Diffstat:
4 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/PriceChart.pm b/PriceChart.pm
@@ -26,6 +26,8 @@ sub get_config
"gid",
"chroot",
"db_dir",
+ "htdocs",
+ "templates",
],
},
vendors => {
diff --git a/gen_index.pl b/gen_index.pl
@@ -3,39 +3,63 @@
use strict;
use warnings;
+use Config::Grammar;
+use Getopt::Std;
use File::Copy;
use PriceChart;
use Template;
-my $dbh = get_dbh();
+my %args;
+getopts("v", \%args);
+
+$| = 1 if ($args{v});
+
+my $cfg = get_config();
+my $dbh = get_dbh($cfg->{"general"});
+
+my $http_cfg = $cfg->{"http"};
+my $include = $http_cfg->{"chroot"} . $http_cfg->{"templates"};
+my $output = $http_cfg->{"chroot"} . $http_cfg->{"htdocs"};
+
+print "info: including from: $include\n" if ($args{v});
+print "info: outputting to: $output\n" if ($args{v});
my $config = {
INTERPOLATE => 1,
POST_CHOMP => 1,
EVAL_PERL => 1,
- # XXX: this needs to be changed
- INCLUDE_PATH => "/home/kyle/src/pricechart/html",
- OUTPUT_PATH => "/var/www/htdocs/pricechart"
+ INCLUDE_PATH => $include,
+ OUTPUT_PATH => $output
};
my $template = Template->new($config);
my $query = "select count(distinct manufacturer) from products";
my ($manufacturers) = $dbh->selectrow_array($query);
+print "info: $manufacturers manufacturers\n" if ($args{v});
$query = "select count(part_num) from products";
my ($products) = $dbh->selectrow_array($query);
+print "info: $products products\n" if ($args{v});
-$query = "select count(name) from vendors";
+$query = "select count(distinct vendor) from prices";
my ($vendors) = $dbh->selectrow_array($query);
+print "info: $vendors vendors\n" if ($args{v});
+
+my $time = time - (7 * 24 * 60 * 60);
+$query = "select count(part_num) from products where first_seen > ?";
+my ($new_products) = $dbh->selectrow_array($query, undef, $time);
+print "info: $new_products new products within 1 week\n" if ($args{v});
my $vars = {
num_vendors => $vendors,
num_manufacturers => $manufacturers,
- num_products => $products
+ num_products => $products,
+ new_products => $new_products
};
$template->process("index.html", $vars, "index.html") || die $template->error();
-copy("html/pricechart.css", "/var/www/htdocs/pricechart/pricechart.css");
+copy("$include/pricechart.css", "$output/pricechart.css");
+print "info: $include/pricechart.css -> $output/\n" if ($args{v});
$dbh->disconnect();
diff --git a/html/index.html b/html/index.html
@@ -2,20 +2,19 @@
<div class="column">
<h1>Welcome</h1>
- <p> Welcome to <em>Price</em><b>Chart</b>, an online service for
- inter-retailer price comparisons of consumer electronics.
+ <p> Welcome to <em>Price</em><b>Chart</b>, a price comparison
+ service for consumer electronics.
Currently <b>[% num_products %]</b> products from
- <b>[% num_manufacturers %]</b> manufacturers are being tracked
- across <b>[% num_vendors %]</b> retailers.</p>
+ <b>[% num_manufacturers %]</b> manufacturers are tracked across
+ <b>[% num_vendors %]</b> retailers.</p>
<p> To start, try searching for a product or manufacturer in the
search box at the top right. </p>
<p> <em>Price</em><b>Chart</b> periodically looks up and saves
- the price information of different products. These prices are
- aggregated by product into charts. From these charts it can be
- easily determined which retailer currently has the lowest price
- for a given product. </p>
+ the prices of products. These prices are converted to charts
+ where determining which retailer is the best to purchase from is
+ easy.</p>
</div>
<div class="column">
diff --git a/html/pricechart.css b/html/pricechart.css
@@ -11,6 +11,10 @@ input {
font-size: 1em;
}
+p {
+ line-height: 1.5em;
+}
+
#footer {
text-align: center;
}
@@ -20,6 +24,7 @@ input {
color: black;
text-decoration: none;
float: left;
+ text-shadow: 2px 2px #DDD;
}
.column {