From 639fdc8bc76794c1ed49ce7ea11cc18c381f8de6 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sun, 18 Oct 2009 18:36:10 +0000 Subject: [PATCH] remember given style option in cookie --- common.inc.plp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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", $_ -- 2.30.0