🚧 This instance is under construction; expect occasional downtime. Runners available in /repos. Questions? Ask in #wikimedia-gitlab on libera.chat, or under GitLab on Phabricator.

Unverified Commit 22ea66eb authored by Samwilson's avatar Samwilson Committed by GitHub
Browse files

Merge pull request #25 from samwilson/map-format

Add map format for service-rendered diagrams
parents 0f69e2cb 6dfa41e0
......@@ -5,11 +5,21 @@ on: [push, pull_request]
jobs:
build:
strategy:
matrix:
php: [ '7.3', '7.4' ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{matrix.php}}
coverage: none
- name: Install
run: |
composer install
......
......@@ -135,10 +135,16 @@ class Diagrams {
$baseUrl = MediaWikiServices::getInstance()->getMainConfig()->get( 'DiagramsServiceUrl' );
$url = trim( $baseUrl, '/' ) . '/render';
$format = isset( $params['format'] ) && $params['format'] ? $params['format'] : 'png';
$mapFormat = null;
if ( $commandName !== 'plantuml' ) {
// Add image map output where it's supported.
$mapFormat = $commandName === 'mscgen' ? 'ismap' : 'cmapx';
}
$requestParams = [
'postData' => http_build_query( [
'generator' => $commandName,
'types' => array_filter( [ $format ] ),
'types' => array_filter( [ $format, $mapFormat ] ),
'source' => $input,
] ),
];
......
......@@ -33,14 +33,15 @@ class Hooks {
if ( $tag === 'graphviz' ) {
// GraphViz.
$dot = new Dot( $input );
return $diagrams->$renderMethod( $params['renderer'] ?? 'dot', $dot->getSrc(), $params );
$html = $diagrams->$renderMethod( $params['renderer'] ?? 'dot', $dot->getSrc(), $params );
} elseif ( $tag === 'mscgen' ) {
// Mscgen.
return $diagrams->$renderMethod( 'mscgen', $input, $params );
$html = $diagrams->$renderMethod( 'mscgen', $input, $params );
} else {
// PlantUML.
return $diagrams->$renderMethod( 'plantuml', $input, $params );
$html = $diagrams->$renderMethod( 'plantuml', $input, $params );
}
return [ $html, 'markerType' => 'nowiki' ];
} );
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment