optimized header creation, now has configuration
This commit is contained in:
parent
0e71232a62
commit
fd198d82a9
50
index.pl
50
index.pl
@ -12,12 +12,22 @@ my $js_dir = "/js/"; #must be in docroot
|
|||||||
my $data_dir = "./dynamic/";
|
my $data_dir = "./dynamic/";
|
||||||
|
|
||||||
# What are my configurations?
|
# What are my configurations?
|
||||||
|
my $system_base = `pwd`;
|
||||||
|
chomp($system_base);
|
||||||
my $site_base = "/";
|
my $site_base = "/";
|
||||||
my $site_name = "Murkfall Mountain";
|
my $site_name = "Murkfall Mountain";
|
||||||
my $site_symbol = "⛰";
|
my $site_symbol = "⛰";
|
||||||
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
|
||||||
|
my @header_includes = (
|
||||||
|
{"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" => $js_dir."bluecore.js", "type" => "text/javascript", "rel" => "", "tag" => "script"},
|
||||||
|
{"file" => $js_dir."base.js", "type" => "text/javascript", "rel" => "", "tag" => "script"}
|
||||||
|
);
|
||||||
|
|
||||||
# Make some tools
|
# Make some tools
|
||||||
sub clean_input {
|
sub clean_input {
|
||||||
my $input = shift;
|
my $input = shift;
|
||||||
@ -59,6 +69,7 @@ sub html_tag {
|
|||||||
my $end = " />";
|
my $end = " />";
|
||||||
if (@attrib_array) {
|
if (@attrib_array) {
|
||||||
foreach(@attrib_array) {
|
foreach(@attrib_array) {
|
||||||
|
unless (defined($_)) { next; }
|
||||||
$string .= ' '.$_->{attribute}.'="'.$_->{value}.'"';
|
$string .= ' '.$_->{attribute}.'="'.$_->{value}.'"';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,35 +115,16 @@ sub header {
|
|||||||
{attribute=>'content', value=>'text/html; charset=utf-8'});
|
{attribute=>'content', value=>'text/html; charset=utf-8'});
|
||||||
# Make title dynamic
|
# Make title dynamic
|
||||||
$header .= html_tag('title',$site_name);
|
$header .= html_tag('title',$site_name);
|
||||||
if (-e $img_dir.'favicon.gif') {
|
for (@header_includes) {
|
||||||
$header .= html_tag(
|
if (-e $system_base.$_->{"file"}) {
|
||||||
'link',
|
my $rel = $_->{"rel"} ne "" ? 1 : 0;
|
||||||
undef,
|
$header .= html_tag(
|
||||||
{attribute=>'rel', value=>'icon'},
|
$_->{"tag"},
|
||||||
{attribute=>'type', value=>'image/gif'},
|
$_->{"tag"} eq "script" ? " " : undef,
|
||||||
{attribute=>'href', value=>$img_dir.'favicon.gif'});
|
$rel ? {attribute=>'rel', value=>$_{"rel"}} : undef,
|
||||||
}
|
{attribute=>'type', value=>$_->{"type"}},
|
||||||
if (-e $css_dir.'css.css') {
|
{attribute=>$rel?'href':'src', value=>$_->{"file"}});
|
||||||
$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(
|
$header .= html_tag(
|
||||||
'meta',
|
'meta',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user