X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/28151a28db84c6d6018232f36c0003ecd562b3f0..639fdc8bc76794c1ed49ce7ea11cc18c381f8de6:/common.inc.plp diff --git a/common.inc.plp b/common.inc.plp index 576e39c..28a14ce 100644 --- a/common.inc.plp +++ b/common.inc.plp @@ -12,7 +12,20 @@ $header{content_type} = 'text/html; charset=utf-8'; sub stylesheet { my %styles = map {$_ => $_} @_; - $style = exists $get{style} && $styles{$get{style}} || $_[0]; + + if (exists $get{style}) { + $style = $styles{ $get{style} }; + require CGI::Cookie; + AddCookie(CGI::Cookie->new( + -name => 'style', + -value => $style, + -path => '/', # site-wide; current page is confusing to most users + -expires => $style ? '+5y' : '-1d', + )->as_string); + } + + $style ||= exists $cookie{style} && $styles{ $cookie{style} } || $_[0]; + return join "\n", map { sprintf( '', $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css", $_