use EscapeHTML() from PLP v3.23
[sheet.git] / source.plp
index db3a4002876ac2ae0313cff324cc6f3cbb5a9dcf..7640ae00b1210e2f08de4a12f0068af018a22c20 100644 (file)
@@ -1,11 +1,5 @@
-<:
-use utf8;
-use strict;
-use warnings;
-
-our $VERSION = 'v1.0';
-
-$header{content_type} = "text/html; charset=utf-8";
+<(common.inc.plp)><:
+       our $VERSION = 'v1.0';
 
 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  "http://www.w3.org/TR/html4/loose.dtd">
@@ -14,13 +8,7 @@ $header{content_type} = "text/html; charset=utf-8";
 <head>
 <meta http-equiv="content-type" content="<:= $header{content_type} :>">
 <title>sheet page source code</title>
-<link rel="stylesheet" type="text/css" media="all" href="/base.css"><:
-       my %styles = map {$_ => $_} qw(dark mono red);
-       our $style = exists $get{style} && $styles{$get{style}} || 'light';
-       printf(qq{\n<link rel="%s" type="text/css" media="all" href="%s" title="%s">},
-               $_ eq $style ? 'stylesheet' : 'alternate stylesheet', "/$_.css", $_
-       ) for keys %styles;
-:>
+<:= stylesheet(qw'light dark mono red') :>
 </head>
 
 <body id="source">
@@ -36,7 +24,7 @@ if (not $source) {
        print '<ul>'."\n";
        for (glob '*.plp') {
                chomp;
-               printf '<li><a href="/source/%s">%1$s</a></li>'."\n", Entity($_);
+               printf '<li><a href="/source/%s">%1$s</a></li>'."\n", EscapeHTML($_);
        }
        print "</ul>\n\n";
 }
@@ -74,8 +62,8 @@ else {
                my $tag = $_->[0] && ($TYPETAG{ $_->[0] } || 'span');
                my $arg = '';
                print "<$tag$arg class=\"sy-\l$_->[0]\">" if $tag;
-               if ($_->[0] eq 'Constant'
-               and $_->[1] =~ s{^(['"])(/?[a-z0-9_.]+\.(?:plp?|css|js))(?=\1$)}{}) {
+               if (!$_->[0] || $_->[0] eq 'Constant'
+               and $_->[1] =~ s{^(['"]?)(/?[a-z0-9_.]+\.(?:plp?|css|js))(?=\1$)}{}) {
                        printf '%s<a href="%s">%s</a>', $1, "/source/$2", $2;
                }
                if (!$_->[0] and $_->[1] =~ s/^(\s*)([A-Z]\w+(?:::\w+)+)(?![^;\s])//) {
@@ -88,11 +76,13 @@ else {
 }
 :>
 <p class="footer">
-       <a href="/" rel="home">sheet.shiar.nl</a>/source.<a href="/source/source.plp" rel="code">plp</a>
-       <a href="http://git.shiar.nl/sheet.git" rel="vcs-git" title="Git repository"><:= $VERSION :></a>
+       <a href="/" rel="home">sheet.shiar.nl</a>/source.<a href="/source/source.plp"
+        rel="code" title="Written in Perl">plp</a>
+       <a href="http://git.shiar.nl/sheet.git/history/HEAD:/source.plp"
+        rel="vcs-git" title="Git repository"><:= $VERSION :></a>
        created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
-       <a title="Licensed under the GNU Affero General Public License, version 3" rel="copyright"
-          href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">AGPLv3</a>
+       <a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html" rel="copyright"
+        title="Licensed under the GNU Affero General Public License, version 3">AGPLv3</a>
 </p>
 
 </html>