AliasPlugin

The AliasPlugin is a NeWikiPlugin that provides an improved page alias feature (the reverse of the SET command). An [{Alias}] shortcut is available.

Description#

Having been frustrated by the need to manually create alias pages just to hold the [{SET alias=TruePageName}] syntax (and since the alias breaks when the page is renamed) this plugin was born. (The SET syntax is backwards! I want to declare an alias on the 'true' named page, not the other way around!)

In most ways this plugin is a convenience, it requires just one parameter 'name' for the alias to be created. It then makes sure that page exists, and that some boilerplate content exists in it. The 'name' parameter is split on commas to allow one invocation to create multiple aliases. Two additional parameters are optional, 'extraHeader' is text that is appended in the boilerplate in the first section, 'extraBody' is appended in the second section. The boiler plate created is as follows:

 [TruePageName].  extraHeader
 ----
 extraBody
 %%warning
 Do Not Edit!  This alias page created by the AliasPlugin invocation on the page [TruePageName].
 [{SET alias=TruePageName}]
 %%  

On each invocation of this plugin it checks to make sure that the alias pages exist with the required boilerplate. When the page is renamed, the required boilerplate is different, and so the alias pages get edited. (See? Sorry for being cryptic here...)

Finally the boilerplate of the alias page contains a normal link back to the true page so the alias is listed as a referrer.

Arguments#

name
one or more comma-separated names for the page alias(es).
extraHeader
the optional text that is appended in the first section of the boilerplate.
extraBody
the optional text that is appended in the second section of the boilerplate.

Example #

To add an alias 'AnAliasToThisPage' to a page,

 [{Alias name='AnAliasToThisPage'}]
Generates this output (on this page):
[{AnAliasToThisPage}]
...and on the plugin-created alias page (named 'AnAliasToThisPage'):
[Alias Plugin]
----
%%warning
Do Not Edit! This alias page created by the AliasPlugin invocation on the page [Alias Plugin].

[{SET alias=Alias Plugin}]
%%

Using the boilerplate options:

 [{Alias name='AnotherAliasToThisPage' extraHeader='This is the header text.' extraBody='This is the body text.'}]
Generates this output (on this page):
[{AnotherAliasToThisPage}]
...and on the plugin-created alias page (named 'AnotherAliasToThisPage'):
[Alias Plugin].  This is the header text.

----
This is the body text.
%%warning
Do Not Edit! This alias page created by the AliasPlugin invocation on the page [Alias Plugin].

[{SET alias=Alias Plugin}]
%%