Extension:Glossary

Related Extensions
An alternative version of this extension can be found at Extension:Terminology

What can this extension do?
Ever been reading a technical article with lots and lots of acronyms? Unless you know all the terminology they are using, it can be really frustrating trying to understand what the author means.

This extension allows wiki authors to define a list of acronyms and their definitions on a special page. Whenever that acronym is found, it will be highlighted and mousing over it will reveal the definition in a tooltip.

Additionally, using Walter Zorn's "JavaScript, DHTML Tooltips" library (found at: http://www.walterzorn.com/tooltip/tooltip_e.htm ) you can customize the appearance of the tooltips.

Usage
By default, the page "Glossary" without a namespace will be used as the source of acronyms and their definitions. It's also possible to modify the extension to put the definitions in a protected namespace.

Installation
Just checkout the code from the svn to /extensions/Glossary/

LocalSettings.php
2. Add the following to the end of your LocalSettings.php:

3. Create the page "Glossary"

4. Add one line to this page for each acronym. Each line should start with a ';' (semicolon), then the text to be replaced followed by a ':' (colon) followed by the text to replace it with.

Sample Glossary

 * FTP:File Transport Protocol
 * AAAAA:American Association Against Acronym Abuse
 * ACK:Acknowledge
 * AFAIK:As Far As I Know
 * AWGTHTGTATA:Are We Going To Have To Go Through All This Again
 * HTTP:HyperText Transfer Protocol

ToolTip
This extension will not work without the tooltip javascript library. Download wz_tooltip.zip and unpack it into a directory called extensions/tooltip.

Parameters
To lock down the glossary, modify the glossary.php file.

Find the line:

and change it to:

The Glossary will now be located at:

MediaWiki:Glossary

Alternatively to use a different Glossary page within each namespace, change this line to: This will look at the NameSpace:Glossary page for all pages in NameSpace and NameSpace_Talk (assuming you have set any custom namespaces up following the convention of even numbers for the namespace and the following odd numbers for the corresponding talk namespaces).

Tooltips onmouseout
As of version 5.0 of the tooltip javascript library, the tooltips get "stuck" on the cursor.
 * 1) Open Glossary.php in a text editor
 * 2) Find line 88: $span->setAttribute('onmouseover', "TagToTip('$term')");
 * 3) Add a new line after it:

Escaping forward slashes for PCRE functions
On line 82 within the glossaryParseThisNode function, the following code exists:

preg_quote is meant to escape special regular expression characters from glossary terms. However by default it will not escape the forward slash character that has special meaning in PCRE regular expression functions. You will therefore need to change line 82 to:

Without this fix, glossary terms containing a forward slash may cause a lot of rendering errors that make your MediaWiki installation unusable.

Incompatibility with CrossReference
CrossReference does not work properly with the Glossary extension because Glossary will parse the text before CrossReference does, mangling the cross references in the process. Glossary should not replace child nodes of  elements (and for that matter, a number of other elements too such as h1 . There is no known workaround at this stage.

Multiple HTML tags in output
The Glossary plugin will create multiple tags within the same output page which is invalid and causes undefined browser rendering behaviour. This has been reproduced with MediaWiki 1.15.0 and is caused by ParserBeforeTidy being called multiple times on sub-sections of the page. Glossary just assumes that ParserBeforeTidy is called once on the complete HTML output. On a less significant note, when Glossary writes the updated DOM structure back into a string output for MediaWiki to output, indentation and spacing is lost. There is no known workaround at this stage.