perl: version descriptions after release dates
[sheet.git] / source.plp
index 43fddb635f7e340801a89525f61861bdb69a6a22..d7d7cb50da39a02247be400b341b7b63ae770bee 100644 (file)
@@ -29,7 +29,7 @@ if ($source =~ s{(?<=\Q.inc.pl\E)/jsonp?$}{} and -r $source) {
 
 Html({
        title => "$source source code",
-       version => '1.2',
+       version => '1.3',
        description => !$source ? 'Index of source files for this site.' : [
                "Source code of the $source file at this site,",
                "with syntax highlighted and references linked."
@@ -43,13 +43,18 @@ Html({
 
 say '';
 
-if (not $source) {
-       print "<h1>Source files</h1>";
+if (not $source or -d $source) {
+       PLP_START {
+               print "<h1>Source files</h1>";
+       };
+
+       if ($source and $source ne 'tools') {
+               Abort("Directory index not permitted", '403 source not allowed');
+       }
 
        print "<p>Project code distributed under the AGPL. Please contribute back.</p>";
        say '<ul>';
-       for (glob '*.plp') {
-               chomp;
+       for (glob($source ? "$source/*" : '*.plp')) {
                say '<li>', showlink($_, "/source/$_");
        }
        say "</ul>\n";
@@ -81,6 +86,7 @@ else {
                say '</pre>';
                exit;
        }
+       -e or mkdir for $cachefile =~ s{[^/]+\z}{}r; # dirname
        open my $cache, '>', $cachefile
                or Alert("Could not save cache", "Opening $cachefile failed: $!");;
 
@@ -99,6 +105,7 @@ else {
                        Statement => 'strong',
                        Error     => 'em',
                        Todo      => 'em',
+                       PreProc   => 'strong',
                );
 
                say '<pre>';