From: Marius Gavrilescu Date: Sat, 18 Jun 2016 17:46:01 +0000 (+0100) Subject: Add website down / maintenance mode X-Git-Tag: 0.000_008~3 X-Git-Url: http://git.ieval.ro/?p=app-web-oof.git;a=commitdiff_plain;h=80e9b2b1a3d52794bc82283ccb30be2cd556d444 Add website down / maintenance mode --- diff --git a/MANIFEST b/MANIFEST index 182d9ba..03caef6 100644 --- a/MANIFEST +++ b/MANIFEST @@ -19,3 +19,4 @@ tmpl/form.html tmpl/order.html tmpl/pay.html tmpl/display.html +tmpl/down.html diff --git a/lib/App/Web/Oof.pm b/lib/App/Web/Oof.pm index 186fb2f..23fd09a 100644 --- a/lib/App/Web/Oof.pm +++ b/lib/App/Web/Oof.pm @@ -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 index 0000000..f2ded47 --- /dev/null +++ b/tmpl/down.html @@ -0,0 +1,9 @@ + + + +ledparts4you + +

ledparts4you

+
Issues/Questions? Contact us at orders@ledparts4you.uk.to
+ +