create new tag
, view all tags

Archive of InterwikiPluginDev Discussions

I've back-ported the $page feature and the better handling of punctuation to the March beta, and in the process found a bug and fixed it. Fix should apply directly to the alpha.

Test case is the following:

This uses an InterWikis rule mapping RFC onto http://www.faqs.org/rfcs/rfc$page.html (by the way, this would be a good rule for TWiki.org's Interwiki setup, as it provides hyperlinked RFCs - the current rule uses $name not $page, so should be fixed anyway.)

In the basic backport, every other RFC: link failed (as on this page at time of writing), because the $postfixPattern is greedy. Instead, I did the following - as a global in InterwikiPlugin.pm, I set:

$prefixPattern         = '(^|[\s\-\*\(])';
$interSiteNamePattern  = '([A-Z][A-Za-z]+';
$topicNamePattern      = '[a-zA-Z0-9_\/][a-zA-Z0-9\-\+\_\.\,\;\:\!\?\/]+?)';
$InterLinkPattern = "$interSiteNamePattern\:$topicNamePattern";
# $postfixPattern        = '([\s\.\,\;\:\!\?\)]*(\s|$))';
# For lookahead version:
$postfixLookaheadPattern        = '(?=[\s\.\,\;\:\!\?\)]*(\s|$))';

Then, in the (March beta based) outsidePREHandler, I used this (no need to return the result of last match as it's a lookahead only):

$_[0] =~ s/$prefixPattern($InterLinkPattern)$postfixLookaheadPattern/"$1" . &handleInterwiki("$2")/geo;

This would also simplify handleInterwikiSiteLink in the Alpha code, since it doesn't need to pass the postfix match result back and forth.

Hope this is clear - lookahead matching in Perl is very neat, and really could have been designed for this situation.

-- RichardDonkin - 24 Jul 2001

Thanks Richard. Fix is incorporated in plugin package.

-- PeterThoeny - 26 Jul 2001

I have found two problems with the InterwikiPlugin code.

The first was a trivial fix. The page portion of the Interwiki link would not allow an '=' to be used. This became a simple update of the $pagePattern variable.

$pagePattern    = '([a-zA-Z0-9_\/][a-zA-Z0-9\-\=\+\_\.\,\;\:\!\?\/]+?)';

The second problem was that the Interwiki link could not be used inside of a specific link. So the following modifications to outsidePREHandler() and handleInterwiki() along with the addition of embedInterwiki() allow this to happen.

sub outsidePREHandler
### my ( $text ) = @_;   # do not uncomment, use $_[0] instead

    $_[0] =~ s/$prefixPattern$sitePattern\:$pagePattern$postfixPattern/"$1" . &embedInterwiki($2,$3)/geo;
    $_[0] =~ s/\[\[\s*$sitePattern\:$pagePattern\s*\]\[/"[[" . &handleInterwiki($1,$2) . "]["/geo;

sub handleInterwiki
    my( $theSite, $theTopic ) = @_;

    &TWiki::Func::writeDebug( "- InterwikiPlugin::handleInterwikiSiteLink: (site: $theSite), (topic: $theTopic)" \) if $debug;

    my $text = "";
    if( defined( $interSiteTable{ $theSite } ) ) {
        my( $url, $help ) = split( /\s+/, $interSiteTable{ $theSite }, 2 );
        &TWiki::Func::writeDebug( "  (url: $url)" ) if $debug;
        if( $url =~ s/\$page/$theTopic/go ) {
            $text = $url;
        } else {
            $text = $url . $theTopic;
    } else {
        $text = "$theSite\:$theTopic";
    return $text;

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

sub embedInterwiki
    my ($theSite, $theTopic) = @_;

    if( defined( $interSiteTable{ $theSite } ) ) {
        my( $url, $help ) = split( /\s+/, $interSiteTable{ $theSite }, 2 );
        my $title = "";
        if( ! $suppressTooltip ) {
            $help =~ s/<nop>/&nbsp;/goi;
            $help =~ s/[\"\<\>]*//goi;
            $help =~ s/\$page/$theTopic/go;
            $title = " title=\"$help\"";

    $url = handleInterwiki ($theSite, $theTopic);
    $text = "<a href=\"$url\" $title>$theSite\:$theTopic&lt;/a>";

    &TWiki::Func::writeDebug( "  (url: $url), (help: $help)" ) if $debug;

    return $text;

-- GerardHickey - 11 Jan 2002

I'm glad to see the specific links + InterWiki fix, it makes them a lot more usable where you don't want the Wiki site name to interrupt the flow of a sentence. Also, have a look at EasierExternalLinking, which is quite an easy change to specific links making them easier to type.

-- RichardDonkin - 12 Jan 2002

I've been reviewing settings and use of InterwikiPlugin on my TWiki installation on a hosted domain and have a couple of questions. Some of the aliases are in the format of non-existent topic. I followed the url of one (OrgPatterns) and found that the page had moved. Thinking that might be reason that the alias showed up as a non-existant topic, I went to the new url, copied it and then when back to edit my InterWikis page and inserted the new url. I then went to test if this interWiki link would work and at first it did not. Then I noticed that the correct url had a "?" between the frontpage url and the particular topic so I went back and added "?" to the end of the url on my InterWikis page. Now my links to OrgPatterns wiki seem to work. However, the Alias listing for OrgPatterns still shows up as a non-existent topic. As a newbie to TWiki, I'd like to have a clearer understanding of what's going on here. My specific questions are:

  • What does it indicate if an alias shows up as a non-existent page? (This is the case for most of the aliases on my site.) See later note below.
  • When adding or editing the url for an alias, are there some general rules that must be followed? Eg. adding "?" to the end or the url. I notice some have this and others do not. Might such conventions be specific to different sites and if so, what should we look for?
  • What is the function of the "?" at the end of some urls?
  • Could you explain a little more about the meaning of the "Tooltip Text" (what it is, how it works, etc) or direct me to somewhere I can learn more about it.

A later note about the aliases formating: I noticed that the ones that showed up as non-existent topics were WikiWords. OK, it makes sense that TWiki was interpreting the alias as a topic link for a topic that did not exist. However, looking at the InterSiteLinkRules on TWiki.org, this isn't the case. I tried to edit that page just to see if there was some special formating but of course I could not.

I appreciate any help in better understanding of how InterwikiPlugin works - I plan on using it alot. Perhaps some of my questions as a newbie suggest additions to documentation for this plugin.

-- LynnwoodBrown - 16 Mar 2002

As with any WikiWord, a '?' at the end of a URL indicates a WikiWordThatDoesNotPointToAPage (like this one) - see TWikiDocumentation#Internal_Links. The Aliases listed on TWiki.InterSiteLinkRules are no different - they only get interpreted differently when you have Alias:PageStuff, i.e. the :PageStuff bit is what makes them be interpreted as aliases, e.g. MeatBall:FrontPage or Google:twiki+wiki.

PeterThoeny added <noautolink> ... </noautolink> around the body of InterSiteLinkRules, which prevents WikiWords being linked. You can either use this or put <nop> in front of specific words.

The tooltips are implemented using the TITLE attribute - try hovering your mouse over the links above, and do a View Source on this page to see how the link appears. Also, try viewing InterSiteLinkRules with ?raw=on suffixed so you can see the TWiki syntax used.

-- RichardDonkin - 17 Mar 2002

See InterwikiLinksForINCLUDE idea to %INCLUDE{}% an external page in InterwikiPlugin syntax.

-- PeterThoeny - 18 Jul 2002

(Hope this is the right place to ask about this, rather than in Support.) Why doesn't [[Wiki:ExtremeProgramming][this Interwiki link]] work when Wiki:ExtremeProgramming does? Is this an oversight in the InterwikiPlugin implementation or a misunderstanding of its use on my part?

[20 minutes later] Oh, wait. I just read InterwikiLinksForINCLUDE and saw DaveBoulton's 18 Jul 2002 comment about the same problem. Never mind. Hope this gets fixed some day -- seems really weird not to be able to use this great convenience inside the great convenience of the double-bracket notation.

-- MitchellModel - 25 Nov 2002

Yes, this would be very nice - I frequently want to do nicer link text for Interwiki links. I would like to see this for the EasierExternalLinking format, e.g. [[Wiki:ExtremeProgramming this Interwiki link]], as well as the traditional format.

You would probably need to look at CVS:lib/TWiki.pm, in the getRenderedVersion subroutine, where it does various sorts of external link, and then put a modified version of that code in the InterwikiPlugin, where it would run earlier. However, I now realise there's a patch for this above, see GerardHickey's comment. If you can test this out and do EasierExternalLinking as well, I think this would be well worth including in this plugin.

-- RichardDonkin - 26 Nov 2002

On TWikiReleaseLinkTool people talk of the need to change internal links on TWikiDotOrg when publishing as part of a release. They become interwiki links, e.g. from CoreTeam to TWiki:Codev/CoreTeam

I think that this is better written TWiki:Codev.CoreTeam because I don't see why the syntax of the Web.Topic component should change just because it is offsite. Indeed I think that the form with the slash is inconsistant and gratuitous whereas TWiki:Codev.CoreTeam is is a nice consistant extension of the existing syntax.

-- MartinCleaver - 16 Jan 2003

On testing I note that the form TWiki:Codev.CoreTeam doesn't work on TWikiDotOrg (so probably doesn't work in both AthensRelease and BeijingRelease too). In my opinion, this definitely a bug.

-- MartinCleaver - 16 Jan 2003

You are right, TWiki:Codev.CoreTeam is more consistent. The TWiki:Codev/CoreTeam format is not a bug of the Interwiki Plugin, the Plugin simply passes that string to the TWiki URL. The TWiki engine could (should) be enhanced to understand an extended path of /Web.TopicName in addition to the /Web/TopicName syntax. There was some discussion about this in the Codev web.

-- PeterThoeny - 17 Jan 2003

TWiki.org and TWikiAlphaRelease understand now TWiki:Codev.CoreTeam type links.

Updated also the Plugin to allow number character # in the page name.

-- PeterThoeny - 18 Jan 2003

A while back I updated to the latest version of TWiki. It is using version 1.0.3 of the Interwiki plugin.

Unfortunately I did not catch it until now, but several of my Interwiki links were broken because the plugin does not look inside the specific links (i.e. [<nop[ ][ ]]). I have gone back and added the following line to the ousidePREHandler() function.

    $_[0] =~ s/\[\[\s*$sitePattern:$pagePattern$postfixPattern\s*\]\[/"[[" . &handleInterwiki($2,$3) . "]["/geo;

This line is placed right after the existing regex. Can this line be included in future releases? It seems that it is a fairly common discussion from the comments above.


-- GerardHickey - 27 Jun 2003

The TWiki administrator at my office has made a nice change to InterwikiPlugin. Links like:


show up as one would expect, with the "Dictionary:" included on the front of each link. However, he's added:


so that double-colons allow only the WORD to show up in the external link. That is, the double-colon is a little like:


(that is, if you include the change that GerardHickey just hinted at)

He also has made it so that %20 is included in the Interwiki link. For example, right now:


does not get linked -- I think this is because of the presence of the % sign. He's changed it so that %20 is allowed. This makes it nice when people link to files stored on a public file share that happens to have spaces in it.

Just a thought. It works well for us.

-- TedPavlic - 22 Aug 2003

%20 should already work with the latest Plugin.

Good idea with the double colon. Wondering, possibly use other chars? Because :: conflicts with Perl program documentation (among other languages)

-- PeterThoeny - 23 Aug 2003

Enhancement to accept Interwiki links also in

TWiki URL's.

-- PatrickNomblot - 27 Oct 2003

The InterwikiPlugin located in the latest TWikiAlphaRelease (CVS:lib/TWiki/Plugins/Interwiki.pm) supports now square bracket links, see InterWikiLinksDoNotWorkInBracketNotation. Sorry Patrick and Gerard, I looked at this dev page too late.

-- PeterThoeny - 16 Feb 2004

Small addition: Support for [[Site:Page label]] (besides the [[Site:Page][label]] [[Site:Page]] rules of previous upgrade)

-- PeterThoeny - 16 Feb 2004

Perhaps I'm missing something obvious, but the latest packaged version of this plugin is not working quite right for me.

InterWiki links work just fine in my TWiki web, which for me is called System at http://www.theoretic.com/System/SitePreferences but they do not work in other webs, rendering either as plain text or as non-existant topics when forced with double brackets.

-- AdamTheo - 15 May 2004

Sounds like you renamed the TWiki web but not reassigned the SYSTEMWEB (or whatever that preference is). The plugin then counts only for the web into which it is installed.

-- MartinCleaver - 15 May 2004

Sorry, what setting is this you are talking about? Is it a setting in the TWiki.cfg, TWikiPreferences, or WebPreferences? I'm not familiar with a setting that determines when Plugins work, other than the settings under TWikiPreferences showing which Plugins are installed. Thanks.

  • Looks like the $twikiWebname setting in TWiki.cfg is not set to the new name. -- PeterThoeny - 20 May 2004

-- AdamTheo - 16 May 2004

I've found another bug: Interwiki links in specific bracketed links such as [[!TWiki:Support.Changes][Support Changes]] that are included from another topic through %INCLUDE{Sandbox.InterwikiLink}% do not work. When this Interwiki link is INCLUDE'd, TWiki strips the colon, so TWiki interprets it as a new page to create in the current web.

  • Not sure I understand what you would like to do. -- PeterThoeny - 20 May 2004
    • When I create a topic with some Interwiki-ized links in brackets (specific links), then %INCLUDE{}% that topic into another topic, the Interwiki links are not rendered properly. They are instead stripped of the colon, and rendered as a link to a non-existant topic. Take a look at http://www.theoretic.com for an example. Over on the far left hand side of the page, under the "People" box. Those links are INCLUDED from the System.PeopleMenu topic, but as you can see, are not renederd properly. _An update: it seems that the Interwiki links INCLUDED from another topic work if the INCLUDED topic is from the same web, but not if it's INCLUDED from another web.

-- AdamTheo - 20 May 2004

And another bug: The plugin won't catch Interwiki links that are immediately preceeded by a greater than character (>), such as part of an HTML tag. For example:


  • This is spec, Interwiki links require a leading space or parenthesis, same as for WikiWord links. -- PeterThoeny - 20 May 2004
    • Ah, ok, I forgot about that. Alright, complaint withdrawn -- AdamTheo - 20 May 2004

-- AdamTheo - 20 May 2004

Adam, maybe you need to be using INCLUDINGTOPIC or INCLUDINGWEB instead. See TWikiVariables#INCLUDINGTOPIC_name_of_topic_tha

Also if you renamed the user-page web from Main to something else, you also need to change the name of the User's web in TWiki.cfg

-- MattWilkie - 21 May 2004

Yeah, I've changed the TWiki web in the TWiki.cfg file. And I doubt using INCLUDINGTOPIC/INCLUDINGWEB would help, since I only use absolute references in the links.

-- AdamTheo - 21 May 2004

Hmm... no one's able to re-create this problem? I guess I'll try re-installing the plugin, and re-evaluating my setup.

-- AdamTheo - 26 May 2004

Adam, not sure but you might hit a bug? Possibly related to the fact that TWiki fixes WikiWord links if the webs are different of the including topic and included topic. This might result in a bug with Interwiki links in square brackets.

-- PeterThoeny - 02 Jun 2004

Copied from Codev.WeDontKnowIt:

The InterwikiPlugin is shipped with the release, so I'm reporting an issue against it here instead of the dev topic.

The tooltip associated with twiki.org is

"... on the TWiki site, we know it!"

I've never been sure if this is just bad English, or if there is something I'm missing. What do we know? What does everyone else know that I don't? What is this trying to say?

Can we drop the "we know it!" bit please? Or replace it with something that makes a bit more sense, like "... on the TWiki site, the home of TWiki!"

-- CrawfordCurrie - 24 Aug 2004


-- MartinCleaver - 24 Aug 2004

Makes sense, thanks for caring for the details.

Updated the InterWikis topic in the InterwikiPlugin package; will be shipped with TWikiRelease01Sep2004.

-- PeterThoeny - 25 Aug 2004

I haven't tried this yet, but does Interwiki support web-centric InterWiki files? By that I mean, does the plugin look for InterWiki rules in the current web, incorporate those rules, then look in /data/Twiki/InterWikis for any global redirection rules? My goal is to provide individuals who maintain separate webs on our site the ability to create their own inter-site links without stepping on other people.


-- SteveRJones - 17 Sep 2004

The Plugin does not support this at this time. It is an easy enhancement though. We can take it into the next release if you provide a patch. Basically, in initPlugin you need to read the default TWiki.InterWikis topic text first (specified in prefs), then read the one in the current web of the same name, and merge both topic contents into one %interSiteTable.

Just reading the code, the Plugin is not clean: Better to use TWiki::Func::readTopicText() to read the topic text.

-- PeterThoeny - 29 Sep 2004

Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatpatch InterWikiPlugin.patch r2 r1 manage 4.6 K 2003-10-28 - 09:22 PatrickNomblot Make Interwiki links working in
Topic revision: r1 - 2006-04-23 - PeterThoeny
  • 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-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.