From 95647069eb4f7e8deab0c0b35f6d39aeaf40ec0d Mon Sep 17 00:00:00 2001 From: Justin Georgi Date: Wed, 30 Apr 2025 09:00:44 -0700 Subject: [PATCH] Read toml formatted configs for display Signed-off-by: Justin Georgi --- composer.json | 5 +++++ includes/GlModelHooks.php | 13 +++---------- includes/GlModelTransformOutput.php | 5 ++++- 3 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 composer.json diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..677166a --- /dev/null +++ b/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "devium/toml": "*" + } +} diff --git a/includes/GlModelHooks.php b/includes/GlModelHooks.php index 1ab8bbe..82d4c40 100644 --- a/includes/GlModelHooks.php +++ b/includes/GlModelHooks.php @@ -44,7 +44,7 @@ class GlModelHooks { } /** - * Render the config json in a
 tag
+     * Render the config toml in a 
 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 .= <<
-            {
-            "viewerConfig": {
-                "default": {
-                    "camera-controls": true
-                }
-            },
-            "annotations": {},
-            "annotationSets": {}
-            }
+                [viewerConfig.default]
+                camera-controls = true
             
             CONF;
         }
diff --git a/includes/GlModelTransformOutput.php b/includes/GlModelTransformOutput.php
index d8ca64e..87e57af 100644
--- a/includes/GlModelTransformOutput.php
+++ b/includes/GlModelTransformOutput.php
@@ -1,6 +1,9 @@
 file->getDescriptionText();
         preg_match('/
([\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;