Read toml formatted configs for display
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
5
composer.json
Normal file
5
composer.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"require": {
|
||||
"devium/toml": "*"
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user