Basic svg rendering
Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
@@ -1,32 +1,60 @@
|
||||
<?php
|
||||
namespace MediaWiki\Extension\AnatImageViewer;
|
||||
|
||||
use Content;
|
||||
use TextContent;
|
||||
|
||||
class AnnotationContent extends TextContent {
|
||||
public const MODEL = 'annotation';
|
||||
|
||||
public function __construct( $modelId = 'annotation' ) {
|
||||
parent::__construct( $modelId );
|
||||
/** @inheritDoc */
|
||||
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() {
|
||||
}
|
||||
|
||||
public function getTextForSummary( $maxLength = 250 ) {
|
||||
}
|
||||
|
||||
public function getSize() {
|
||||
}
|
||||
|
||||
public function copy() {
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Determines whether this content should be counted as a "page" for the wiki's statistics.
|
||||
*
|
||||
* @param bool|null $hasLinks
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
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
|
||||
namespace MediaWiki\Extension\AnatImageViewer;
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
use Devium\Toml\Toml;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use Content;
|
||||
@@ -9,12 +11,19 @@ use CodeContentHandler;
|
||||
use MediaWiki\Content\Renderer\ContentParseParams;
|
||||
use ParserOutput;
|
||||
use Html;
|
||||
use IContextSource;
|
||||
use MediaWiki\Content\ValidationParams;
|
||||
use Status;
|
||||
|
||||
|
||||
class AnnotationHandler extends CodeContentHandler {
|
||||
private const ANNOT_VERSION = '0.1';
|
||||
|
||||
public function __construct( $modelId = 'annotation' ) {
|
||||
parent::__construct( $modelId, [ CONTENT_FORMAT_TEXT ] );
|
||||
public function __construct(
|
||||
$modelId = AnnotationContent::MODEL,
|
||||
$formats = [ CONTENT_FORMAT_TEXT ]
|
||||
) {
|
||||
parent::__construct( $modelId, $formats );
|
||||
}
|
||||
|
||||
protected function getContentClass() {
|
||||
@@ -39,27 +48,23 @@ class AnnotationHandler extends CodeContentHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
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() {
|
||||
return new AnnotationContent();
|
||||
}
|
||||
|
||||
public function supportsDirectEditing() {
|
||||
return true;
|
||||
return new AnnotationContent( '' );
|
||||
}
|
||||
|
||||
protected function fillParserOutput( Content $content, ContentParseParams $cpoParams, ParserOutput &$output ) {
|
||||
self::console_log('Parsing the fucking thing', true);
|
||||
self::console_log($content, true);
|
||||
|
||||
$metadata = toml_decode($content->getNativeData(), true);
|
||||
self::console_log(var_dump($metadata), true);
|
||||
|
||||
if (isset($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.
|
||||
*
|
||||
* @param string $metadata The metadata object parsed from the text
|
||||
* @param string $baseImageUrl 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 model-viewer element inside a div container
|
||||
* @param string $baseImage The full url pointing to the base image to annotate
|
||||
* @return string Html string of the complete svg
|
||||
*/
|
||||
private function buildSvg($metadata, $baseImage) {
|
||||
self::console_log(var_dump($baseImage), true);
|
||||
//Gather basic data
|
||||
$elBaseImg = '';
|
||||
$vbHeight = 100;
|
||||
|
||||
Reference in New Issue
Block a user