Add website down / maintenance mode
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 18 Jun 2016 17:46:01 +0000 (18:46 +0100)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 18 Jun 2016 17:46:01 +0000 (18:46 +0100)
MANIFEST
lib/App/Web/Oof.pm
tmpl/down.html [new file with mode: 0644]

index 182d9baf92676599d5b87889a3666452949f7684..03caef65952ca1c7e5cc7ba407b1fc4483787a10 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -19,3 +19,4 @@ tmpl/form.html
 tmpl/order.html
 tmpl/pay.html
 tmpl/display.html
+tmpl/down.html
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;
diff --git a/tmpl/down.html b/tmpl/down.html
new file mode 100644 (file)
index 0000000..f2ded47
--- /dev/null
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<link rel="stylesheet" href="/static/style.css">
+<title>ledparts4you</title>
+
+<h1 id="title">ledparts4you</h1>
+<div id="subtitle">Issues/Questions? Contact us at <a href="mailto:orders@ledparts4you.uk.to">orders@ledparts4you.uk.to</a></div>
+
+<div id="content"></div>
This page took 0.01514 seconds and 4 git commands to generate.