Extension:Diagrams

From Linux Web Expert

MediaWiki extensions manual
Diagrams
Release status: stable
px
Implementation Tag
Description Display various types of diagrams rendered from text within wiki pages.
Author(s) Sam Wilson (Samwilsontalk)
Latest version 0.13.1 (2024-04-10)
Compatibility policy Master maintains backward compatibility.
MediaWiki >= 1.34.0, <= 1.42
Database changes No
Composer samwilson/diagrams
License MIT License
Download
README
$wgDiagramsServiceUrl
<graphviz>, <mscgen>, and <uml>
Quarterly downloads Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').
Public wikis using Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin').

The Diagrams extension displays GraphViz, Mscgen, PlantUML, and Mermaid diagrams in a wiki. It can be configured to use a small web service to render the images.

It replaces the GraphViz , PlantUML , and Mermaid extensions in some ways, but does not (yet) support all features of all of them. The original reason for creating a new extension was to not store the rendered images as wiki files (as the GraphViz extension did), but it has changed to become a general diagramming extension.

Installation

  • <translate> <tvar name=1>Download</tvar> and place the file(s) in a directory called <tvar name=name>Diagrams</tvar> in your <tvar name=ext>extensions/</tvar> folder.</translate>
  • <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
    wfLoadExtension( 'Diagrams' );
    
  • Rendering: For formats other than Mermaid, and if you do not use the external rendering service (see below), then you have to install graphviz, mscgen and/or plantuml on the computer running the web server. For example, on Debian or Ubuntu systems this can be done with:
    $ sudo apt install graphviz mscgen plantuml
    
  • Private wikis: if you are using image authorization then you need to add the following to LocalSettings.php:
    $wgUploadPath = "$wgScriptPath/img_auth.php";
    $wgImgAuthUrlPathMap['/diagrams/'] = 'mwstore://local-backend/local-public/diagrams/';
    
  • File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>

Optional external rendering

This extension can also be configured to use an external rendering web service to generate the actual diagrams files. This is useful if you do not want the rendered files to be stored in the wiki, or if you have security requirements that make it more convenient to have the external rendering commands run somewhere other than on the web server.

Earlier versions of this extension required this service, but since 0.4.0 it's been optional.

There are two implementations of the service:

  1. A PHP (Symfony) based serviceinstallation instructions
  2. A Python based serviceinstallation instructions, demo

Once you have the servicing installed and running correctly, add the following to your LocalSettings.php:

// The URL at which you installed the Diagrams Service.
$wgDiagramsServiceUrl = 'https://diagrams.example.com/subdir';

Usage

This extension adds four tags: <graphviz>, <mscgen>, <uml>, and <mermaid>.

See also