common: prefix version numbers by unlinked 'version'
[sheet.git] / common.inc.plp
index 563c0e48ba5bdfa8986592c91fb46f65d7287732..11f1fb4a18a7e2959048542198551c2845204c40 100644 (file)
@@ -23,15 +23,15 @@ $header{content_type} = 'text/html; charset=utf-8';
 sub stylesheet {
        my %styles = map {$_ => $_} @_;
 
-       if (exists $get{style}) {
-               $style = $styles{ $get{style} };
+       if (defined( my $setstyle = $get{style} )) {
+               $style = $styles{ $setstyle };
                eval {
                        require CGI::Cookie;
                        my $cookie = CGI::Cookie->new(
                                -name    => 'style',
-                               -value   => $style,
+                               -value   => $setstyle || '',
                                -path    => '/',  # site-wide; current page is confusing to most users
-                               -expires => $style ? '+5y' : '-1d',
+                               -expires => $setstyle ? '+5y' : '-1d',
                        ) or die "empty object returned\n";
                        AddCookie($cookie->as_string);
                } or warn "Unable to create style cookie: $@";
@@ -41,7 +41,7 @@ sub stylesheet {
 
        return join "\n", map { sprintf(
                '<link rel="%s" type="text/css" media="all" href="%s" title="%s">',
-               $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.6", $_
+               $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css?1.7", $_
        ) } @_;
 }
 
@@ -77,6 +77,8 @@ sub Html {
        $meta->{stylesheet} ||= [qw'light dark circus mono red terse'];
        $meta->{charset} ||= 'utf-8';
 
+       ref $_ eq 'ARRAY' or $_ = [$_] for $meta->{raw};
+
        # optional amends
        push @{ $meta->{raw} }, (
                '<!--[if lte IE 6]><style> .help dl.legend dt {margin:0 0 1px} </style><![endif]-->',
@@ -107,19 +109,31 @@ sub Html {
 <title>$meta->{title}</title>
 <meta name="description" content="$meta->{description}">
 <meta name="keywords" content="$meta->{keywords}">
+<meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="icon" type="image/png" href="/clip.png">
 EOT
        print $_, "\n" for $meta->{stylesheet} || ();
        print $_, "\n" for $meta->{raw} || ();
        print qq{</head>\n\n<body id="$file">\n};
 
+       # dev indicator
+       printf '<p style="%s">beta</p>', join('; ',
+               'position: fixed',
+               'right: 1em',
+               'opacity: .5',
+               'border: 1ex solid red',
+               'border-width: 1ex 0',
+               'z-index: 1',
+               'background: inherit',
+       ) if $ENV{HTTP_HOST} =~ /\bdev\./;
+
        # prepare trailing output
        PLP_END {
                print <<"EOT";
 <p class="footer">
        <a href="/" rel="start">sheet.shiar.nl</a>/$file.<a href="/source/$file.plp"
         rel="source" title="Written in Perl">plp</a>
-       <a href="http://git.shiar.nl/sheet.git/history/HEAD:/$file.plp"
+       version <a href="http://git.shiar.nl/sheet.git/history/HEAD:/$file.plp"
         rel="vcs-git" title="Git repository">$meta->{version}</a>
        created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
        <a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html" rel="license copyright"