commit 6a5237bd8cf5f2b90842ff12e394922464c33768 Author: webuser@infra.woelkchen.at Date: Tue Mar 19 22:33:58 2024 +0100 Added 1.0 files diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..000caf0 --- /dev/null +++ b/extension.json @@ -0,0 +1,35 @@ +{ + "name": "Spoilerâ–“Alert", + "author": "Samuel Maenle", + "url": "https://git.maenle.net/diocloid/SpoilerAlert", + "description": "This MediaWiki extension allows users to create spoiler tags that reveal content on click. <spoiler> I am a spoiler </spoiler>", + "type": "parserhook", + "version": "1.0", + "license-name": "AGPL-3.0-only", + "manifest_version": 2, + "AutoloadClasses": { + "SpoilerAlertHooks": "includes/SpoilerAlertHooks.php" + }, + "Hooks": { + "BeforePageDisplay": [ + "SpoilerAlertHooks::onBeforePageDisplay" + ], + "ParserFirstCallInit": [ + "SpoilerAlertHooks::onParserFirstCallInit" + ] + }, + "ResourceModules": { + "ext.spoileralert": { + "scripts": [ + ], + "styles": [ + "/modules/ext.spoileralert.css" + ], + "position": "top" + } + }, + "ResourceFileModulePaths": { + "localBasePath": "", + "remoteExtPath": "SpoilerAlert" + } +} diff --git a/includes/SpoilerAlertHooks.php b/includes/SpoilerAlertHooks.php new file mode 100644 index 0000000..3c9524f --- /dev/null +++ b/includes/SpoilerAlertHooks.php @@ -0,0 +1,17 @@ +setHook( 'spoiler', [ self::class, 'renderSpoiler' ] ); + return true; + } + + public static function renderSpoiler( $input, array $args, Parser $parser, PPFrame $frame ) { + $output = $parser->recursiveTagParse( $input, $frame ); + return "" . htmlspecialchars( $output ) . ""; + } + + public static function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) { + $out->addModules( ['ext.spoileralert'] ); + return true; + } +} diff --git a/modules/ext.spoileralert.css b/modules/ext.spoileralert.css new file mode 100644 index 0000000..6d7043c --- /dev/null +++ b/modules/ext.spoileralert.css @@ -0,0 +1,10 @@ +.spoiler { + background-color: black; + color: black; + transition: color 0.5s ease; + cursor: pointer; +} + +.spoiler.revealed { + color: white; +}