X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/84f0630eace132ded7af839105d7e2d096eba5ad..29b407ddf91b653e6e8380f73e221628a392376f:/source.plp diff --git a/source.plp b/source.plp index 418a2c1..56193fb 100644 --- a/source.plp +++ b/source.plp @@ -1,7 +1,6 @@ <(common.inc.plp)><: -my $source = $ENV{PATH_INFO}; -$source =~ s{^/}{}; +my $source = $Request; if ($source =~ s{(?<=\Q.inc.pl\E)/jsonp?$}{} and -r $source) { # convert perl include to json construct @@ -28,7 +27,7 @@ if ($source =~ s{(?<=\Q.inc.pl\E)/jsonp?$}{} and -r $source) { Html({ title => "$source source code", - version => 'v1.1', + version => '1.1', description => !$source ? 'Index of source files for this site.' : [ "Source code of the $source file at this site,", "with syntax highlighted and references linked." @@ -39,21 +38,21 @@ Html({ stylesheet => [qw'light dark mono red'], }); -print "\n"; +say ''; if (not $source) { print "

Source files

"; print "

Project code distributed under the AGPL. Please contribute back.

"; - print '\n"; } else { - print "

Source of $source

\n"; + say "

Source of $source

"; if ($source =~ m{(?:/|^)\.}) { die "File request not permitted\n"; @@ -68,7 +67,6 @@ else { } -r $source or die "Requested file not found\n"; - require Encode; if (eval { require Text::VimColor and Text::VimColor->VERSION(0.12) }) { delete $Text::VimColor::SYNTAX_TYPE{Underlined}; my %TYPETAG = ( @@ -82,10 +80,10 @@ else { vim_options => [@Text::VimColor::VIM_OPTIONS, '+:set enc=utf-8'], ); my $parsed = $hl->marked; - print "
\n";
+		say '
';
 		foreach (@$parsed) {
 			my ($type, $contents) = @{$_};
-			$contents = Encode::decode_utf8($contents);
+			$contents = decode_utf8($contents);
 			my $tag = $type && ($TYPETAG{$type} || 'span');
 			my $arg = '';
 			print "<$tag$arg class=\"sy-\l$type\">" if $tag;
@@ -106,14 +104,14 @@ else {
 			print Text::VimColor::_xml_escape($contents);
 			print "" if $tag;
 		}
-		print "
\n"; + say '
'; } else { - print "
\n";
-		print EscapeHTML(Encode::decode_utf8(ReadFile($source)));
-		print "
\n"; + say '
';
+		print EscapeHTML(decode_utf8(ReadFile($source)));
+		say '
'; } - print "\n"; + say ''; }