]> Sergey Matveev's repositories - zk.git/commitdiff
Ability to disable links/backs generation
authorSergey Matveev <stargrave@stargrave.org>
Thu, 8 May 2025 11:46:17 +0000 (14:46 +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 8a4c90adf18a06d1f1b307ace17edcc2a8118d36..bebc2eee3064a5a7cdc88e0cebd9df53371780a6 100755 (executable)
--- a/zk
+++ b/zk
@@ -65,13 +65,13 @@ quickly open results in the editor.
 
 =item *
 
-C<E<gt> URL[ optional text]E<lt>CRE<gt>> on a separate line will add a
-link to the specified URL (with optional text). Pay attention that line
-contains carriage-return character at the end.
+C<E<gt> URL[ optional text]\r> on a separate line will add a link to the
+specified URL (with optional text). Pay attention that line contains
+carriage-return character at the end.
 
 =item *
 
-C<I URL[ alt]E<lt>CRE<gt>> on a separate line will add an image with
+C<I URL[ alt]\r> on a separate line will add an image with
 optional alternative text similarly as link is specified.
 
 =back
@@ -96,6 +96,13 @@ to other pages. It also will include all backlinks in them. Each
 directory will also contain index page with links to all
 existing pages in current directory and to subdirectories.
 
+=head1 (BACK)LINKS GENERATION
+
+Set C<ZK_DO_LINKS=0> to disable automatic links-table creation in the
+HTML output. Set C<ZK_DO_BACKS=0> to disable automatic backlinks-table.
+If C<do-links\r> line is presented, then links-table is forcefully generated.
+C<do-backs\r> generated backlinks table.
+
 =head1 HISTORY
 
 Older version of that script, written on Z shell, can be found in Git history.
@@ -117,6 +124,11 @@ sub usage {
 
 usage if $#ARGV == -1;
 
+my $doLinks = ((not exists $ENV{ZK_DO_LINKS}) or
+    ($ENV{ZK_DO_LINKS} eq "1")) ? 1 : 0;
+my $doBacks = ((not exists $ENV{ZK_DO_BACKS}) or
+    ($ENV{ZK_DO_BACKS} eq "1")) ? 1 : 0;
+
 my %mtimes;
 my %sizes;
 my %cats;
@@ -263,7 +275,7 @@ sub genHTML {
     }
     close $fh;
     print $out "</pre>\n";
-    if ($#lnks != -1) {
+    if ($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) {
@@ -274,7 +286,7 @@ sub genHTML {
         print $out "</table>\n";
     }
     @lnks = sort keys %{$backs{$page}};
-    if ($#lnks != -1) {
+    if ($doBacks and $#lnks != -1) {
         print $out "<a id=\"backs\"></a><table border=1><caption>Backlinks</caption>\n";
         my $rel;
         foreach my $l (@lnks) {