X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/effd000ff281f2187bf653b6e1c6aa0fc796c5f9..598285f72ae22bca87d53a29651e7110a253b25b:/source.plp?ds=sidebyside diff --git a/source.plp b/source.plp index e645cd2..43fddb6 100644 --- a/source.plp +++ b/source.plp @@ -74,6 +74,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; @@ -110,6 +120,7 @@ else { $line = qq(<$tag class="sy-\l$type">$line) if $tag; print $line; + print {$cache} $line if $cache; } say ''; }