Tags:
create new tag
view all tags

Undefined Topics Remain Unlinked

I have set out to deactivate the feature where an undefined topic links to the "create" page for that topic. I did a quick hack on Twiki.pm to do so. The diff is included below.

Basically, I'm turning lots of Twiki pages into documentation, and because I'm documenting program code, there are a lot of UndefinedWikiWords. Rather than <nop>ing all the undefined topics, I perform the views with "?linkundefs=0" appended to the link. Many wgets and htmldocs later, I have a PDF with active links to topics defined in the "book", and all undefined links deactivated. This also results in a much "prettier" layout, as the undefined words are not underlined, and have no question mark (?) following them, either.

With a trivial bit of work, the code could also use a personal preference as to whether or not to link undefined wiki words. However, Perl isn't my strong point, so I leave it to the gurus.



--- TWiki.pm.orig       Mon Oct 14 16:49:00 2002
+++ TWiki.pm    Mon Oct 14 16:58:41 2002
@@ -75,6 +75,7 @@
         $superAdminGroup $doSuperAdminGroup
         $cgiQuery @publicWebList
         $formatVersion $OS
+       $linkundefs
     );

 # TWiki::Store config:
@@ -138,7 +139,6 @@

 $formatVersion = "1.0";

-
 # =========================
 sub initialize
 {
@@ -241,6 +241,8 @@
     }
 #/AS

+    $linkundefs = getLinkUndefs();
+
     return ( $topicName, $webName, $scriptUrlPath, $userName, $dataDir );
 }

@@ -642,6 +644,14 @@
 }

 # =========================
+sub getLinkUndefs
+{
+    my $lu = 0;
+    $lu = int( $cgiQuery->param( 'linkundefs' ) ) if( $cgiQuery );
+    return $lu;
+}
+
+# =========================
 sub getViewUrl
 {
     my( $theWeb, $theTopic ) = @_;
@@ -1774,7 +1784,7 @@
             return $text;
         }

-    } elsif( $doLink ) {
+    } elsif( $doLink && $linkundefs ) {
         $text .= "<span style='background : $newTopicBgColor;'>"
               .  "<font color=\"$newTopicFontColor\">$theLinkText</font></span>"
               .  "<a href=\"$scriptUrlPath/edit$scriptSuffix/$theWeb/$theTopic?topicparent=$webName.$topicName\">?</a>";
@@ -1816,7 +1826,7 @@
         return "$thePreamble$theText"; # no link if no topic
     }

-    return internalLink( $thePreamble, $web, $topic, $theText, $anchor, 1 );
+    return internalLink( $thePreamble, $web, $topic, $theText, $anchor, $linkundefs );
 }

 # =========================


-- EricMitchell - 15 Oct 2002
Topic revision: r1 - 2002-10-15 - EricMitchell
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.