Welcome, Registration, and other StartingPoints; TWiki history & Wiki style; All the docs...

Navigation

%MYSIDEBAR%
This site is powered by the TWiki collaboration platform

_wremoId0

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 TWiki. 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{regex="on"}% display also the regular expression to match the alias
%ALIASES{"<topic>" merge="on,off"}% use aliases defined in <topic> by either merging or redefining the set of current aliases
%ALIAS{name="..." value="..." [regex="..."]}% defines an alias using regex to find it; if regex is not specified it defaults to the alias' name
%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 regex parameter in the %ALIAS{...}% tag might contain the two variables $start and $stop that help to match the boundaries of an alias consisting of non-alphabetic characters. Textile example:

%ALIAS{name="''" regex="$start''$stop" value="&rdquo;"}%
%ALIAS{name="``" regex="$start``$stop" value="&ldquo;"}%
%ALIAS{name="-" regex=" - " value=" &ndash; "}%
%ALIAS{name="--" regex=" -- " value=" &mdash; "}%
%ALIAS{name="(c)" regex="$start\(c\)$stop" value="&copy;"}%
%ALIAS{name="(r)" regex="$start\(r\)$stop" value="&reg;"}%
%ALIAS{name="(tm)" regex="$start\(tm\)$stop" value="&trade;"}%
%ALIAS{name="..." regex="$start\.\.\.$stop" value="&hellip;"}%
%ALIAS{name=",," regex="$start,,$stop" value="&bdquo;"}%
%ALIAS{name="1/2" regex="$start1/2$stop" value="&frac12;"}%
%ALIAS{name="1/4" regex="$start1/4$stop" value="&frac14;"}%
%ALIAS{name="3/4" regex="$start3/4$stop" value="&frac34;"}%

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

Name Value
MainWeb MainWeb
SandboxWeb SandboxWeb
TESTALIAS GREEN
TESTLINK TESTLINK
TWikiWeb TWikiWeb
UserWeb UserWeb
rtfm read the fine manual

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 TWikiSkins (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

  Pattern Substitution Correctness
1 TESTLINK yes, this is a link to TWiki.WebHome DONE
2 GREEN yes DONE
3 _TESTLINK no, _ is no word boundary DONE
4 TESTLINK_TESTLINK no, _ is no word boundary DONE
5 TESTLINK yes DONE
6 TESTLINKTESTLINK no, this is one word not being aliases DONE
7 read the fine manual yes, but be more polite to your users DONE
8 GREEN this should be a green link to https://mirror.egtvedt.no/avr32linux.org/twiki/bin/TESTALIAS DONE
9 TESTALIAS no, don't substitute inside a TWiki tag DONE
10 TESTALIAS no, don't substitute inside a TWiki tag DONE
11 [[TESTALIAS]] no, not even inside a nopped TWiki tag DONE
12 GREEN yes, ignores red DONE
13 %TESTALIAS% no, inside two % DONE
14 %TESTALIAS% no, this is inside two % DONE
15 %TESTALIAS% no. inside two % DONE
16 %TESTALIAS% no. inside two % DONE
17 %GREEN yes, no perc on the same line DONE
18 %GREEN yes, with a second % here DONE
19 %BLABLA GREEN% yes, this is no regular TWiki tag DONE
20 %BLABLA{TESTALIAS}% no, this is a regular TWiki tag DONE
21 %BLABLA{TESTALIAS}% no, albeit this is a nopped TWiki tag DONE

Plugin Info

Plugin Author: TWiki:Main/OthelloMaurer, TWiki:Main/MichaelDaum
Copyright ©: 2003, Othello Maurer; 2003-2006, Michael Daum
License: GPL (GNU General Public License)
Version: v1.32
Change History:  
10 Feb 2006: fixed use of uninitialized value (outch)
03 Feb 2006: prevent nested alias expansion; support convenience aliases for anchors on the same page
09 Dec 2005: added expl icite regex parameter for ALIAS
06 Dec 2005: fixed deprecation warning on a dakar install; added support for non-alphabetical aliases; fixed use of uninitialized values due to special chars in alias patterns; the ALIAS tag in WebAliases can be used to define global aliases now
27 Apr 2005: always read site aliases and then merge in web aliases
07 Apr 2005: TWiki:Main/MichaelDaum: major rewrite
30 Mar 2005: TWiki:Main/MichaelDaum: added alias area
  added fix to honor order of alias/unalias commands in a topic
23 Mar 2005: TWiki:Main/MichaelDaum: added list of test-cases
  rewrite of substitution code
  improved configurability
22 Mar 2005: TWiki:Main/MichaelDaum: prevent substitutions within html tags, twiki tags and twiki links
21 Mar 2005: TWiki:Main/MichaelDaum: allow arbitrary string substs
  configured via a list now (was tables)
  taking care not to replace inside html tags
1 Dec 2003: TWiki:Main.NielsKoldso: Non WikiWord aliases as an option
  More alias prefixes allowed
16 Oct 2003: Speedup
09 Oct 2003: Initial Version
CPAN Dependencies: none
Other Dependencies: none
Perl Version: 5.005
Plugin Home: http://TWiki.org/cgi-bin/view/Plugins/AliasPlugin
Feedback: http://TWiki.org/cgi-bin/view/Plugins/AliasPluginDev

-- TWiki:Main/OthelloMaurer - 09 Oct 2003
-- TWiki:Main/MichaelDaum - 10 Feb 2006

r2 - 2006-03-12 - 12:14:49 - TWikiAdminGroup
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding AVR32 Linux? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.AliasPlugin
Syndicate this site RSSATOM