4 my $source = $ENV{PATH_INFO};
7 :><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
8 "http://www.w3.org/TR/html4/loose.dtd">
12 <meta http-equiv="content-type" content="<:= $header{content_type} :>">
13 <title><:= $source :> source code</title>
14 <meta name="description" content="<:=
15 $source ? "Source code of local $source file"
16 . ", with syntax highlighted and references linked."
17 : 'Index of source files for this site.'
19 <meta name="keywords" content="sheet, cheat, source, code, perl, plp, html, agpl">
20 <:= stylesheet(qw'light dark mono red') :>
21 <link rel="icon" type="image/png" href="/clip.png">
28 print "<h1>Source files</h1>";
30 print "<p>Project code distributed under the AGPL. Please contribute back.</p>";
34 printf '<li><a href="/source/%s">%1$s</a></li>'."\n", EscapeHTML($_);
39 print "<h1>Source of $source</h1>\n";
41 if ($source =~ m{(?:/|^)\.}) {
42 die "File request not permitted\n";
44 elsif ($source =~ s{::}{/}g or !-e $source) {
47 -e ($_ = "$INC[$_]/$source") or next;
52 -r $source or die "Requested file not found\n";
54 if (eval { require Text::VimColor and Text::VimColor->VERSION(0.12) }) {
55 delete $Text::VimColor::SYNTAX_TYPE{Underlined};
57 Statement => 'strong',
62 my $hl = Text::VimColor->new(
64 vim_options => [@Text::VimColor::VIM_OPTIONS, '+:set enc=utf-8'],
66 my $parsed = $hl->marked;
69 my $tag = $_->[0] && ($TYPETAG{ $_->[0] } || 'span');
71 print "<$tag$arg class=\"sy-\l$_->[0]\">" if $tag;
72 if (!$_->[0] || $_->[0] eq 'Constant'
73 and $_->[1] =~ s{^(['"]?)(/?[a-z0-9_.]+\.(?:plp?|css|js))(?=\1$)}{}) {
74 printf '%s<a href="%s">%s</a>', $1, "/source/$2", $2;
76 if (!$_->[0] and $_->[1] =~ s/^(\s*)([A-Z]\w+(?:::\w+)+)(?![^;\s])//) {
77 printf '%s<a href="%s">%s</a>', $1, "/source/$2", $2;
79 print Text::VimColor::_xml_escape($_->[1]);
80 print "</$tag>" if $tag;
85 print "<pre>\n", EscapeHTML(ReadFile($source)), "</pre>\n";
90 <a href="/" rel="home">sheet.shiar.nl</a>/source.<a href="/source/source.plp"
91 rel="code" title="Written in Perl">plp</a>
92 <a href="http://git.shiar.nl/sheet.git/history/HEAD:/source.plp"
93 rel="vcs-git" title="Git repository"><:= $VERSION :></a>
94 created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
95 <a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html" rel="copyright"
96 title="Licensed under the GNU Affero General Public License, version 3">AGPLv3</a>