Stuck point

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2026-05-18 08:56:56 -07:00
parent d39458d53b
commit c4e783dd9d
4 changed files with 46 additions and 24 deletions

View File

@@ -13,17 +13,13 @@
"constant": "NS_AV_ANNOT", "constant": "NS_AV_ANNOT",
"name": "Annotation", "name": "Annotation",
"protection": "annotations-edit", "protection": "annotations-edit",
"subpages": false, "subpages": false
"content": true,
"defaultcontentmodel": "annotation"
}, },
{ {
"id": 2219, "id": 2219,
"constant": "NS_AV_ANNOT_TALK", "constant": "NS_AV_ANNOT_TALK",
"name": "Annotation_talk", "name": "Annotation_talk",
"subpages": true, "subpages": true
"content": false,
"defaultcontentmodel": "wikitext"
} }
], ],
"callback": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::registrationCallback", "callback": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::registrationCallback",
@@ -31,8 +27,9 @@
"MediaWiki\\Extension\\AnatImageViewer\\": "includes/" "MediaWiki\\Extension\\AnatImageViewer\\": "includes/"
}, },
"ContentHandlers": { "ContentHandlers": {
"annotation": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHandler" "annotation": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHandler::class"
}, },
"Hooks": { "Hooks": {
"ContentHandlerDefaultModelFor": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::onContentHandlerDefaultModelFor"
} }
} }

View File

@@ -8,7 +8,7 @@ class AnnotationContent extends TextContent {
public function __construct( $modelId = 'annotation' ) { public function __construct( $modelId = 'annotation' ) {
parent::__construct( $modelId ); parent::__construct( $modelId );
} }
/* /*
public function getTextForSearchIndex() { public function getTextForSearchIndex() {
} }

View File

@@ -4,20 +4,41 @@ namespace MediaWiki\Extension\AnatImageViewer;
use Devium\Toml\Toml; use Devium\Toml\Toml;
use MediaWiki\MediaWikiServices; use MediaWiki\MediaWikiServices;
use Content; use Content;
use TextContentHandler; use Title;
use CodeContentHandler;
use MediaWiki\Content\Renderer\ContentParseParams; use MediaWiki\Content\Renderer\ContentParseParams;
use ParserOutput; use ParserOutput;
use ConfigFactory;
use RequestContext;
use Html; use Html;
class AnnotationHandler extends TextContentHandler { class AnnotationHandler extends CodeContentHandler {
private const ANNOT_VERSION = '0.1'; private const ANNOT_VERSION = '0.1';
public function __construct( $modelId = 'annotation' ) { public function __construct( $modelId = 'annotation' ) {
parent::__construct( $modelId, [ CONTENT_FORMAT_TEXT ] ); parent::__construct( $modelId, [ CONTENT_FORMAT_TEXT ] );
} }
protected function getContentClass() {
return AnnotationContent::class;
}
/**
* Only allow this content handler to be used in the Module namespace
* @param Title $title
* @return bool
*/
public function canBeUsedOn( Title $title ) {
if ( $title->getNamespace() !== NS_AV_ANNOT ) {
return false;
}
return parent::canBeUsedOn( $title );
}
/** @inheritDoc */
public function supportsPreloadContent(): bool {
return true;
}
/* /*
public function serializeContent( Content $content, $format = null ) { public function serializeContent( Content $content, $format = null ) {
} }
@@ -25,7 +46,7 @@ class AnnotationHandler extends TextContentHandler {
public function unserializeContent( $blob, $format = null ) { public function unserializeContent( $blob, $format = null ) {
} }
*/ */
public function makeEmptyContent() { public function makeEmptyContent() {
return new AnnotationContent(); return new AnnotationContent();
} }
@@ -35,9 +56,7 @@ class AnnotationHandler extends TextContentHandler {
} }
protected function fillParserOutput( Content $content, ContentParseParams $cpoParams, ParserOutput &$output ) { protected function fillParserOutput( Content $content, ContentParseParams $cpoParams, ParserOutput &$output ) {
// define $html somewhere self::console_log('Parsing the fucking thing', true);
// e.g. $output->setText( $html );
self::console_log($content, true); self::console_log($content, true);
$metadata = toml_decode($content->getNativeData(), true); $metadata = toml_decode($content->getNativeData(), true);
@@ -83,8 +102,6 @@ class AnnotationHandler extends TextContentHandler {
); );
$elBaseImg = Html::rawElement('image', $attrBase); $elBaseImg = Html::rawElement('image', $attrBase);
} }
$mainConfig = ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
$context = RequestContext::getMain();
//Render and return svg //Render and return svg
$attrSvg = array( $attrSvg = array(

View File

@@ -1,17 +1,25 @@
<?php <?php
namespace MediaWiki\Extension\AnatImageViewer; namespace MediaWiki\Extension\AnatImageViewer;
use MediaWiki\MediaWikiServices;
use RequestContext;
use Html;
use ParserOutput;
class AnnotationHooks { class AnnotationHooks {
public static function registrationCallback() { public static function registrationCallback() {
// Must match the name used in the 'ContentHandlers' section of extension.json
define( 'CONTENT_MODEL_ANNOTATION', 'annotation' ); define( 'CONTENT_MODEL_ANNOTATION', 'annotation' );
} }
/**
* Set the content handler for annotations
*
* @param Title $title
* @param string &$model
* @return void
*/
public static function onContentHandlerDefaultModelFor( $title, &$model ) {
if ( $title->getNamespace() === NS_AV_ANNOT ) {
self::console_log('Found fucking thing!',true);
$model = CONTENT_MODEL_ANNOTATION;
}
}
/** /**
* Small helper function to display information on the browser console * Small helper function to display information on the browser console
* *