X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/8c3e7dc6481f4d61eca39c1250699302a329be56..7713d82f979bdb6eb47c41b4e3b2ce198b6acd2a:/common.inc.plp diff --git a/common.inc.plp b/common.inc.plp index 6330329..58d0964 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -54,7 +54,7 @@ sub stylesheet { } sub checkmodified { - my $lastmod; + my $lastmod = 0; for (@_) { my $mod = stat $_ or next; $mod = $mod->mtime or next; @@ -85,7 +85,9 @@ sub Html { $meta->{stylesheet} ||= [qw'light dark circus mono red terse']; $meta->{charset} ||= 'utf-8'; - ref $_ eq 'ARRAY' or $_ = [$_] for $meta->{raw}; + # convert options to arrays + ref $_ eq 'ARRAY' or $_ = [$_] + for grep {$_} $meta->{raw}, $meta->{description}, $meta->{keywords}; # optional amends push @{ $meta->{raw} }, ( @@ -97,11 +99,6 @@ sub Html { '', ) if $meta->{keys}; - # flatten arrays - ref $_ eq 'ARRAY' and $_ = join ' ', @$_ for $meta->{description}; - ref $_ eq 'ARRAY' and $_ = join ', ', @$_ for $meta->{keywords}; - ref $_ eq 'ARRAY' and $_ = join "\n", @$_ for $meta->{raw}; - # other vars my $Dev = $ENV{HTTP_HOST} =~ /\bdev\./; my ($file) = $ENV{SCRIPT_FILENAME} =~ m{ ([^/]+) \.plp$ }x; @@ -115,13 +112,15 @@ sub Html { $meta->{title} - - - - EOT + say sprintf '', EscapeHTML($_) + for join(' ', @{ $meta->{description} }) || (); + say sprintf '', EscapeHTML($_) + for join(', ', @{ $meta->{keywords} }) || (); + say ''; + say ''; say for stylesheet($meta->{stylesheet}); - say for $meta->{raw} || (); + say for map { @{$_} } $meta->{raw} || (); say '' if $Dev; say qq{\n\n};