Commit a8735bef authored by Marijn van Wezel's avatar Marijn van Wezel
Browse files

Merge branch 'master' of gitlab.wikibase.nl:extensions/semantic-structured-discussions

parents 8eb0df81 28605a3c
Pipeline #2762 passed with stage
in 10 seconds
......@@ -10,5 +10,13 @@ Semantic Versioning [1].
UNRELEASED
----------
1.0.0 - 20-02-2022
------------------
Added:
- Initial release.
[0]: https://keepachangelog.com/en/1.0.0/
[1]: https://semver.org/spec/v2.0.0.html
# Semantic Structured Discussions
Semantic Structured Discussions is an extension for MediaWiki that adds semantic annotations to Structured Discussions
(Flow) topics. More information can be found on its
[MediaWiki](https://www.mediawiki.org/wiki/Extension:Semantic_Structured_Discussions) page.
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......@@ -19,8 +19,6 @@
*/
use MediaWiki\MediaWikiServices;
use SemanticStructuredDiscussions\Hooks\SemanticStructuredDiscussionsHookRunner;
use SemanticStructuredDiscussions\SemanticMediaWiki\AnnotatorFactory;
use SemanticStructuredDiscussions\SemanticMediaWiki\AnnotatorStore;
use SemanticStructuredDiscussions\SemanticMediaWiki\DataAnnotator;
use SemanticStructuredDiscussions\Services;
......@@ -47,7 +45,9 @@ return [
*
* @return DataAnnotator The DataAnnotator singleton
*/
'SemanticStructuredDiscussions.SemanticMediaWiki.DataAnnotator' => static function ( MediaWikiServices $services ): DataAnnotator {
'SemanticStructuredDiscussions.SemanticMediaWiki.DataAnnotator' => static function (
MediaWikiServices $services
): DataAnnotator {
return new DataAnnotator( Services::getAnnotatorStore( $services ) );
},
/**
......
......@@ -7,7 +7,7 @@
"semantic",
"semantic-mediawiki"
],
"homepage": "http://www.mediawiki.org/wiki/Extension:Semantic_Structured_Discussions",
"homepage": "https://www.mediawiki.org/wiki/Extension:Semantic_Structured_Discussions",
"license": "GPL-2.0-or-later",
"authors": [
{
......@@ -22,20 +22,6 @@
"require": {
"php": ">=7.4.0"
},
"require-dev": {
"mediawiki/mediawiki-codesniffer": "34.0.0",
"mediawiki/mediawiki-phan-config": "0.10.6",
"mediawiki/minus-x": "1.1.1",
"php-parallel-lint/php-console-highlighter": "0.5.0",
"php-parallel-lint/php-parallel-lint": "1.3.0"
},
"scripts": {
"lint": "parallel-lint . --exclude vendor --exclude node_modules --exclude .git",
"phpcs": "phpcs -p -s",
"minusx": "minus-x check .",
"phpunit": "php ../../tests/phpunit/phpunit.php -c phpunit.xml.dist",
"test": "composer phpunit tests/"
},
"config": {
"process-timeout": 600
}
......
{
"name": "Semantic Structured Discussions",
"type": "semantic",
"version": "0.1.1",
"version": "1.0.0",
"author": [
"Marijn van Wezel"
"Marijn van Wezel ([https://wikibase-solutions.com Wikibase Solutions])"
],
"url": "https://www.mediawiki.org/wiki/Extension:Semantic_Structured_Discussions",
"descriptionmsg": "semanticstructureddiscussions-desc",
......@@ -30,7 +30,7 @@
"SemanticStructuredDiscussionsMagic": "i18n/SemanticStructuredDiscussions.i18n.php"
},
"ServiceWiringFiles": [
"SemanticStructuredDiscussions.ServiceWiring.php"
"SemanticStructuredDiscussions.ServiceWiring.php"
],
"Hooks": {
"APIFlowAfterExecute": "SemanticStructuredDiscussions\\Hooks::onAPIFlowAfterExecute",
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......@@ -45,6 +45,7 @@ final class Hooks {
*/
public static function onRegisterExtension(): void {
// Enable semantic annotations for pages in the "Topic" namespace
// phpcs:ignore MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix
global $smwgNamespacesWithSemanticLinks;
$smwgNamespacesWithSemanticLinks[NS_TOPIC] = true;
}
......@@ -82,7 +83,7 @@ final class Hooks {
return;
}
Services::getDataAnnotator()->addAnnotations( $topic, $title, $semanticData );
Services::getDataAnnotator()->addAnnotations( $topic, $semanticData );
}
/**
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......@@ -20,18 +20,20 @@
namespace SemanticStructuredDiscussions\SemanticMediaWiki;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\ReplyAnnotators\ReplyAnnotator;
// @codingStandardsIgnoreStart
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\ReplyAnnotators\ContentAnnotator as ReplyContentAnnotator;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\ReplyAnnotators\CreatorAnnotator as ReplyCreatorAnnotator;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\ReplyAnnotators\ModificationDateAnnotator as ReplyModificationDateAnnotator;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\TopicAnnotators\TopicAnnotator;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\ReplyAnnotators\ReplyAnnotator;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\TopicAnnotators\CreatorAnnotator as TopicCreatorAnnotator;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\TopicAnnotators\ModificationDateAnnotator as TopicModificationDateAnnotator;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\TopicAnnotators\OwnerAnnotation as TopicOwnerAnnotation;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\TopicAnnotators\SummaryAnnotator as TopicSummaryAnnotator;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\TopicAnnotators\TitleAnnotator as TopicTitleAnnotator;
use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\TopicAnnotators\TopicAnnotator;
use SemanticStructuredDiscussions\StructuredDiscussions\SDReply;
use SemanticStructuredDiscussions\StructuredDiscussions\SDTopic;
// @codingStandardsIgnoreEnd
class AnnotatorStore {
private const TOPIC_ANNOTATORS = [
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......@@ -24,8 +24,14 @@ use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\Annotator;
use SemanticStructuredDiscussions\StructuredDiscussions\SDReply;
abstract class ReplyAnnotator implements Annotator {
/**
* @var SDReply The reply-information to use for annotating
*/
protected SDReply $reply;
/**
* @param SDReply $reply The reply-information to use for annotating
*/
public function __construct( SDReply $reply ) {
$this->reply = $reply;
}
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......@@ -20,7 +20,6 @@
namespace SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\TopicAnnotators;
use SemanticStructuredDiscussions\StructuredDiscussions\SDTopic;
use SMW\DIProperty;
use SMW\SemanticData;
use SMWDITime;
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......@@ -21,7 +21,6 @@
namespace SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\TopicAnnotators;
use Flow\Exception\CrossWikiException;
use Flow\Exception\DataModelException;
use Flow\Exception\InvalidInputException;
use SMW\DIProperty;
use SMW\SemanticData;
......@@ -36,7 +35,7 @@ class OwnerAnnotation extends TopicAnnotator {
public function addAnnotation( SemanticData $semanticData ): void {
try {
$topicArticle = $this->topic->getTopicOwner();
} catch (CrossWikiException|InvalidInputException $e) {
} catch ( CrossWikiException | InvalidInputException $e ) {
// Silently ignore specifically these exceptions
return;
}
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......@@ -24,8 +24,14 @@ use SemanticStructuredDiscussions\SemanticMediaWiki\Annotators\Annotator;
use SemanticStructuredDiscussions\StructuredDiscussions\SDTopic;
abstract class TopicAnnotator implements Annotator {
/**
* @var SDTopic The topic-information to use for annotating
*/
protected SDTopic $topic;
/**
* @param SDTopic $topic The topic-information to use for annotating
*/
public function __construct( SDTopic $topic ) {
$this->topic = $topic;
}
......
<?php declare(strict_types=1);
<?php declare( strict_types=1 );
/**
* Semantic Structured Discussions MediaWiki extension
* Copyright (C) 2022 Wikibase Solutions
......@@ -27,7 +27,8 @@ use SMW\Subobject;
use Title;
/**
* This class is responsible for annotating the SemanticData object with information about the given topic and its replies.
* This class is responsible for annotating the SemanticData object with information about
* the given topic and its replies.
*/
class DataAnnotator {
/**
......@@ -46,17 +47,16 @@ class DataAnnotator {
* Adds annotations to the given SemanticData object about the given Topic.
*
* @param SDTopic $topic The topic about which to add annotations
* @param Title $title The Title of the page to annotate
* @param SemanticData $semanticData The SemanticData object to add the annotations to
*/
public function addAnnotations( SDTopic $topic, Title $title, SemanticData $semanticData ): void {
if ( $topic->isModerated() ) {
// Do not annotate the topic if it is moderated, since this WILL lead to information leakage
public function addAnnotations( SDTopic $topic, SemanticData $semanticData ): void {
if ( !$topic->isEveryoneAllowed() ) {
// Do not annotate the topic if it is not viewable by everyone, since this WILL lead to information leakage
return;
}
$this->addTopicAnnotations( $topic, $semanticData );
$this->addRepliesAnnotations( $topic->getReplies(), $title, $semanticData );
$this->addRepliesAnnotations( $topic->getReplies(), $semanticData );
}
/**
......@@ -66,20 +66,18 @@ class DataAnnotator {
* @param Title $title
* @param SemanticData $semanticData
*/
private function addRepliesAnnotations( array $replies, Title $title, SemanticData $semanticData ): void {
private function addRepliesAnnotations( array $replies, SemanticData $semanticData ): void {
foreach ( $replies as $reply ) {
if ( $reply->isModerated() ) {
// Do not annotate the reply if it is moderated, since this WILL lead to information leakage
if ( !$reply->isEveryoneAllowed() ) {
// Do not annotate the reply if it is not viewable by everyone, since this WILL lead to
// information leakage
continue;
}
$subobject = new Subobject( $title );
$subobject = new Subobject( $semanticData->getSubject()->getTitle() );
$subobject->setEmptyContainerForId( sprintf( 'flow-post-%s', $reply->getPostId() ) );
/** @var SemanticData $subobjectData */
$subobjectData = $subobject->getSemanticData();
$this->addReplyAnnotations( $reply, $subobjectData );
$this->addReplyAnnotations( $reply, $subobject->getSemanticData() );
$semanticData->addSubobject( $subobject );
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment