Move to namespace specific svg annotations #1
@@ -7,29 +7,32 @@
|
|||||||
"license-name": "MIT",
|
"license-name": "MIT",
|
||||||
"type": "media",
|
"type": "media",
|
||||||
"manifest_version": 1,
|
"manifest_version": 1,
|
||||||
|
"requires": {
|
||||||
|
"MediaWiki": ">= 1.39.0"
|
||||||
|
},
|
||||||
"namespaces": [
|
"namespaces": [
|
||||||
{
|
{
|
||||||
"id": 2218,
|
"id": 2218,
|
||||||
"constant": "NS_AV_ANNOT",
|
"constant": "NS_AV_ANNOT",
|
||||||
"name": "Annotation",
|
"name": "Annotation",
|
||||||
"protection": "annotations-edit",
|
"protection": "annotations-edit",
|
||||||
"subpages": false
|
"subpages": false,
|
||||||
|
"content": false,
|
||||||
|
"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",
|
|
||||||
"AutoloadNamespaces": {
|
"AutoloadNamespaces": {
|
||||||
"MediaWiki\\Extension\\AnatImageViewer\\": "includes/"
|
"MediaWiki\\Extension\\AnatImageViewer\\": "includes/"
|
||||||
},
|
},
|
||||||
"ContentHandlers": {
|
"ContentHandlers": {
|
||||||
"annotation": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHandler::class"
|
"annotation": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHandler"
|
||||||
},
|
|
||||||
"Hooks": {
|
|
||||||
"ContentHandlerDefaultModelFor": "MediaWiki\\Extension\\AnatImageViewer\\AnnotationHooks::onContentHandlerDefaultModelFor"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,32 +1,60 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace MediaWiki\Extension\AnatImageViewer;
|
namespace MediaWiki\Extension\AnatImageViewer;
|
||||||
|
|
||||||
|
use Content;
|
||||||
use TextContent;
|
use TextContent;
|
||||||
|
|
||||||
class AnnotationContent extends TextContent {
|
class AnnotationContent extends TextContent {
|
||||||
|
public const MODEL = 'annotation';
|
||||||
|
|
||||||
public function __construct( $modelId = 'annotation' ) {
|
/** @inheritDoc */
|
||||||
parent::__construct( $modelId );
|
public function __construct( $text, $model_id = self::MODEL ) {
|
||||||
|
parent::__construct( $text, $model_id );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
public function getTextForSearchIndex() {
|
* Determines whether this content can be considered empty.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isEmpty() {
|
||||||
|
$text = trim( strip_tags( $this->getText() ) );
|
||||||
|
return $text === '';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getWikitextForTransclusion() {
|
/**
|
||||||
}
|
* Determines whether this content should be counted as a "page" for the wiki's statistics.
|
||||||
|
*
|
||||||
public function getTextForSummary( $maxLength = 250 ) {
|
* @param bool|null $hasLinks
|
||||||
}
|
*
|
||||||
|
* @return bool
|
||||||
public function getSize() {
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
public function copy() {
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public function isCountable( $hasLinks = null ) {
|
public function isCountable( $hasLinks = null ) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isValid() {
|
||||||
|
return parent::isValid();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should return text relevant to the wiki's search index.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getTextForSearchIndex() {
|
||||||
|
return strip_tags( $this->getText() );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function convert( $toModel, $lossy = '' ) {
|
||||||
|
return parent::convert( $toModel, $lossy );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSection( $sectionId ) {
|
||||||
|
return parent::getSection( $sectionId );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function replaceSection( $sectionId, Content $with, $sectionTitle = '' ) {
|
||||||
|
return parent::replaceSection( $sectionId, $with, $sectionTitle );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace MediaWiki\Extension\AnatImageViewer;
|
namespace MediaWiki\Extension\AnatImageViewer;
|
||||||
|
|
||||||
|
require_once __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
use Devium\Toml\Toml;
|
use Devium\Toml\Toml;
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\MediaWikiServices;
|
||||||
use Content;
|
use Content;
|
||||||
@@ -9,12 +11,19 @@ use CodeContentHandler;
|
|||||||
use MediaWiki\Content\Renderer\ContentParseParams;
|
use MediaWiki\Content\Renderer\ContentParseParams;
|
||||||
use ParserOutput;
|
use ParserOutput;
|
||||||
use Html;
|
use Html;
|
||||||
|
use IContextSource;
|
||||||
|
use MediaWiki\Content\ValidationParams;
|
||||||
|
use Status;
|
||||||
|
|
||||||
|
|
||||||
class AnnotationHandler extends CodeContentHandler {
|
class AnnotationHandler extends CodeContentHandler {
|
||||||
private const ANNOT_VERSION = '0.1';
|
private const ANNOT_VERSION = '0.1';
|
||||||
|
|
||||||
public function __construct( $modelId = 'annotation' ) {
|
public function __construct(
|
||||||
parent::__construct( $modelId, [ CONTENT_FORMAT_TEXT ] );
|
$modelId = AnnotationContent::MODEL,
|
||||||
|
$formats = [ CONTENT_FORMAT_TEXT ]
|
||||||
|
) {
|
||||||
|
parent::__construct( $modelId, $formats );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getContentClass() {
|
protected function getContentClass() {
|
||||||
@@ -39,27 +48,23 @@ class AnnotationHandler extends CodeContentHandler {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public function serializeContent( Content $content, $format = null ) {
|
public function serializeContent( Content $content, $format = null ) {
|
||||||
|
return parent::serializeContent( $content, $format );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unserializeContent( $blob, $format = null ) {
|
public function unserializeContent( $text, $format = null ) {
|
||||||
|
return new AnnotationContent( $text );
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
public function makeEmptyContent() {
|
public function makeEmptyContent() {
|
||||||
return new AnnotationContent();
|
return new AnnotationContent( '' );
|
||||||
}
|
|
||||||
|
|
||||||
public function supportsDirectEditing() {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function fillParserOutput( Content $content, ContentParseParams $cpoParams, ParserOutput &$output ) {
|
protected function fillParserOutput( Content $content, ContentParseParams $cpoParams, ParserOutput &$output ) {
|
||||||
self::console_log('Parsing the fucking thing', true);
|
self::console_log('Parsing the fucking thing', true);
|
||||||
self::console_log($content, true);
|
|
||||||
|
|
||||||
$metadata = toml_decode($content->getNativeData(), true);
|
$metadata = toml_decode($content->getNativeData(), true);
|
||||||
|
self::console_log(var_dump($metadata), true);
|
||||||
|
|
||||||
if (isset($metadata['baseImage'])) {
|
if (isset($metadata['baseImage'])) {
|
||||||
$baseImage = MediaWikiServices::getInstance()->getRepoGroup()->findFile('File:' . $metadata['baseImage']);
|
$baseImage = MediaWikiServices::getInstance()->getRepoGroup()->findFile('File:' . $metadata['baseImage']);
|
||||||
@@ -77,11 +82,11 @@ class AnnotationHandler extends CodeContentHandler {
|
|||||||
* and produces the html string for the svg with base image and annotations.
|
* and produces the html string for the svg with base image and annotations.
|
||||||
*
|
*
|
||||||
* @param string $metadata The metadata object parsed from the text
|
* @param string $metadata The metadata object parsed from the text
|
||||||
* @param string $baseImageUrl The full url pointing to the base image to annotate
|
* @param string $baseImage The full url pointing to the base image to annotate
|
||||||
* @param array $frameParams The additional user defined parameters for the viewer such as hotspot and view classes
|
* @return string Html string of the complete svg
|
||||||
* @return string Html string of the complete model-viewer element inside a div container
|
|
||||||
*/
|
*/
|
||||||
private function buildSvg($metadata, $baseImage) {
|
private function buildSvg($metadata, $baseImage) {
|
||||||
|
self::console_log(var_dump($baseImage), true);
|
||||||
//Gather basic data
|
//Gather basic data
|
||||||
$elBaseImg = '';
|
$elBaseImg = '';
|
||||||
$vbHeight = 100;
|
$vbHeight = 100;
|
||||||
|
|||||||
Reference in New Issue
Block a user