5 no warnings 'qw'; # you know what you doing
6 no warnings 'uninitialized'; # save some useless checks for more legible code
7 use open IO => ':utf8';
9 use Shiar_Sheet::KeySigns qw(%sign); # dependant on $get{ascii}
12 our $showkeys = !exists $get{keys} ? undef :
13 ($get{keys} ne '0' && ($get{keys} || 'always'));
15 $header{content_type} = 'text/html; charset=utf-8';
18 my %styles = map {$_ => $_} @_;
20 if (exists $get{style}) {
21 $style = $styles{ $get{style} };
23 AddCookie(CGI::Cookie->new(
26 -path => '/', # site-wide; current page is confusing to most users
27 -expires => $style ? '+5y' : '-1d',
31 $style ||= exists $cookie{style} && $styles{ $cookie{style} } || $_[0];
33 return join "\n", map { sprintf(
34 '<link rel="%s" type="text/css" media="all" href="%s" title="%s">',
35 $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css", $_
43 $meta->{stylesheet} ||= [qw'light dark circus mono red terse'];
44 $meta->{charset} ||= 'utf-8';
47 push @{ $meta->{raw} }, (
48 '<!--[if lte IE 6]><style> .help dl.legend dt {margin:0 0 1px} </style><![endif]-->',
49 '<!--[if lte IE 7]><style> .help dl.legend dd {float:none} </style><![endif]-->',
50 !$showkeys ? '<style type="text/css"> .no {visibility:hidden} </style>'
51 : $showkeys eq 'ghost' ? '<style type="text/css"> .no, .alias {opacity:.5} </style>'
53 '<script type="text/javascript" src="/keys.js"></script>',
57 ref $_ eq 'ARRAY' and $_ = join ' ', @$_ for $meta->{description};
58 ref $_ eq 'ARRAY' and $_ = join ', ', @$_ for $meta->{keywords};
59 ref $_ eq 'ARRAY' and $_ = join "\n", @$_ for $meta->{rawstyle}, $meta->{raw};
60 ref $_ eq 'ARRAY' and $_ = stylesheet(@$_)."\n" for $meta->{stylesheet};
63 my $sep = $meta->{charset} eq 'utf-8' ? '•' : ' -- ';
64 my ($file) = $ENV{SCRIPT_FILENAME} =~ m{ ([^/]+) \.plp$ }x;
67 $header{content_type} = "text/html; charset=$meta->{charset}";
73 <meta http-equiv="content-type" content="$header{content_type}">
74 <title>$meta->{title}</title>
75 <meta name="description" content="$meta->{description}">
76 <meta name="keywords" content="$meta->{keywords}">
77 <link rel="icon" type="image/png" href="/clip.png">
79 print $_, "\n" for $meta->{stylesheet} || ();
80 print $_, "\n" for $meta->{raw} || ();
81 print qq{</head>\n\n<body id="$file">\n};
83 # prepare trailing output
87 <a href="/" rel="home">sheet.shiar.nl</a>/$file.<a href="/source/$file.plp"
88 rel="code" title="Written in Perl">plp</a>
89 <a href="http://git.shiar.nl/sheet.git/history/HEAD:/$file.plp"
90 rel="vcs-git" title="Git repository">$meta->{version}</a>
91 created by <a href="http://shiar.nl/" rel="author">Shiar</a> $sep
92 <a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html" rel="copyright"
93 title="Licensed under the GNU Affero General Public License, version 3">AGPLv3</a>