User:WolfgangFahl/MagicTag

From mediawiki.org
MediaWiki extensions manual
MagicTag
Release status: experimental
Implementation Parser function
Description Allows calling an external RESTFul service specified at configuration time to render "magic" tag content. The <magic> content will be calculated based on the content of the current page as well as parameters being specified. The service being called needs to be a trusted service.
Author(s) WolfgangFahltalk
Latest version 0.0.0
MediaWiki 1.35+
License Apache License 2.0
Download
Translate the WolfgangFahl/MagicTag extension if it is available at translatewiki.net

The MagicTag is a Tag extension that adds a <Magic>. On rendering this tag a configurable external RESTFul service is called with a POST request and the tag content will be replaced by the text response of the service.

Installation[edit]

  • Download and move the extracted MagicTag folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/MagicTag
  • Only when installing from Git, run Composer to install PHP dependencies, by issuing composer install --no-dev in the extension directory. (See task T173141 for potential complications.)
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'MagicTag' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage[edit]

Setup the RESTFul service endpoint first.

Examples[edit]

Take the use cases:

  1. We want to display some text as ASCII-Art and are to lazy to look for a PHP / extension based solution. There is https://pypi.org/project/art/ which looks nice for the job. There seems to be no security risk involved.
  2. We want to display the disk usage in our wiki. This info might not be too security sensible and e.g. useful in an intranet to show when we run out of disk space.
<Magic service="Art">MagicTag</Magic>

Result[edit]

 __  __                _        _____               
|  \/  |  __ _   __ _ (_)  ___ |_   _|  __ _   __ _ 
| |\/| | / _` | / _` || | / __|  | |   / _` | / _` |
| |  | || (_| || (_| || || (__   | |  | (_| || (_| |
|_|  |_| \__,_| \__, ||_| \___|  |_|   \__,_| \__, |
                |___/                         |___/ 

Diskusage[edit]

<Magic service="Diskusage"/>

Result[edit]

Total: 187 GiB Used: 140 GiB Free: 37 GiB 

See also[edit]