Read toml formatted configs for display

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2025-04-30 09:00:44 -07:00
parent 4c11d44918
commit 95647069eb
3 changed files with 12 additions and 11 deletions

5
composer.json Normal file
View File

@@ -0,0 +1,5 @@
{
"require": {
"devium/toml": "*"
}
}

View File

@@ -44,7 +44,7 @@ class GlModelHooks {
}
/**
* Render the config json in a <pre> tag
* Render the config toml in a <pre> tag
*
* @param $input The text inside the custom tag
* @param array $args Any attributes given in the tag
@@ -170,15 +170,8 @@ class GlModelHooks {
$uploadFormObj->mComment .= <<<CONF
<mvconfig>
{
"viewerConfig": {
"default": {
"camera-controls": true
}
},
"annotations": {},
"annotationSets": {}
}
[viewerConfig.default]
camera-controls = true
</mvconfig>
CONF;
}

View File

@@ -1,6 +1,9 @@
<?php
namespace MediaWiki\Extension\GlModelViewer;
require_once __DIR__ . '/../vendor/autoload.php';
use Devium\Toml\Toml;
use MediaWiki\MediaWikiServices;
use MediaTransformOutput;
use ConfigFactory;
@@ -49,7 +52,7 @@ class GlModelTransformOutput extends MediaTransformOutput {
public function toHtml($options = []) {
$descriptText = $this->file->getDescriptionText();
preg_match('/<pre mvconfig.*?>([\S\s]*?)<\/pre>/',$descriptText,$modelDescript);
$metadata = json_decode($modelDescript[1], true);
$metadata = toml_decode($modelDescript[1], true);
if ($this->thumb) {
$poster = $metadata['viewerConfig'][$this->view]['poster'] ?? false;