Show only model on file preview page
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -15,7 +15,8 @@
|
|||||||
"MimeMagicImproveFromExtension": "GlModelViewer::onMimeMagicImproveFromExtension",
|
"MimeMagicImproveFromExtension": "GlModelViewer::onMimeMagicImproveFromExtension",
|
||||||
"BeforePageDisplay": "GlModelViewer::onBeforePageDisplay",
|
"BeforePageDisplay": "GlModelViewer::onBeforePageDisplay",
|
||||||
"ImageBeforeProduceHTML": "GlModelViewer::onImageBeforeProduceHTML",
|
"ImageBeforeProduceHTML": "GlModelViewer::onImageBeforeProduceHTML",
|
||||||
"ImageOpenShowImageInlineBefore": "GlModelViewer::onImageOpenShowImageInlineBefore"
|
"ImageOpenShowImageInlineBefore": "GlModelViewer::onImageOpenShowImageInlineBefore",
|
||||||
|
"AlternateEditPreview": "GlModelViewer::onAlternateEditPreview"
|
||||||
},
|
},
|
||||||
"ResourceFileModulePaths": {
|
"ResourceFileModulePaths": {
|
||||||
"localBasePath": "modules",
|
"localBasePath": "modules",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
use MediaWiki\MediaWikiServices;
|
||||||
|
|
||||||
class GlModelViewer extends ImageHandler {
|
class GlModelViewer extends ImageHandler {
|
||||||
public static function onMimeMagicInit(MimeAnalyzer $mime) {
|
public static function onMimeMagicInit(MimeAnalyzer $mime) {
|
||||||
@@ -38,11 +39,18 @@ class GlModelViewer extends ImageHandler {
|
|||||||
$out->addModules('ext.glmv');
|
$out->addModules('ext.glmv');
|
||||||
$viewer = self::buildViewer($file,['class' => 'view-default']);
|
$viewer = self::buildViewer($file,['class' => 'view-default']);
|
||||||
$out->addHtml(Html::rawElement('div',['id' => 'file', 'class' => 'fullModelView'],$viewer));
|
$out->addHtml(Html::rawElement('div',['id' => 'file', 'class' => 'fullModelView'],$viewer));
|
||||||
#echo '<script>';
|
}
|
||||||
#self::console_log($imagepage->getFile()->getFullUrl());
|
|
||||||
#self::console_log($imagepage->getFile()->getDescriptionText());
|
public static function onAlternateEditPreview( EditPage $editor, Content $content, string &$previewHTML, ?ParserOutput &$parserOutput ) {
|
||||||
#self::console_log($out);
|
$file = MediaWikiServices::getInstance()->getRepoGroup()->findFile($editor->getTitle());
|
||||||
#echo '</script>';
|
if ($file->getMimeType() !== 'model/gltf-binary') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$out = $editor->getContext()->getOutput();
|
||||||
|
$out->addModules('ext.glmv');
|
||||||
|
$previewHTML = self::buildViewer($file,['class' => 'view-default']);
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function buildViewer($file, $frameParams) {
|
private static function buildViewer($file, $frameParams) {
|
||||||
@@ -83,6 +91,11 @@ class GlModelViewer extends ImageHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function console_log($data, $add_script_tags = false) {
|
public static function console_log($data, $add_script_tags = false) {
|
||||||
|
#Usage:
|
||||||
|
#echo '<script>';
|
||||||
|
#self::console_log('logged string');
|
||||||
|
#echo '</script>';
|
||||||
|
|
||||||
$command = 'console.log('. json_encode($data, JSON_HEX_TAG).');';
|
$command = 'console.log('. json_encode($data, JSON_HEX_TAG).');';
|
||||||
if ($add_script_tags) {
|
if ($add_script_tags) {
|
||||||
$command = '<script>'. $command . '</script>';
|
$command = '<script>'. $command . '</script>';
|
||||||
|
|||||||
Reference in New Issue
Block a user