]> Sergey Matveev's repositories - zk.git/commitdiff
Ability to force links/backs creation
authorSergey Matveev <stargrave@stargrave.org>
Thu, 8 May 2025 12:11:27 +0000 (15:11 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 8 May 2025 15:05:15 +0000 (18:05 +0300)
zk

diff --git a/zk b/zk
index 621cfa1062e1cbe7add742c99cedba05387ef8bb..7aa7a3a2b626ebedf89b8fd51a4138a1965b108c 100755 (executable)
--- a/zk
+++ b/zk
@@ -239,6 +239,8 @@ sub genHTML {
         print $out "<link rel=\"alternate\" type=\"text/plain\" title=\"src\" href=\"$fn.txt\" />\n";
     }
     print $out "</head><body><pre>";
+    my $doLinksForced = 0;
+    my $doBacksForced = 0;
     open(my $fh, "<", $page) or die "$!";
     while (<$fh>) {
         chop;
@@ -260,8 +262,14 @@ sub genHTML {
                 } else {
                     $_ = "<img src=\"$cols[1]\" />";
                 }
+            } elsif ($cols[0] eq "do-links") {
+                $doLinksForced = 1;
+                next;
+            } elsif ($cols[0] eq "do-backs") {
+                $doBacksForced = 1;
+                next;
             } else {
-                print STDERR "unknown $cols[0]\n";
+                die "unknown $cols[0] command\n";
             }
         } else {
             $_ = htmlescape $_;
@@ -275,7 +283,7 @@ sub genHTML {
     }
     close $fh;
     print $out "</pre>\n";
-    if ($doLinks and $#lnks != -1) {
+    if ($doLinksForced or ($doLinks and $#lnks != -1)) {
         print $out "<a id=\"links\"></a><table border=1><caption>Links</caption>\n";
         my $mtime;
         while (my ($i, $l) = each @lnks) {
@@ -286,7 +294,7 @@ sub genHTML {
         print $out "</table>\n";
     }
     @lnks = sort keys %{$backs{$page}};
-    if ($doBacks and $#lnks != -1) {
+    if ($doBacksForced or ($doBacks and $#lnks != -1)) {
         print $out "<a id=\"backs\"></a><table border=1><caption>Backlinks</caption>\n";
         my $rel;
         foreach my $l (@lnks) {