perl: deobfuscate the year of v5.8 stability end
[sheet.git] / common.inc.plp
index 6d6a532ed348afa6021bb3c4dd674db1fbea6c76..fec7b570a263cd7875aff05418fb0c71d25e2948 100644 (file)
@@ -54,8 +54,7 @@ our $style;
 $header{content_type} = 'text/html; charset=utf-8';
 
 sub stylesheet {
 $header{content_type} = 'text/html; charset=utf-8';
 
 sub stylesheet {
-       my ($avail) = @_;
-       my @avail = ref $avail eq 'ARRAY' ? @{$avail} : $avail or return;
+       my @avail = qw( light dark circus mono red );
        my %styles = map {$_ => $_} @avail;
 
        if (defined( my $setstyle = $get{style} )) {
        my %styles = map {$_ => $_} @avail;
 
        if (defined( my $setstyle = $get{style} )) {
@@ -72,8 +71,8 @@ sub stylesheet {
                } or warn "Unable to create style cookie: $@";
        }
 
                } or warn "Unable to create style cookie: $@";
        }
 
-       $style ||= $styles{$_} for $cookie{style} || ();
        my $setstyle = $style;
        my $setstyle = $style;
+       $style ||= $styles{$_} for $cookie{style} || ();
        $style ||= $avail[0];
        return $setstyle;
 }
        $style ||= $avail[0];
        return $setstyle;
 }
@@ -127,7 +126,6 @@ sub Html {
        }
 
        # default fallbacks
        }
 
        # default fallbacks
-       $meta->{stylesheet} ||= [qw( light dark circus mono red )];
        $meta->{charset} ||= 'utf-8';
        $meta->{lang} ||= 'en';
 
        $meta->{charset} ||= 'utf-8';
        $meta->{lang} ||= 'en';
 
@@ -143,7 +141,7 @@ sub Html {
        unshift @{ $meta->{raw} }, (
                '<link rel="stylesheet" type="text/css" media="all" href="/light.css?1.20">',
        );
        unshift @{ $meta->{raw} }, (
                '<link rel="stylesheet" type="text/css" media="all" href="/light.css?1.20">',
        );
-       $meta->{stylesheet} = stylesheet($meta->{stylesheet});
+       $meta->{stylesheet} = stylesheet();
 
        if (my $img = $meta->{image}) {
                my $proto = sprintf('http%s://', !!$ENV{HTTPS} && 's');
 
        if (my $img = $meta->{image}) {
                my $proto = sprintf('http%s://', !!$ENV{HTTPS} && 's');
@@ -180,10 +178,7 @@ sub Html {
                say '<link rel="icon" type="image/png" href="/clip.png">';
                say for map { @{$_} } $meta->{raw} || ();
                say '<meta name="robots" content="noindex">' if $Dev;
                say '<link rel="icon" type="image/png" href="/clip.png">';
                say for map { @{$_} } $meta->{raw} || ();
                say '<meta name="robots" content="noindex">' if $Dev;
-               say "<script>$_</script>" for join($/,
-                       "if (m = window.matchMedia('(monochrome)'))",
-                       "(m.onchange = e => document.documentElement.classList.toggle('s-mono', e.matches))(m);",
-               );
+               say '<script src="/prefer.js"></script>';
                say '</head>';
                say '';
                say sprintf '<body id="%s">', $file;
                say '</head>';
                say '';
                say sprintf '<body id="%s">', $file;