Extension:Dia

From MediaWiki.org

Jump to: navigation, search
Manual on MediaWiki Extensions
List of MediaWiki Extensions
Dia

Release status: beta

Implementation Media
Description Allows Dia diagrams to be rendered inside MediaWiki pages.
Author(s) EleotleCram
MediaWiki 1.11
License GPL v2 or up
Download bundle (mirror)
Parameters $wgDIANominalSize, $wgDIAMaxSize, $wgDIAConverters, $wgDIAConverter, $wgDIAConverterPath

Contents

[edit] What does this extension do?

The Dia extension allows Dia diagrams to be embedded/rendered inside MediaWiki pages. It can be used to have thumbnails of specified size to be automatically generated from the uploaded .dia files. (If no size is given, then the nominal size will be used.)

In the future, when SVG gets better support in all the major browsers, this extension may also produce .svg from the .dia files.

[edit] Dependencies

  • dia - This extension relies on an external conversion program to perform the conversion. By default, dia itself is used to perform this conversion, which means that you will need to have it installed on the server.

[edit] Installing

Copy the Dia directory into the extensions folder of your MediaWiki installation. Then add the following lines to your LocalSettings.php file (near the end):

require_once( "$IP/extensions/Dia/Dia.php" ); # Load Dia extension
$wgFileExtensions[] = 'dia';                  # Allow uploading of dia files

Also make sure that you have mediawiki configured to allow for file uploads:

$wgEnableUploads = true;

(This setting is already present in LocalSettings.php, however, it defaults to false, to enable uploads, make sure it is set to true.)

To finish the installation, you must make sure the dia mime types are known to WikiMedia. This can be done by applying the supplied patch mimetypes.patch. To do so, go to your mediawiki installation root (the directory containing the includes/ directory) and type the following in a commandline shell:

patch -p0 < extensions/Dia/mimetypes.patch

Or by manually adding the following line to includes/mime.types:

application/x-dia-diagram dia

And by adding the following line to includes/mime.info:

application/x-dia-diagram [DRAWING]

[edit] Configuration

$wgDIANominalSize
The nominal width of a Dia file when rendered to png (default: 300px).
$wgDIAMaxSize
Don't scale a Dia file larger than this (default: 1024px).

[edit] Advanced Configuration

Dia diagrams may be uploaded as drawings. these diagrams are converted to png before they can be rendered on a page. An external program is required to perform this conversion. By default 'dia' itself is used to perform this conversion, but if you have a different tool to perform the conversion you can set it up here.

$wgDIAConverters
An associative array linking your conversion tool (as key) with the commandline to be used for your tool. In this commandline you can use the following variables:
  • $input: The input filename
  • $output: The output filename
  • $width: The output width
$wgDIAConverter
The currently selected converter (default: 'dia').
$wgDIAConverterPath
If the currently selected converter is not in the default PATH environment variable, you can set the path here.

Note: Future versions of the extension may also output SVG.

[edit] Client side

This extension works great when using an external editor.

In addition to this, a patch has been posted on bugzilla that updates the ee (external editor) "extension" to allow a connection to a wiki page that is protected with HTTP authentication (i.e. logins that give a popup username/password requester).

[edit] FAQ

Please also see Extension_talk:Dia for further assistence and questions regarding this extension.

  • Q:Which shapes does this extension support?
    • A:This extension uses 'dia' itself to perform the conversion, so it will supported whatever the 'dia' that is installed on the server will support.
      If someone uploads a .dia file that uses shapes (from a third-party plugin) that the installed 'dia' does not have, then these shapes will not get rendered in the thumbnail until the 'dia' on the server-side is also extended with the used plugin.
  • Q:When I upload I get: "The file is corrupt or has an incorrect extension"
    • A:Latest MediaWiki in SVN has "improved" mime type checking which means that it now recognises files not only by file name extension but also based on its contents. Unfortunately, because MediaWiki does not recognise dia files by default, it detects a dia file as an ordinary xml file. To fix this, you will have to patch mediawiki. Copy/paste the following code snippet to a file called dia_xml_format.patch.
Index: includes/MimeMagic.php
===================================================================
--- includes/MimeMagic.php      (revision 33928)
+++ includes/MimeMagic.php      (working copy)
@@ -460,6 +460,7 @@
                        $types = array(
                                'http://www.w3.org/2000/svg:svg'    => 'image/svg+xml',
                                'svg'                               => 'image/svg+xml',
+                               'http://www.lysator.liu.se/~alla/dia/:diagram' => 'application/x-dia-diagram',
                                'http://www.w3.org/1999/xhtml:html' => 'text/html', // application/xhtml+xml?
                                'html'                              => 'text/html', // application/xhtml+xml?
                        );

And apply the patch from the mediawiki installation root:

patch -p0 < dia_xml_format.patch
  • Q:How can I display a dia file ?
    • A:A Dia file can be displayed and edited using Dia [1]. The file can also be exported to a variety of different formats (such as SVG, PDF, PNG), of course, once exported, it cannot be edited anymore. This plugin performs a conversion to PNG automatically for including dia files as images inside mediawiki. However, through the upload page, the original dia file can be retrieved for additional editing and maintenance.

[edit] History

  • 20071031 Initial version.
Personal tools