pricecharts

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

commit 60584c39411a944a4265b4b5a01bb412147dd081
parent bffc96b572da605a9321a0a428ad49835e0300c6
Author: Kyle Milz <kyle@getaddrinfo.net>
Date:   Sun, 15 Mar 2015 17:12:38 -0600

html: move templates on dir up

When copying the html templates into the chroot, don't put them in their own
directory. Instead, rename their extensions to reflect the templates that they
are, and move them into the html root.

This removes the need for yet another config variable. With this diff I can
gen_index and then view the main page. Search also works.

Diffstat:
MMakefile | 16++++++++++++----
MPriceChart.pm | 1-
Dhtml/index.html | 37-------------------------------------
Ahtml/index.tt2 | 37+++++++++++++++++++++++++++++++++++++
Dhtml/search.html | 15---------------
Ahtml/search.tt2 | 15+++++++++++++++
Rhtml/wrapper.html -> html/wrapper.tt2 | 0
Mpc_fcgi | 6+++---
8 files changed, 67 insertions(+), 60 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,15 +1,23 @@ USR_LOCAL_BIN=/usr/local/bin -LIBDATA=/usr/local/libdata/perl5/site_perl +PERL_LIBDATA=/usr/local/libdata/perl5/site_perl +HTDOCS=/var/www/htdocs -DEV_ETC=/home/kyle/src/pricechart +DEV_BIN=/home/kyle/src/pricechart BINS=price_scraper product_scraper gen_index pc_fcgi +LIBS=PriceChart.pm install: cp $(BINS) $(USR_LOCAL_BIN)/ - sed -e "s@$(DEV_ETC)@$(USR_LOCAL_BIN)@" < openbsd_rc.d_pc_fcgi \ + cp $(LIBS) $(PERL_LIBDATA)/ + + sed -e "s@$(DEV_BIN)@$(USR_LOCAL_BIN)@" < openbsd_rc.d_pc_fcgi \ > /etc/rc.d/pc_fcgi chmod 555 /etc/rc.d/pc_fcgi - cp PriceChart.pm $(LIBDATA)/ + + mkdir $(HTDOCS)/pricechart + cp -R html/* $(HTDOCS)/pricechart/ uninstall: rm /etc/rc.d/pc_fcgi + # rm $(PERL_LIBDATA)/$(LIBS) + # rm $(USR_LOCAL_BIN)/$(BINS) diff --git a/PriceChart.pm b/PriceChart.pm @@ -27,7 +27,6 @@ sub get_config "chroot", "db_dir", "htdocs", - "templates", "logs", ], }, diff --git a/html/index.html b/html/index.html @@ -1,37 +0,0 @@ -[% WRAPPER wrapper.html %] - <div class="column"> - <h1>Welcome</h1> - - <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 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 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"> - <h1>Motivation</h1> - - <p> <em>Price</em><b>Chart</b> is meant to be a consumer - purchasing tool. It is intended to give the consumer insight - into retail pricing which they would not normally have. </p> - - <p> A common practice when purchasing something new is <em>price - comparison</em>. A consumer decides on a certain product - they are interested in and then look around for the best deal. - That is what this service does. It automates <em>price - comparisons</em>. </p> - - <p> This is important because the price difference between - different retailers for the same product is often hundreds of - dollars if not more. </p> - </div> -[% END %] diff --git a/html/index.tt2 b/html/index.tt2 @@ -0,0 +1,37 @@ +[% WRAPPER wrapper.tt2 %] + <div class="column"> + <h1>Welcome</h1> + + <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 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 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"> + <h1>Motivation</h1> + + <p> <em>Price</em><b>Chart</b> is meant to be a consumer + purchasing tool. It is intended to give the consumer insight + into retail pricing which they would not normally have. </p> + + <p> A common practice when purchasing something new is <em>price + comparison</em>. A consumer decides on a certain product + they are interested in and then look around for the best deal. + That is what this service does. It automates <em>price + comparisons</em>. </p> + + <p> This is important because the price difference between + different retailers for the same product is often hundreds of + dollars if not more. </p> + </div> +[% END %] diff --git a/html/search.html b/html/search.html @@ -1,15 +0,0 @@ -[% WRAPPER wrapper.html %] - <p>Found <b>[% num_results %]</b> search - [% IF num_results == 1 %] - result - [% ELSE %] - results - [% END %] - for <b>[% query %]</b>:</p> - - [% FOREACH part_num IN results %] - [% part_num.1 %] [% part_num.2 %] ([% part_num.0 %])<br> - <object data="/svg/[% part_num.0 %].svg" type="image/svg+xml"> - </object> - [% END %] -[% END %] diff --git a/html/search.tt2 b/html/search.tt2 @@ -0,0 +1,15 @@ +[% WRAPPER wrapper.tt2 %] + <p>Found <b>[% num_results %]</b> search + [% IF num_results == 1 %] + result + [% ELSE %] + results + [% END %] + for <b>[% query %]</b>:</p> + + [% FOREACH part_num IN results %] + [% part_num.1 %] [% part_num.2 %] ([% part_num.0 %])<br> + <object data="/svg/[% part_num.0 %].svg" type="image/svg+xml"> + </object> + [% END %] +[% END %] diff --git a/html/wrapper.html b/html/wrapper.tt2 diff --git a/pc_fcgi b/pc_fcgi @@ -71,8 +71,8 @@ my $dbh = get_dbh($cfg->{"general"}, $db_dir); my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, $socket, FCGI::FAIL_ACCEPT_ON_INTR); -print "info: making template config\n" if ($args{v}); -my $config = { INCLUDE_PATH => $http_cfg{"templates"} }; +print "info: making template, include_path = $http_cfg{htdocs}\n" if ($args{v}); +my $config = { INCLUDE_PATH => $http_cfg{"htdocs"} }; my $template = Template->new($config) || die $Template::ERROR . "\n"; # db query we take input from the user for @@ -101,7 +101,7 @@ while ($request->Accept() >= 0) { results => $products }; - $template->process("search.html", $vars) or print $template->error(); + $template->process("search.tt2", $vars) or print $template->error(); } syslog(LOG_INFO, "shutdown"); closelog();