From 8c3e7dc6481f4d61eca39c1250699302a329be56 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 29 Mar 2017 17:34:08 +0200 Subject: [PATCH] common: join stylesheets html inline --- common.inc.plp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/common.inc.plp b/common.inc.plp index 33fad39..6330329 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -27,7 +27,9 @@ our $showkeys = !exists $get{keys} ? undef : $header{content_type} = 'text/html; charset=utf-8'; sub stylesheet { - my %styles = map {$_ => $_} @_; + my ($avail) = @_; + my @avail = ref $avail eq 'ARRAY' ? @{$avail} : $avail or return; + my %styles = map {$_ => $_} @avail; if (defined( my $setstyle = $get{style} )) { $style = $styles{ $setstyle }; @@ -43,12 +45,12 @@ sub stylesheet { } or warn "Unable to create style cookie: $@"; } - $style ||= exists $cookie{style} && $styles{ $cookie{style} } || $_[0]; + $style ||= exists $cookie{style} && $styles{ $cookie{style} } || $avail[0]; - return join "\n", map { sprintf( + return map { sprintf( '', $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.9", $_ - ) } @_; + ) } @avail; } sub checkmodified { @@ -99,7 +101,6 @@ sub Html { 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}; - ref $_ eq 'ARRAY' and $_ = stylesheet(@$_)."\n" for $meta->{stylesheet}; # other vars my $Dev = $ENV{HTTP_HOST} =~ /\bdev\./; @@ -119,7 +120,7 @@ sub Html { EOT - say for $meta->{stylesheet} || (); + say for stylesheet($meta->{stylesheet}); say for $meta->{raw} || (); say '' if $Dev; say qq{\n\n}; -- 2.30.0