Extension talk:Dia
Add topicQ:What does this extension do?
[edit]Could you please clarify what does this extension do. It sounds very cool (if I understand correctly), but how does it work? I see that it doesn't simply enable upload of dia files (like it is enabled on wiki e.g. for .xcf files), but you didn't specify what else does it do.
You also didn't say (at least not directly) if I need to have Dia installed for it to work. Correct me if I'm wrong, but it looks like it is needed.
You didn't say what shapes does your extension support and so I assume that your extensions is allowing MediWiki to generate thumbnails directly with the specified size by using Dia scripts.
Best regards,
Nux
A:What does this extension do?
[edit]Hi, as you have correctly assumed, this extension allows you to upload dia files directly to MediaWiki. The thumbnails are then automatically generated on-the-fly, as they are for e.g. SVG files.
I'm not sure if your question and the latest update of the Extension:Dia page have crossed, because I realized only after I published the page that I had forgotten to tell that you specifically need to allow t files to be submitted. I now tell this in the code snippet where the extension is loaded (see the line below that).
In the advanced configuration you can read that this extension needs an external program to provide the conversion. This is currently done by dia. (Is there anything else that can convert .dia
files? I don't believe there is.) This, of course, requires Dia to be installed, but I will make this dependency a bit more explicit.
As to answer your last question, since this extension uses Dia to perform the conversion, it also means that it should support any shape that Dia itself does, meaning, if someone uploads a .dia
file that uses an extra plugin or extra shapes, then you will need to install these on the server as well.
Hoping to have answered all your questions,
Marcel
How can I display a dia file? (Sintaxis)
Q:How can I display a dia file? What is the wiki linking syntax?
[edit]The following does not appear to work (for me)..
[[Image:my_uploaded_dia_file.dia]]
Doesn't work for me, either. Diagram is not rendered inline, nor is handled correctly when I click on it. In latter case, I get a "MIME type: unknown/unknown" message.
That suggests that the file type is not being recognized. But I applied the patch to mime.types and mime.info, and checked that it worked.
Also tried saving the diagram uncompressed, just in case that was causing the problem.
Various questions:
- How can I tell whether the extension is installed correctly? Is there a way of getting MediaWiki to list its extensions?
- Ditto with mime types. Is there a special page to get MediaWiki to list known types?
- I'm using MediaWiki version 1.10.4 (default package for Fedora 9). Would this be the problem?
Compressed format not working
[edit]The extension works fine with MW 1.12 and the documentation is clear enough for patching file (thx for this :). However, I did notice an unexpected problem : the extension doesn't handle .dia file which are compressed. It only process .dia files that are not internally compressed.
It is not a big problem to solve when you understand what is happening, but it could be useful to mention it in the documentation. Also, if there is a way to upload compressed dia files, that could be useful as well ;) LT-P 10:59, 20 May 2008 (UTC)
- How did you solve the problem? Of course, you can simply unpack it when it is uploaded, but then you do expect that it is always compressed. Did you find a really elegant solution that handles all cases?
- --Olenz 14:55, 3 July 2008 (UTC)
- Same problem here. Any solutions yet? How can I handle uncompression at upload time? For now I am running "gzip -dc" on the files before uploading them. As I understand, this is in MediaWiki's MIME type handling, not in the Dia extension itself, am I right?
I fixed this issue on a MediaWiki 1.13.0 installation with the following patch:
--- ./extensions/Dia/Dia.body.php.orig 2007-10-31 14:23:42.000000000 -0400 +++ ./extensions/Dia/Dia.body.php 2008-08-29 10:05:43.000000000 -0400 @@ -5,6 +5,13 @@ global $wgDIANominalSize; $xmlstr = file_get_contents( $filename ); + + # filbranden 2008-08-29: detect gzipped Dia files + if ( substr($xmlstr, 0, 2) == "\037\213" ) { + $xmlstr = shell_exec(escapeshellcmd("gzip -dc $filename")); + } + # filbranden 2008-08-29: end detect gzipped Dia files + $xmlstr = str_replace( "<dia:", "<", $xmlstr ); $xmlstr = str_replace( "</dia:", "</", $xmlstr ); --- ./includes/specials/SpecialUpload.php.orig 2008-07-10 04:32:34.000000000 -0400 +++ ./includes/specials/SpecialUpload.php 2008-08-29 10:49:28.000000000 -0400 @@ -1382,6 +1382,13 @@ return false; } + # filbranden 2008-08-29: accept gzipped Dia files + if ( $mime == "application/x-gzip" && $extension && strtolower($extension) == "dia" ) { + wfDebug( __METHOD__.": special handling of compressed Dia files\n" ); + return true; + } + # filbranden 2008-08-29: end handling gzipped Dia + $match= $magic->isMatchingExtension($extension,$mime); if ($match===NULL) { --- ./includes/MimeMagic.php.orig 2008-07-02 19:25:20.000000000 -0400 +++ ./includes/MimeMagic.php 2008-08-29 10:53:23.000000000 -0400 @@ -593,6 +593,19 @@ $m = NULL; } else { wfDebug( __METHOD__.": magic mime type of $file: $m\n" ); + + # filbranden 2008-08-29: if file is gzipped but extension is ".dia", treat as a Dia diagram: + if ( $m == "application/x-gzip" ) { + if ( $ext === true ) { + $i = strrpos( $file, '.' ); + $ext = strtolower( $i ? substr( $file, $i + 1 ) : '' ); + } + if ( $ext && strtolower($ext) == "dia" ) { + $m = "application/x-dia-diagram"; + } + } + # filbranden 2008-08-29: end detection of gzipped Dia diagram. + return $m; } }
- Can you include the file? I couldn't seem to find where to insert in SpecialUpload.php Daimengrui 08:21, 13 September 2011 (UTC)
"Cannot allocate memory"
[edit]This sounds like a nice extension. Unfortunately, I can't get it to run.
After removing the above problems (MIME types, compressed files, ...), I can now upload diagrams. Unfortunately, when the diagram is about to be rendered, I get the following message in the place where the diagram should be:
Error creating thumbnail: dia: error while loading shared libraries: libXrender.so.1: failed to map segment from shared object: Cannot allocate memory
As of July 3rd 2008, see here.
I've already tried to increase the available memory size for PHP, but to no avail.
Any hints?
--Olenz 14:43, 3 July 2008 (UTC)
- I have found the problem: the amount of memory given to shell commands is controlled by the configuration variable
$wgMaxShellMemory
- which is set to 102400 by default. Apparently, 100MB is too few memory for larger diagrams.
- By setting
$wgMaxShellMemory = 512000;
- everything goes smoothly now.
- --Olenz 07:14, 4 July 2008 (UTC)
As you may notice, I have incorporated the above experiences into the Installation section of the article. --Olenz 08:01, 4 July 2008 (UTC)
Size of Dia Image
[edit]Hello,
I'm using this extension, and I'm not particularly happy with the way it's calculating the image size by looking inside the XML. Anyway, it seems to be doing the wrong thing, because the numbers inside the XML are floats, and I don't think that they are pixels at all. The size it calculates is always much smaller than the size I get by running "dia -e" without any "-s" parameter.
To work around this, I patched Dia.body.php to use "dia" to calculate the image size. However, this is not very efficient from my point of view, since then it will call "dia" to create a PNG in /tmp only to find the image size and delete it, while just after that it will be called again to generate an image in the thumbnails. I was trying to do it only once, generate an image and set its size attributes later, but I didn't find any way to do it. Do you know how to do that?
Anyway, here is my patch to call "dia" to generate a temporary image and calculate the file size:
--- Dia/Dia.body.php.orig 2007-10-31 14:23:42.000000000 -0400 +++ Dia/Dia.body.php 2008-08-29 16:45:49.000000000 -0400 @@ -156,7 +156,19 @@ } function getImageSize( $image, $path ) { - return wfGetDIAsize( $path ); + #return wfGetDIAsize( $path ); + + # filbranden 2008-08-29: call Dia and create a png to calculate the size + # NOTE: this is really wasteful, I would prefer to do that only in doTransform, but I do not know how to do that + $tmpfile = tempnam("/tmp", "MediaWikiDia"); + $retval = 0; + $gis = false; + wfShellExec("dia -n -e $tmpfile -t png $path", $retval); + if ($retval == 0) { + $gis = getimagesize($tmpfile); + } + unlink($tmpfile); + return $gis; } function getThumbType( $ext, $mime ) {
Editing Dia Files
[edit]The installation works fine for me and i am able to see the thumbnail on the wiki page.
Now I have more than 10 to 20 users who would be using the wiki page. In order to edit the .dia file, I understand that an external editor has to be configured. My question is do all the users have to configure the external editor in their pc's to edit the .dia file and upload it back to the server?
Your reply would be really helpful.
- I don't know what you mean by "configure the external editor"? If you have any program to edit .dia-files, you can use those files. The only caveat is probably, that so far you have to use the patch given above to make the exntension handle compressed files, which dia uses by default. But this is something you should do on the server.
- --Olenz 07:11, 20 March 2009 (UTC)
dia_xml_format.patch for mediawiki-1.13
[edit]The patch for mediawiki-1.12 does not work for mediawiki 1.13, as the part of includes/MimeMagic.php is now in includes/DefaultSettings.php.
But the top of includes/DefaultSettings.php says âNEVER EDIT THIS FILEâ, and instead add changes to LocalSettings.php.
Your LocalSettings.php should now look like this:
require_once( "$IP/extensions/Dia/Dia.php" ); # Load Dia extension $wgFileExtensions[] = 'dia'; # Allow uploading of dia files $wgXMLMimeTypes['http://www.lysator.liu.se/~alla/dia/:diagram'] = 'application/x-dia-diagram'; # Append to the mime types
--genx 09:52, 1 April 2009 (UTC)
Fatal error: Class 'SimpleXMLElement' not found in <mypath>/extensions/Dia/Dia.body.php on line 11
[edit]In mediawiki-1.13, trying to upload a dia file I get the following error:
Fatal error: Class 'SimpleXMLElement' not found in <mypath>/extensions/Dia/Dia.body.php on line 11
Problem solved by rebuilding php with simplexml (use flag in gentoo), and reloading apache.
--genx 09:52, 1 April 2009 (UTC)
Fatal error: parser error : Start tag expected, '<' not found in ... \Dia\Dia.body.php on line 11
[edit]This means what it says, the <dia: tag cannot be found in the dia file. In my case this was because I made the .dia file compressed. Full error below ... (fixed by saving dia file as "uncompressed" file.
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : Start tag expected, '<' not found in G:\xampp\htdocs\mediawiki\extensions\Dia\Dia.body.php on line 11
- Can you display a few lines above around line 11 Dia.body.php look like? Mine looks like this:
# filbranden 2008-08-29: detect gzipped Dia files if ( substr($xmlstr, 0, 2) == "\037\213" ) { $xmlstr = shell_exec(escapeshellcmd("gzip -dc $filename")); } # filbranden 2008-08-29: end detect gzipped Dia files
- --genx Mon Apr 20 10:11:32 PDT 2009
Error xml_parse: Unable to call handler
[edit]Q: How can I fix this error when running on mediawiki 1.16
Warning: xml_parse() [function.xml-parse]: Unable to call handler () in /var/www/html/devwiki_new/includes/XmlTypeCheck.php on line 53
I have the same error when i try to upload SVG files. the files are uploaded but i get this warning. --The IceMan 20:53, 9 November 2010 (UTC)
Q:Where can I find the dia.php file?
[edit]In the directions provided they say you must add the line, 'require_once( "$IP/extensions/Dia/Dia.php" ); # Load Dia extension' to your localSettings.php file. After I copy the /Dia directory into the mediaWiki/Extensions directory and add this line, I get an error because there is no dia.php...anywhere. Did I miss something in the installation. Do I need to add this file?
Answer: You need to download the dia package and extrat the Dia folder to your extensions directory
Q: DIA extension not working with 1.18.3
[edit]Followed the instructions to extract the Dia folder under extensions made the changes to localsettings.php and MediaWiki just fails. In the apache log
The given path is misformatted or contained invalid characters: Cannot map POST /mediawiki/index.php/Special:Upload HTTP/1.1 to file, referer: http://localhost:8080/mediawiki/index.php/Special:Upload The given path is misformatted or contained invalid characters: Cannot map GET /mediawiki/index.php/File:Relationships.dia HTTP/1.1 to file, referer: http://localhost:8080/mediawiki/index.php/Special:Upload
Is this still maintained?
[edit]I tried to install this extension with the latest mediawiki and its failed to work at all, Is this project dead?
Doesnt work with 1.20
[edit]Can almost get it to work, but dia wont produce thumbnails. This appears in my debug log:
thumbnail failed on wikiserver: error 2 "'mwstore://local-backend/local-public/4/4b/diagram.dia' not found!" from "dia -n -e '/var/www/wikis/Wiki/images/temp/transform_4cf2c647216d-1.png' -t png -s 300 'mwstore://local-backend/local-public/4/4b/diagram.dia' 2>&1"
The dia command dont know mediawiki internal file url - how to replace with actual file path?...
One Fix
[edit]I had the same problem after upgrading mediawiki from 1.17 to 1.20.5.
Fixed it by modifying extensions/Dia/Dia.body.php function doTransform() and modifying
$srcPath = $image->getPath();
to
$srcPath = $image->getLocalRefPath();
Another problem with 1.20
[edit]I get the following error message when I add the Dia extension to mediawiki-1.20.6
Fatal error: Call to a member function addMessages() on a non-object in /home/www/htdocs/mediawiki-1.20.6/extensions/Dia/Dia.php on line 76
PHP version: PHP 5.3.10-1ubuntu3.6 with Suhosin-Patch (cli)
MySQL: Server version: 5.5.31-0ubuntu0.12.04.1 (Ubuntu)
Apache:
Server version: Apache/2.2.22 (Ubuntu)
Server built: Mar 8 2013 15:53:13
Fix
[edit]Just comment away the two lines with references to addMessages()
Warmsock (talk) 08:37, 21 June 2013 (UTC)
Fix works
[edit]Thanks
Proposed for commons, T26252
[edit]c:Commons:File types mentions the "Dia diagram format" as an unsupported file type. phab:T26252 proposes supporting it. I'm mildly interested in this as it might make it easier to generate and maintain diagrams in software documentation, like Manual:Database_layout/diagram. -- SPage (WMF) (talk) 08:06, 17 August 2015 (UTC)