Information
===========
This is a MediaWiki extension that implements automatic creation of links as a
magic word. The information about which identifiers to link where should be
provided in a special page in the MediaWiki namespace. It is possible to
restrict linking of a identifier on one or a group of pages.
Usage
=====
The extension should be used as {{#autolink:list_name|identifier|title_override}}.
The meaning of parameters is as follows:
'identifier' is the identifier to be linkified;
'list_name' is the name of the definition list that the extension should use,
as defined in $AutoLinkerDefinitions.
'text_override' is the text that overrides the link title. By default, the
link title is 'identifier'.
Configuration
=============
The extension pulls the information about which identifiers to link where from
definition lists.
A definition list is a page in a MediaWiki namespace, format of which is
described below. The first parameter passed to extension specifies which list
to use. The allowed values and the actual locations of the lists are specified
in an array in $AutoLinkerDefinitions. For example:
$AutoLinkerDefinitions = [
'a' => 'autolinker-defs-a',
'b' => 'autolinker-defs-b'
];
If the above is included into the LocalSettings.php, then e.g.
{{#autolink:a|???}} will pull the definitions from MediaWiki:autolinker-defs-a.
A definition list is a file in the JSON format. The format is as follows:
{
"groups" : [
{
"name" : "string",
OPTIONAL "base_url" : "string", END
"urls" : [ "url", "url", ... ],
},
...
],
"links" : [
{
"string" : "string",
OPTIONAL "on_group" : "name", OR "on_page" : "url", END
"target" : "url",
},
...
],
Here OPTIONAL, OR and END define what attributes are accepted.
The 'groups' array defines page groups that can later be used in
'links[].on_group'. Each element in this array defines one page group. A page
group is simply a named set of pages. This set is defined in the 'urls' array.
If all pages in the group have a common title prefix, then it can be moved to
'base_url' attribute. The 'name' attribute defines the name of a group. All
groups should have unique names.
The 'links' array defines identifier -> link target mapping. Each element in the
array defines one mapping: 'string' is the identifier, 'target' is the target
link. The set of pages that a mapping takes effect in can be restricted by
'on_group' or 'on_page' attributes. 'on_group', if defined, must contain a name
of a group that has been defined in the 'groups' array.