##################################################
my %db;
-my ($form, $continue, $order, $details, $pay, $display);
+my ($form, $continue, $order, $details, $pay, $display, $down);
{
sub parse_html {
$details = parse_html 'details';
$pay = parse_html 'pay';
$display = parse_html 'display';
+ $down = parse_html 'down';
}
sub stringify_money { sprintf "£%.2f", $_[0] / 100 }
sub product_to_schemaorg {
my ($include_url, %data) = @_;
my $stock = $data{stock} > 0 ? 'InStock' : 'OutOfStock';
+ my @extra;
+ push @extra, (brand => {'@type' => 'Brand', name => $data{brand}}) if $data{brand};
+ push @extra, (model => $data{model}) if $data{model};
+{
'@context' => 'http://schema.org/',
'@type' => 'Product',
name => $data{title},
image => "/static/fullpics/$data{product}-1.jpg",
description => $data{subtitle},
+ @extra,
offers => {
'@type' => 'Offer',
price => ($data{price} =~ s/(..)$/\.$1/r),
$res;
}
};
+ enable sub {
+ my $app = shift;
+ sub {
+ if (-f 'down.html') {
+ my $down_lit = HTML::Element::Library::super_literal read_file 'down.html';
+ my $tree = $down->clone;
+ $tree->fid('content')->replace_content($down_lit);
+ return [503, ['Content-type' => 'text/html; charset=utf-8'], [$tree->as_HTML]]
+ }
+ $app->(@_)
+ }
+ };
mount '/' => sub { [301, [Location => '/form'], []] };
mount '/form' => \&form_app;
mount '/continue' => \&continue_app;