AliasPlugin
Description
This plugin allows you to create arbitrary word aliases.
If you write down a word that has a defined alias, it will then be replaced with
the given text string. If that string is a string of the format
<web>.<topic>
it will be replaced by an appropriate TWiki link. Aliases take only effect within the boundaries
if
alias areas between %STARTALIASAREA% and %STOPALIASAREA% tags.
Aliases aren't replaced within html tags (
<html tag ... TESTALIAS ... >
), TWiki tags (
%INCLUDE... TESTALIAS ...%
) and TWiki links
(
[[TWiki.WebHome][TESTALIAS]]
). A word can be prevented of being substituted by
prefixing it with
<nop>
.
Configuration
Configuration of this plugin is done by writing
your aliases into a specific topic which defaults to the topic defined
by the
DEFAULT_ALIASES
variable (see below). This topic is looked up
in the current web. If it does not exist in the current web, the plugin will fallback to
the
DEFAULT_ALIASES
in the System.
Aliases defined in
DEFAULT_ALIASES
will be
used within the current web.
Aliases can be defined temporarily also, that is
they will only be taking effect within the current topic. Similarly, aliases can be
disabled. See the Syntax section for more details.
Syntax
This is the list of TWiki tags defined by this plugin.
Name |
Description |
%ALIASES% |
display all aliases |
%ALIASES{"<topic>" merge="on,off"}% |
use aliases defined in <topic> by either merging or redefining the set of current aliases |
%ALIAS{name="..." value="..." }% |
defines one new alias |
%STARTALIASAREA% |
mark the beginning of an alias area |
%STOPALIASAREA% |
mark the end of an alias area |
%UNALIAS% |
delete all aliases |
%UNALIAS{name="..."}%,%UNALIAS{"..."}% |
deletes one alias |
The aliases in the topic
DEFAULT_ALIASES
can be either defined using the %ALIAS{}%
macro or listed in the following way:
* <name1>: <value1>
* <name2>: <value2>
* <name3>: <value3>
...
Plugin Settings
- Set SHORTDESCRIPTION = Define aliases which will be replaced with arbitrary strings automatically
- restrict aliases to WikiWords
- Set ALIAS_WIKI_WORDS_ONLY = 0
- Set the topic holding some default aliases
Defined Aliases
%ALIAS{name="rtfm" value="read the fine manual"}%
%ALIASES%
Plugin Installation Instructions
Note: You do not need to install anything on the browser to use this plugin. The following instructions are for the administrator who installs the plugin on the server where TWiki is running.
- Download the ZIP file from the Plugin web (see below)
- Unzip
AliasPlugin.zip
in your twiki installation directory. Content: File: | Description: |
data/TWiki/AliasPlugin.txt | Plugin topic |
data/TWiki/WebAliases.txt | definition of site-wide aliases |
lib/TWiki/Plugins/AliasPlugin.pm | Plugin Perl module |
- On TWiki/Dakar: Visit
configure
in your TWiki installation, and enable the plugin in the {Plugins} section. You might add %STARTALIASAREA% and %STOPALIASAREA% surrounding the %TEXT% tag of the view and preview templates of your Skins (e.g. view.pattern.tmpl
and preview.pattern.tmpl
) to enable the AliasPlugin sitewide.
- On TWiki/Beijing: add the line marked with
+
to the script bin/view
(a similar change must be added to the bin/preview
script):
if( $viewRaw ) {
$text = &TWiki::Store::readTopicRaw( $webName, $topic );
} else {
( $meta, $text ) = &TWiki::Store::readTopic( $webName, $topic );
+ $text = "%STARTALIASAREA% $text %STOPALIASAREA%";
}
- On TWiki/Cairo: either of both might work (can someone confirm?)
Test-Cases
%STARTALIASAREA%
|
Pattern |
Substitution |
Correctness |
1 |
TESTLINK |
yes, this is a link to TWiki.WebHome |
|
2 |
TESTALIAS |
yes |
|
3 |
_TESTLINK |
no, _ is no word boundary |
|
4 |
TESTLINK_TESTLINK |
no, _ is no word boundary |
|
5 |
TESTLINK |
yes |
|
6 |
TESTLINKTESTLINK |
no, this is one word not being aliases |
|
7 |
rtfm |
yes, but be more polite to your users |
|
8 |
TESTALIAS |
this should be a green link to https://nats-www.informatik.uni-hamburg.de/bin/TESTALIAS |
|
9 |
TESTALIAS |
no, don't substitute inside a TWiki tag |
|
10 |
TESTALIAS |
no, don't substitute inside a TWiki tag |
|
11 |
[[TESTALIAS]] |
no, not even inside a nopped TWiki tag |
|
12 |
TESTALIAS |
yes, ignores red |
|
13 |
%TESTALIAS% |
no, inside two % |
|
14 |
%TESTALIAS% |
no, this is inside two % |
|
15 |
%TESTALIAS% |
no. inside two % |
|
16 |
%TESTALIAS% |
no. inside two % |
|
17 |
%TESTALIAS |
yes, no perc on the same line |
|
18 |
%TESTALIAS |
yes, with a second % here |
|
19 |
%BLABLA TESTALIAS% |
yes, this is no regular TWiki tag |
|
20 |
%BLABLA{TESTALIAS}% |
no, this is a regular TWiki tag |
|
21 |
%BLABLA{TESTALIAS}% |
no, albeit this is a nopped TWiki tag |
|
%STOPALIASAREA%
Plugin Info
--
TWiki:Main/OthelloMaurer - 09 Oct 2003
--
TWiki:Main/MichaelDaum - 21 Mar 2005