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') :>
27 print "<h1>Source files</h1>";
29 print "<p>Project code distributed under the AGPL. Please contribute back.</p>";
33 printf '<li><a href="/source/%s">%1$s</a></li>'."\n", EscapeHTML($_);
38 print "<h1>Source of $source</h1>\n";
40 if ($source =~ m{(?:/|^)\.}) {
41 die "File request not permitted\n";
43 elsif ($source =~ s{::}{/}g or !-e $source) {
46 -e ($_ = "$INC[$_]/$source") or next;
51 -r $source or die "Requested file not found\n";
53 if (eval { require Text::VimColor and Text::VimColor->VERSION(0.12) }) {
54 delete $Text::VimColor::SYNTAX_TYPE{Underlined};
56 Statement => 'strong',
61 my $hl = Text::VimColor->new(
63 vim_options => [@Text::VimColor::VIM_OPTIONS, '+:set enc=utf-8'],
65 my $parsed = $hl->marked;
68 my $tag = $_->[0] && ($TYPETAG{ $_->[0] } || 'span');
70 print "<$tag$arg class=\"sy-\l$_->[0]\">" if $tag;
71 if (!$_->[0] || $_->[0] eq 'Constant'
72 and $_->[1] =~ s{^(['"]?)(/?[a-z0-9_.]+\.(?:plp?|css|js))(?=\1$)}{}) {
73 printf '%s<a href="%s">%s</a>', $1, "/source/$2", $2;
75 if (!$_->[0] and $_->[1] =~ s/^(\s*)([A-Z]\w+(?:::\w+)+)(?![^;\s])//) {
76 printf '%s<a href="%s">%s</a>', $1, "/source/$2", $2;
78 print Text::VimColor::_xml_escape($_->[1]);
79 print "</$tag>" if $tag;
84 print "<pre>\n", EscapeHTML(ReadFile($source)), "</pre>\n";
89 <a href="/" rel="home">sheet.shiar.nl</a>/source.<a href="/source/source.plp"
90 rel="code" title="Written in Perl">plp</a>
91 <a href="http://git.shiar.nl/sheet.git/history/HEAD:/source.plp"
92 rel="vcs-git" title="Git repository"><:= $VERSION :></a>
93 created by <a href="http://shiar.nl/" rel="author">Shiar</a> •
94 <a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html" rel="copyright"
95 title="Licensed under the GNU Affero General Public License, version 3">AGPLv3</a>