Extension:ShortLinksParser

What can this extension do?
If you're linking often to the same external sources you have always to repeat certain parts of the URL which remain the same. This extension introduces a possibility to shorten this notation by providing reusable base-urls with placeholders. Note: See See also for differences to Interwiki-Links

Usage
E.g. you have a lot of links to wikipedia so you would have to write again and again the same base URL with the name of the page appended:

and again

Using the ShortLinksParser-Extension you can cut down the link to:

and

whereas the ShortLink Wikipedia is replaced by the base URL  and the page name is inserted for a placeholder.

Another reasonable field of application might be linking to items of other web applications, e.g. Project Management or Bug Tracking Tools.

Download instructions
Please create a new folder in your MediaWiki Extension directory ($IP/extensions) named ShortLinksParser. Add the files shortLinksParser_class.php and ShortLinksParser.php to it.

Your directory structure should now look like this: --extensions ShortLinksParser --ShortLinksParser.php --shortLinksParser_class.php

Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.

Installation
Installation follows two steps:

1. Add the following to LocalSettings.php:

2. Configure the ShortLinks in ShortLinksParser.php as described in the next point.

Configuration parameters
Configuring a ShortLink is as easy as filling an associative array.

Please note: You can find the array in the extension file ShortLinksParser.php below.

For the above mentioned Wikipedia example this might be:

The number in braces is a placeholder. You can use insert placeholders on any position you want and as many as you want.

Multiple placeholders
An example for multiple placeholders

In your MediaWiki you could now define a ShortLink pointing to the MediaWiki Extension authors:

By default the pipe symbol (|) is used to separate the parameters.

Customizing the ShortLinks parameter separator
You can also use another symbol, but make sure this symbol can't be part of an URL. To define another char use the method  of the class shortLinksParser.

Customizing the look of a ShortLink
If you want to highlight a ShortLink e.g. with an icon, you can easily do that in CSS. Every generated ShortLink is surrounded with a div-Box which has a class assigned to it.

The name of the class follows a certain syntax: NAME_OF_THE_SHORTLINK-shortLinkContainer. For the above mentioned Wikipedia example this would be.

You can either add the CSS-Code to existing CSS-files or use an extra file. To link to the extra file you can use the method  of the class shortLinksParser.

Differences to interwiki links
The built in interwiki function of the MediaWiki-Software has basically the same approach. Differences are
 * Customizing the look of a ShortLink: There's a div box with a CSS class refering to the ShortLink around every ShortLink. You can use it to customize the look of a link (e.g. using an icon in front of every link). With interwiki links you only have the CSS class "extiw" assigned to every inverwiki link so you can't differentiate between prefixes.
 * Multiple placeholders: You can define several placeholders in a ShortLink. In the next version you can also overload a ShortLink with a different number of params pointing to different URLs of the same base URLs.