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 $input The text inside the custom tag
|
||||||
* @param array $args Any attributes given in the tag
|
* @param array $args Any attributes given in the tag
|
||||||
@@ -170,15 +170,8 @@ class GlModelHooks {
|
|||||||
$uploadFormObj->mComment .= <<<CONF
|
$uploadFormObj->mComment .= <<<CONF
|
||||||
|
|
||||||
<mvconfig>
|
<mvconfig>
|
||||||
{
|
[viewerConfig.default]
|
||||||
"viewerConfig": {
|
camera-controls = true
|
||||||
"default": {
|
|
||||||
"camera-controls": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"annotations": {},
|
|
||||||
"annotationSets": {}
|
|
||||||
}
|
|
||||||
</mvconfig>
|
</mvconfig>
|
||||||
CONF;
|
CONF;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace MediaWiki\Extension\GlModelViewer;
|
namespace MediaWiki\Extension\GlModelViewer;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
use Devium\Toml\Toml;
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
use MediaTransformOutput;
|
use MediaTransformOutput;
|
||||||
use ConfigFactory;
|
use ConfigFactory;
|
||||||
@@ -49,7 +52,7 @@ class GlModelTransformOutput extends MediaTransformOutput {
|
|||||||
public function toHtml($options = []) {
|
public function toHtml($options = []) {
|
||||||
$descriptText = $this->file->getDescriptionText();
|
$descriptText = $this->file->getDescriptionText();
|
||||||
preg_match('/<pre mvconfig.*?>([\S\s]*?)<\/pre>/',$descriptText,$modelDescript);
|
preg_match('/<pre mvconfig.*?>([\S\s]*?)<\/pre>/',$descriptText,$modelDescript);
|
||||||
$metadata = json_decode($modelDescript[1], true);
|
$metadata = toml_decode($modelDescript[1], true);
|
||||||
|
|
||||||
if ($this->thumb) {
|
if ($this->thumb) {
|
||||||
$poster = $metadata['viewerConfig'][$this->view]['poster'] ?? false;
|
$poster = $metadata['viewerConfig'][$this->view]['poster'] ?? false;
|
||||||
|
|||||||
Reference in New Issue
Block a user