From 0e71232a627fb177a9d01248115ae11445e74f30 Mon Sep 17 00:00:00 2001 From: bluesaxman Date: Mon, 29 Apr 2019 08:02:47 -0600 Subject: [PATCH] added detection for header files --- index.pl | 61 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 27 deletions(-) diff --git a/index.pl b/index.pl index 0c63b46..0d9d7a7 100755 --- a/index.pl +++ b/index.pl @@ -15,6 +15,7 @@ my $data_dir = "./dynamic/"; my $site_base = "/"; my $site_name = "Murkfall Mountain"; my $site_symbol = "⛰"; +my $site500 = "There was an oopsy"; my $site404 = "There is nothing here..."; # Make some tools @@ -49,7 +50,7 @@ sub http_status { return $header; } -sub html_tag { # needs to support attributes +sub html_tag { my $tag = shift; my $content = shift; my @attrib_array = @_; @@ -72,7 +73,7 @@ sub html_tag { # needs to support attributes sub soft_die { print http_status(500,"text/html; charset=utf-8"); print "\n"; - print html_tag("html",html_tag("body","There was an oopsy")); + print html_tag("html",html_tag("body",$site500)); exit; } @@ -103,29 +104,36 @@ sub header { {attribute=>'content', value=>'text/html; charset=utf-8'}); # Make title dynamic $header .= html_tag('title',$site_name); - # Check these files to see if they exsist, and only add if they do. - $header .= html_tag( - 'link', - undef, - {attribute=>'rel', value=>'icon'}, - {attribute=>'type', value=>'image/gif'}, - {attribute=>'href', value=>$img_dir.'favicon.gif'}); - $header .= html_tag( - 'link', - undef, - {attribute=>'rel', value=>"stylesheet"}, - {attribute=>'type',value=>"text/css"}, - {attribute=>'href',value=>$css_dir.'css'}); - $header .= html_tag( - 'script', - " ", - {attribute=>'type', value=>"text/javascript"}, - {attribute=>'src',value=>$js_dir.'bluecore.js'}); - $header .= html_tag( - 'script', - " ", - {attribute=>'type', value=>"text/javascript"}, - {attribute=>'src', value=>$js_dir.'base'}); + if (-e $img_dir.'favicon.gif') { + $header .= html_tag( + 'link', + undef, + {attribute=>'rel', value=>'icon'}, + {attribute=>'type', value=>'image/gif'}, + {attribute=>'href', value=>$img_dir.'favicon.gif'}); + } + if (-e $css_dir.'css.css') { + $header .= html_tag( + 'link', + undef, + {attribute=>'rel', value=>"stylesheet"}, + {attribute=>'type',value=>"text/css"}, + {attribute=>'href',value=>$css_dir.'css.css'}); + } + if (-e $js_dir.'bluecore.js') { + $header .= html_tag( + 'script', + " ", + {attribute=>'type', value=>"text/javascript"}, + {attribute=>'src',value=>$js_dir.'bluecore.js'}); + } + if (-e $js_dir.'base.js') { + $header .= html_tag( + 'script', + " ", + {attribute=>'type', value=>"text/javascript"}, + {attribute=>'src', value=>$js_dir.'base.js'}); + } $header .= html_tag( 'meta', undef, @@ -218,7 +226,6 @@ sub submenu { shift(@list); return render_menu("sub",@list); } - ######################### /menu ########################### sub page_template { @@ -226,7 +233,7 @@ sub page_template { my $page_content = html_tag( 'div', $content -# For the main sides command prompt +# For the main sites command prompt # .html_tag('span'," ", {attribute=>'id', value=>"prompt"}) # .html_tag('span',"█", {attribute=>'class', value=>"cursor"}) ,{attribute=>'id', value=>'screen'});