Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New version of the Dia plugin #2

Open
marklagendijk opened this issue Jan 15, 2014 · 7 comments
Open

New version of the Dia plugin #2

marklagendijk opened this issue Jan 15, 2014 · 7 comments

Comments

@marklagendijk
Copy link

I wrote a new version of the Dia plugin, which solves a few problems which this one has.

It renders the diagrams as .svg instead of .png, and also calulates the dimensions correctly. Please check it out, and let me know what you think.
Suggestions for improvement are welcome.

@vitalif
Copy link
Member

vitalif commented Jan 15, 2014

Hm... Is your one a fork of original or of this (my) one?
If you tried my version, you should notice it also renders diagrams as svg... since d0c32bf... :)))

@vitalif
Copy link
Member

vitalif commented Jan 15, 2014

and also calulates the dimensions correctly

...and does my one calculate them incorrectly?

@marklagendijk
Copy link
Author

I took your code as a starting point / example, but wrote most of the logic from scratch.
Here are the main differences / improved points:

  • It suppports compressed .dia files. It just calls Dia for each file to create a .svg. The .svg is also used for getting the size of the image.
  • It calculates the thumbnail size correctly (same size as Dia). If you specify an Dia file without any size specification, it will be the same size as when you open the diagram in Dia. Eg: [[File:MyDiagram.dia]]. This hugely improves usability. Also the thumnails on the file page of diagram files, are displayed in a better size.
  • It is well documented (code + readme)

Would you mind if I updated the MediaWiki page so it describes and points to this new plugin?

@vitalif
Copy link
Member

vitalif commented Jan 15, 2014

It suppports compressed .dia files.

About this - I think it's not correct to just set $wgMediaHandlers['application/x-gzip'] = 'DiaHandler'; I.e. it will call DiaHandler for all gz files, and there are at least .svgz ones - these do not contain dia...
If I remember correctly I also support svgz and gzipped dia, but only in Mediawiki4Intranet, because it needs a patch to mediawiki core.

@marklagendijk
Copy link
Author

Thanks for the feedback!
You are right. It might be best to make that line conditional with an configuration option. But this only would be a problem when you want to allow uploads of other files, which are also using application/x-gzip, which isn't very common.

@vitalif
Copy link
Member

vitalif commented Jan 16, 2014

Your Dia.body.php, line 67:

$dstPath = $srcPath . '.svg';

This is also bad - do you generate the thumbnail directly nearby to the source file instead of inside the thumbnail directory?


I've just discovered SVG support in my version didn't work correctly in MW >= 1.19 because $dstPath in transform() is inside /tmp in these versions, not inside the real thumbnail directory, and the .svg file wasn't copied from /tmp after generation.

Fixed it, and also removed nominal size (as in your version). Removed the ancient mime types patch, and slightly updated the readme.

I'll still use my version in mediawiki4intranet because it outputs SVG as an <object> with PNG fallback which may be still needed for old browsers.

If you want to update URL on the page, please do not remove link to my version, but of course you're free to also add your one as an alternative...

@vitalif
Copy link
Member

vitalif commented Jan 16, 2014

You are right. It might be best to make that line conditional with an configuration option. But this only would be a problem when you want to allow uploads of other files, which are also using application/x-gzip, which isn't very common.

Also note that your method won't work - MediaWiki will deny uploading gzipped dia files because of mime type and extension mismatch. You need to patch mime.types (add dia extension to application/x-gzip line) for this to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants