added footer includes for things that need to load post page load

This commit is contained in:
bluesaxman 2019-05-03 09:10:30 -06:00
parent 928ce837f6
commit 61077644cc

View File

@ -4,26 +4,29 @@ use strict;
use warnings; use warnings;
# Where are my things? # Where are my things?
my $img_dir = "/img/"; #must be in docroot my $img_dir = "/img/"; #must be based on web root
my $pages_dir = "./pages/"; my $css_dir = "/css/"; #must be based on web root
my $js_dir = "/js/"; #must be based on web root
my $pages_dir = "./pages/";
my $scripts_dir = "./scripts/"; my $scripts_dir = "./scripts/";
my $css_dir = "/css/"; #must be in docroot my $data_dir = "./dynamic/";
my $js_dir = "/js/"; #must be in docroot
my $data_dir = "./dynamic/";
# What are my configurations? # What are my configurations?
my $system_base = `pwd`; my $system_base = `pwd`; #where am I on the system
chomp($system_base); chomp($system_base);
my $site_base = "/"; my $site_base = "/";
my $site_name = "Murkfall Mountain"; my $site_name = "Murkfall Mountain";
my $site_symbol = "&#9968"; my $site_symbol = "&#9968";
my $site500 = "There was an oopsy"; my $site500 = "There was an oopsy";
my $site404 = "There is nothing here..."; my $site404 = "There is nothing here...";
# What files should we include in our header # What files should we include in our header
my @header_includes = ( my @header_includes = (
{"file" => $img_dir."favicon.gif", "type" => "image/gif", "rel" => "icon", "tag" => "link"}, {"file" => $img_dir."favicon.gif", "type" => "image/gif", "rel" => "icon", "tag" => "link"},
{"file" => $css_dir."css.css", "type" => "text/css", "rel" => "stylesheet", "tag" => "link"}, {"file" => $css_dir."css.css", "type" => "text/css", "rel" => "stylesheet", "tag" => "link"},
);
my @footer_includes = (
{"file" => $js_dir."bluecore.js", "type" => "text/javascript", "rel" => "", "tag" => "script"}, {"file" => $js_dir."bluecore.js", "type" => "text/javascript", "rel" => "", "tag" => "script"},
{"file" => $js_dir."base.js", "type" => "text/javascript", "rel" => "", "tag" => "script"} {"file" => $js_dir."base.js", "type" => "text/javascript", "rel" => "", "tag" => "script"}
); );
@ -91,6 +94,7 @@ sub soft_die {
sub page404 { sub page404 {
print http_status(404,"text/html; charset=utf-8"); print http_status(404,"text/html; charset=utf-8");
print "<!DOCTYPE html>\n"; print "<!DOCTYPE html>\n";
$site_name .= " - 404";
print html_tag("html", print html_tag("html",
html_tag("head",header()). html_tag("head",header()).
html_tag("body", html_tag("body",
@ -105,6 +109,22 @@ sub normalize_string {
# lets build a website # lets build a website
sub include {
my @includes = @_;
my $buffer = "";
for (@includes) {
if (-e $system_base.$_->{"file"}) {
my $rel = $_->{"rel"} ne "" ? 1 : 0;
$buffer .= html_tag(
$_->{"tag"},
$_->{"tag"} eq "script" ? " " : undef,
$rel ? {attribute=>'rel', value=>$_->{"rel"}} : undef,
{attribute=>'type', value=>$_->{"type"}},
{attribute=>$rel?'href':'src', value=>$_->{"file"}});
}
}
return $buffer;
}
sub header { sub header {
my $header = ""; my $header = "";
@ -113,19 +133,8 @@ sub header {
undef, undef,
{attribute=>'http-equiv', value=>'Content-Type'}, {attribute=>'http-equiv', value=>'Content-Type'},
{attribute=>'content', value=>'text/html; charset=utf-8'}); {attribute=>'content', value=>'text/html; charset=utf-8'});
# Make title dynamic
$header .= html_tag('title',$site_name); $header .= html_tag('title',$site_name);
for (@header_includes) { $header .= include(@header_includes);
if (-e $system_base.$_->{"file"}) {
my $rel = $_->{"rel"} ne "" ? 1 : 0;
$header .= html_tag(
$_->{"tag"},
$_->{"tag"} eq "script" ? " " : undef,
$rel ? {attribute=>'rel', value=>$_->{"rel"}} : undef,
{attribute=>'type', value=>$_->{"type"}},
{attribute=>$rel?'href':'src', value=>$_->{"file"}});
}
}
$header .= html_tag( $header .= html_tag(
'meta', 'meta',
undef, undef,
@ -167,6 +176,7 @@ sub get_page {
open(PAGE, "<", $pages_dir.$sub_page_name) or return page404($pageURL." we looked here:".$pages_dir.$sub_page_name); open(PAGE, "<", $pages_dir.$sub_page_name) or return page404($pageURL." we looked here:".$pages_dir.$sub_page_name);
my @content = <PAGE>; my @content = <PAGE>;
close(PAGE); close(PAGE);
$site_name .= " - ".$page_name;
return @content; return @content;
} }
} }
@ -243,7 +253,8 @@ sub build_page {
html_tag("head",header()). html_tag("head",header()).
html_tag("body", html_tag("body",
render_logo($site_symbol). render_logo($site_symbol).
page_template(@content), page_template(@content).
include(@footer_includes),
#for the main site #for the main site
# {attribute=>'onkeydown',value=>"HandleStroke(event)"} # {attribute=>'onkeydown',value=>"HandleStroke(event)"}
)); ));