X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/effd000ff281f2187bf653b6e1c6aa0fc796c5f9..a93c5c61b18192c5f74256e3cb18e7f1cd2034d5:/source.plp diff --git a/source.plp b/source.plp index e645cd2..358bf84 100644 --- a/source.plp +++ b/source.plp @@ -43,13 +43,18 @@ Html({ say ''; -if (not $source) { - print "

Source files

"; +if (not $source or -d $source) { + PLP_START { + print "

Source files

"; + }; + + if ($source and $source ne 'tools') { + Abort("Directory index not permitted", '403 source not allowed'); + } print "

Project code distributed under the AGPL. Please contribute back.

"; say '\n"; @@ -74,6 +79,16 @@ else { -r $source or Abort("Requested file not found", '404 source not found'); my $size = (stat $source)->[7]; + my $cachefile = "source/$source.html"; + if (-e $cachefile and (stat $cachefile)->[9] >= (stat $source)->[9]) { + say '
';
+		print ReadFile($cachefile);
+		say '
'; + exit; + } + open my $cache, '>', $cachefile + or Alert("Could not save cache", "Opening $cachefile failed: $!");; + if (my $hl = eval { $size < 32_768 or die 'large files take too long to parse'; require Text::VimColor; @@ -89,6 +104,7 @@ else { Statement => 'strong', Error => 'em', Todo => 'em', + PreProc => 'strong', ); say '
';
@@ -110,6 +126,7 @@ else {
 
 			$line = qq(<$tag class="sy-\l$type">$line) if $tag;
 			print $line;
+			print {$cache} $line if $cache;
 		}
 		say '
'; }