From: Mischa POSLAWSKY Date: Sun, 18 Oct 2009 18:36:10 +0000 (+0000) Subject: remember given style option in cookie X-Git-Tag: v1.3~97 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/639fdc8bc76794c1ed49ce7ea11cc18c381f8de6 remember given style option in cookie --- 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", $_