Bump version and update Changes
[app-web-oof.git] / lib / App / Web / Oof.pm
index 186fb2fc4e931df41d8b01ac51efa4ed90b8b99e..f9f34f312c139d38f3da2f4eb8f9183b22de9533 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use utf8;
 use parent qw/Plack::Component/;
 
-our $VERSION = '0.000_007';
+our $VERSION = '0.000_008';
 
 use DBIx::Simple;
 use Email::Sender::Simple 'sendmail';
@@ -44,7 +44,7 @@ my $postage_per_item = $ENV{OOF_POSTAGE_PER_ITEM} // 50;
 ##################################################
 
 my %db;
-my ($form, $continue, $order, $details, $pay, $display);
+my ($form, $continue, $order, $details, $pay, $display, $down);
 
 {
        sub parse_html {
@@ -60,6 +60,7 @@ my ($form, $continue, $order, $details, $pay, $display);
        $details  = parse_html 'details';
        $pay      = parse_html 'pay';
        $display  = parse_html 'display';
+       $down     = parse_html 'down';
 }
 
 sub stringify_money { sprintf "£%.2f", $_[0] / 100 }
@@ -225,7 +226,7 @@ sub order_app {
                                header => [
                                        From    => $ENV{OOF_EMAIL_FROM},
                                        To      => $ENV{OOF_EMAIL_TO},
-                                       Subject => "Order $id placed",
+                                       Subject => "Order $id placed for ".stringify_money($parms{total}),
                                ],
                                body => 'A new order was placed.',
                        )) if $ENV{OOF_EMAIL_TO};
@@ -281,6 +282,17 @@ sub details_app {
        $tree->fid('pictures')->find('li')->iter3(\@pics, \&details_list_element);
        $tree->fid('jsonld')->replace_content(encode_json product_to_schemaorg '', %data);
 
+       $tree->fid('dd_stock')->replace_content($data{stock});
+       $tree->fid('dd_price')->replace_content(stringify_money $data{price});
+       for (qw/brand model/) {
+               if ($data{$_}) {
+                       $tree->fid("dd_$_")->replace_content($data{$_});
+               } else {
+                       $tree->fid("dt_$_")->detach;
+                       $tree->fid("dd_$_")->detach;
+               }
+       }
+
        for my $ahref ($tree->find('a')) {
                $ahref->attr(href => "/form?highlight=$id") if $ahref->attr('href') eq '/';
        }
@@ -349,6 +361,18 @@ sub app {
                                $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;
This page took 0.010509 seconds and 4 git commands to generate.