Skip to content

Commit

Permalink
Switch from png to svg as output format
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Tetzlaff committed May 22, 2019
1 parent ee7937c commit da0a39b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ It allows to generate UML graph images from simple description text block.

# Features
* Create any UML graph supported by PlantUML.
* Generated images are PNGs.
* Generated images are SVGs.
* Generated images are cached and regenerated when needed.
* Toolbar button (optional)
* Control the display witdh, height and alignment.
Expand Down
2 changes: 1 addition & 1 deletion img.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$cache = $plugin->_imgfile($data);

if ($cache) {
header('Content-Type: image/png;');
header('Content-Type: image/svg+xml;');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + max($conf['cachetime'], 3600)) . ' GMT');
header('Cache-Control: public, proxy-revalidate, no-transform, max-age=' . max($conf['cachetime'], 3600));
header('Pragma: public');
Expand Down
14 changes: 6 additions & 8 deletions syntax.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
* Note this is also called by img.php
*/
function _imgfile($data) {
$cache = $this->_cachename($data, 'png');
$cache = $this->_cachename($data, 'svg');

// create the file if needed
if (!file_exists($cache)) {
Expand All @@ -167,11 +167,7 @@ function _imgfile($data) {
clearstatcache();
}

if ($data['width'] && $data['percent'] != '%') {
$cache = media_resize_image($cache, 'png', $data['width'], $data['height']);
}

return file_exists($cache) ? $cache : false;
return file_exists($cache) ? $cache : false;
}

/**
Expand Down Expand Up @@ -212,19 +208,21 @@ function _local($data, $in, $out) {
dbglog($in, 'No such plantuml input file');
return false;
}

$java = $this->getConf('java');
$jar = $this->getConf('jar');
$jar = realpath($jar);
$jar = escapeshellarg($jar);

// we are not specifying the output here, because plantuml will generate a file with the same
// name as the input but with .png extension, which is exactly what we want
// name as the input but with .svg extension, which is exactly what we want
$command = $java;
$command .= ' -Djava.awt.headless=true';
$command .= ' -Dfile.encoding=UTF-8';
$command .= " -jar $jar";
$command .= ' -splash:no';
$command .= ' -charset UTF-8';
$command .= ' -tsvg';
$command .= ' ' . escapeshellarg($in);
$command .= ' 2>&1';

Expand Down

0 comments on commit da0a39b

Please sign in to comment.