When I first installed the March beta, I got the
InterwikiPlugin working with no problem at all. I recently upgraded our live TWiki site to the March beta, and discovered that Interwiki had stopped working, although I basically moved the test site over to the live site intact, with no changes to the Plugins web. Of course, something else may have changed at the same time...
Anyway, on investigating this with various writeDebug statements in the initPlugin sub of
InterwikiPlugin.pm, I found that the whole
Plugins.InterWikis.txt file was being read in to the first item of @data, i.e. the first array item contained the entire file. The line separators were \r\n, not just \n. The output of a foreach loop into $line through the @data array read:
line = * Wiki http://c2.com/cgi/wiki?^M
* TWiki http://twiki.org/cgi-bin/view/^M
* ZWiki http://joyful.com/zwiki/^M
I fixed this by adding a line before the map/grep line, as follows:
@data = map { split /\r\n/ } @data; # Split into lines
@data = grep { /^\t\*\s.*$/ } @data; # avoid comments
@data = map { split /^\t\*\s/ } @data; # remove starting \t*\s
@data = map { split /\s+/ } @data; # obtain key->value
It seems like all TWiki topics use \r\n for line separators (at least when edited from Windows), so I can't see how this would ever have worked as-is.
I'm using Red Hat Linux 6.2, Perl 5.005_03. Does anyone have any ideas on this?
--
RichardDonkin - 19 Jun 2001
Could you upgrade to the latest
InterwikiPlugin? The lates version is based on TWiki tables, and the reg-exp does not match the end of the line, so line endings do not matter:
@data = map { split /\s+/, $_, 2 }
map { s/^\|\s*$interSiteNamePattern\s*\|\s*(.*?)\s*\|\s*(.*?)\s*\|.*$/$1 $2 $3/os ; $_ }
grep { /^\|\s*$interSiteNamePattern\s*\|.*?\|.*?\|/ } @data;
--
PeterThoeny - 19 Jun 2001
OK, will try this. However, the problem was not with the REs but with the <IN> element sucking in the entire file into $data[0] - i.e. somehow the input record separator, $/, was wrong, or perhaps the file was opened in binmode by default? I'm not a Perl guru so not sure how this happened, or why behaviour changed on moving the identical data and code into live TWiki site (on same machine, just a different directory).
Could you let me know how the end of line encoding is supposed to work in TWiki? Is it client-dependent, i.e. pages use \r\n or \n or \r depending on last client that edited them? Or is it standard, i.e. \r\n is used consistently?
--
RichardDonkin - 20 Jun 2001
With browsers you can't assume any line ending, it can be
\r\n,
\n or
\r depending on the client platform.
This problem will go away if
TWiki::Store::readFile() is used instead of file open. This is a To Do item as stated in
InterwikiPluginEarlyDev.
--
PeterThoeny - 23 Jun 2001