To support RemoteWikiLinks, we need a local page which describes the remote server.
Somewhere on the local page, it should contain the RemoteWikiURL keyword followed by the URL on the same line, like this:
RemoteWikiURL: http://www.archlug.org/kwiki/?
You can optionally specify a RemoteWikiIcon to specify an icon to be used for any RemoteWikiLinks to that RemoteWikiURL like this:
RemoteWikiIcon: http://www.archlug.org/images/archlug-16x16.gif
Other Wikis:
Geographically close Wikis:
Shorthand for other sites:
Translations of ArchLUG Kwiki pages from English:
Translations From English:
Translations To English:
The code for this module was inspired by the
KwikiKwiki : RemoteWikiLinks but I present the current source code below. I use a custom Formatter module that dynamically pulls in formatting plugins instead of hacking the existing CGI/Kwiki/Formatter.pm module.
package RemoteWikiLinksPlugin;
$VERSION='0.1';
use strict;
use CGI::Kwiki ':char_classes';
# Relax the match for valid page names, not just wikiwords
my $WIKIWORD = "[$UPPER](?=[$WORD]*[$UPPER])(?=[$WORD]*[$LOWER])[$WORD]+";
$WIKIWORD = "[$ALPHANUM\-]+";
sub remote_wiki_link {
my ($self, $text) = @_;
$self->split_method($text,
qr{($WIKIWORD:[\w=\?\&\+\-\%\./]+)},
'remote_wiki_link_format',
);
}
sub remote_wiki_link_format {
my ($self, $text) = @_;
$text =~ m/($WIKIWORD):(\S+)/;
my $remote_wiki = $1;
my $remote_wiki_link;
my $remote_page = $2;
my $remote_wiki_icon;
if ( $self->driver->database->exists( $remote_wiki ) ) {
my $remote_wiki_text = $self->driver->database->load( $remote_wiki );
($remote_wiki_link) = $remote_wiki_text =~ m/\bRemoteWikiURL:\s*(\S+)/mi;
($remote_wiki_icon) = $remote_wiki_text =~ m/\bRemoteWikiIcon:\s*(\S+)/mi;
}
return qq{$text} unless ($remote_wiki && $remote_wiki_link);
my $html = "";
if ($remote_wiki_icon) {
$html = qq{<a href="$remote_wiki_link$remote_page">} .
qq{<img src="$remote_wiki_icon" border="0" } .
qq{title="Remote Wiki - $remote_wiki $remote_page" } .
qq{alt="Remote Wiki - $remote_wiki $remote_page" />} .
qq{</a>\ };
}
$html .= qq{<a href="$remote_wiki_link$remote_page">$remote_wiki:$remote_page</a>};
return qq{$html};
}
1;
That's it.