Add website down / maintenance mode
[app-web-oof.git] / lib / App / Web / Oof.pm
index 186fb2fc4e931df41d8b01ac51efa4ed90b8b99e..23fd09ae37ac92a72ca77e0efa9ce220f2f879ff 100644 (file)
@@ -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 }
@@ -349,6 +350,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.009543 seconds and 4 git commands to generate.