2023-07-16 23:53:43
This commit is contained in:
parent
346edd0ecc
commit
4a055965ec
|
@ -0,0 +1 @@
|
|||
.idea/
|
|
@ -0,0 +1,13 @@
|
|||
# Contributing
|
||||
|
||||
- Feedback, wishes and suggestions can be sent by email.
|
||||
- Constructive criticism, bug descriptions and other reports are welcome.
|
||||
- Email: mail@ihub.to
|
||||
|
||||
## Sources
|
||||
|
||||
- [**GitHub**](https://github.com/pkgstore)
|
||||
- [GitLab](https://gitlab.com/pkgstore) (MIRROR)
|
||||
- [Codeberg](https://codeberg.org/pkgstore) (MIRROR)
|
||||
- [MosHub](https://hub.mos.ru/pkgstore) (MIRROR)
|
||||
- [Git.Org.Ru](https://git.org.ru/pkgstore) (MIRROR)
|
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2023 Package Store
|
||||
Copyright (c) 2023 iHub TO <https://ihub.to>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\PkgStore;
|
||||
|
||||
use MWException;
|
||||
use OutputPage, Parser, PPFrame, Skin;
|
||||
|
||||
/**
|
||||
* Class MW_EXT_Spoiler
|
||||
*/
|
||||
class MW_EXT_Spoiler
|
||||
{
|
||||
/**
|
||||
* Register tag function.
|
||||
*
|
||||
* @param Parser $parser
|
||||
*
|
||||
* @return void
|
||||
* @throws MWException
|
||||
*/
|
||||
public static function onParserFirstCallInit(Parser $parser): void
|
||||
{
|
||||
$parser->setHook('spoiler', [__CLASS__, 'onRenderTagSpoiler']);
|
||||
$parser->setHook('hide', [__CLASS__, 'onRenderTagHide']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render tag function: Spoiler.
|
||||
*
|
||||
* @param $input
|
||||
* @param array $args
|
||||
* @param Parser $parser
|
||||
* @param PPFrame $frame
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function onRenderTagSpoiler($input, array $args, Parser $parser, PPFrame $frame): string
|
||||
{
|
||||
// Argument: title.
|
||||
$getTitle = MW_EXT_Kernel::outClear($args['title'] ?? '' ?: '');
|
||||
$outTitle = empty($getTitle) ? MW_EXT_Kernel::getMessageText('spoiler', 'title') : $getTitle;
|
||||
|
||||
// Get content.
|
||||
$getContent = trim($input);
|
||||
$outContent = $parser->recursiveTagParse($getContent, $frame);
|
||||
|
||||
// Out HTML.
|
||||
$outHTML = '<details class="mw-spoiler navigation-not-searchable">';
|
||||
$outHTML .= '<summary>' . $outTitle . '</summary>';
|
||||
$outHTML .= '<div class="mw-spoiler-body"><div class="mw-spoiler-content">' . "\n\r" . $outContent . "\n\r" . '</div></div>';
|
||||
$outHTML .= '</details>';
|
||||
|
||||
// Out parser.
|
||||
return $outHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render tag function: Hide.
|
||||
*
|
||||
* @param $input
|
||||
* @param Parser $parser
|
||||
* @param PPFrame $frame
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function onRenderTagHide($input, Parser $parser, PPFrame $frame): string
|
||||
{
|
||||
// Get content.
|
||||
$getContent = trim($input);
|
||||
$outContent = $parser->recursiveTagParse($getContent, $frame);
|
||||
|
||||
// Out HTML.
|
||||
$outHTML = '<span class="mw-hide navigation-not-searchable">';
|
||||
$outHTML .= '<span class="mw-hide-body"><span class="mw-hide-content">' . $outContent . '</span></span>';
|
||||
$outHTML .= '</span>';
|
||||
|
||||
// Out parser.
|
||||
return $outHTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load resource function.
|
||||
*
|
||||
* @param OutputPage $out
|
||||
* @param Skin $skin
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function onBeforePageDisplay(OutputPage $out, Skin $skin): void
|
||||
{
|
||||
$out->addModuleStyles(['ext.mw.spoiler.styles']);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
// Confirm MediaWiki environment.
|
||||
if (!defined('MEDIAWIKI')) {
|
||||
die('This file is a MediaWiki extension and thus not a valid entry point.');
|
||||
}
|
||||
|
||||
if (function_exists('wfLoadExtension')) {
|
||||
wfLoadExtension('MW_EXT_Spoiler');
|
||||
// Keep i18n globals so mergeMessageFileList.php doesn't break.
|
||||
$wgExtensionMessagesFiles['MW_EXT_Spoiler'] = __DIR__ . '/i18n';
|
||||
|
||||
return;
|
||||
} else {
|
||||
die('This version of the MW_EXT_Spoiler extension requires MediaWiki 1.31+');
|
||||
}
|
19
README.md
19
README.md
|
@ -1 +1,18 @@
|
|||
# mediawiki-ext-spoiler
|
||||
# Information
|
||||
|
||||
Блок со скрытой и отображаемой информацией.
|
||||
|
||||
## Install
|
||||
|
||||
1. Загрузите папки и файлы в директорию `extensions/MW_EXT_Spoiler`.
|
||||
2. В самый низ файла `LocalSettings.php` добавьте строку:
|
||||
|
||||
```php
|
||||
wfLoadExtension( 'MW_EXT_Spoiler' );
|
||||
```
|
||||
|
||||
## Syntax
|
||||
|
||||
```html
|
||||
<spoiler title="[TITLE]">[CONTENT]</spoiler>
|
||||
```
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"name": "pkgstore/mediawiki-ext-spoiler",
|
||||
"type": "mediawiki-extension",
|
||||
"description": "MediaWiki spoiler extension.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://ihub.to/",
|
||||
"keywords": [
|
||||
"mediawiki",
|
||||
"spoiler"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "iHub TO",
|
||||
"email": "mail@ihub.to",
|
||||
"homepage": "https://ihub.to/",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "Kitsune Solar",
|
||||
"email": "mail@kitsune.solar",
|
||||
"homepage": "https://kitsune.solar/",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/pkgstore/mediawiki-ext-spoiler/issues",
|
||||
"source": "https://github.com/pkgstore/mediawiki-ext-spoiler"
|
||||
},
|
||||
"require": {
|
||||
"composer/installers": "^1.0.1",
|
||||
"php": ">=8.2",
|
||||
"pkgstore/mediawiki-ext-kernel": "*"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"MW_EXT_Spoiler.class.php"
|
||||
]
|
||||
},
|
||||
"config": {
|
||||
"optimize-autoloader": true,
|
||||
"prepend-autoloader": false
|
||||
},
|
||||
"extra": {
|
||||
"installer-name": "MW_EXT_Spoiler"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"name": "MW_EXT_Spoiler",
|
||||
"version": "1.0.0",
|
||||
"author": [
|
||||
"[https://ihub.to/ iHub TO]",
|
||||
"[https://kitsune.solar/ Kitsune Solar]",
|
||||
"..."
|
||||
],
|
||||
"url": "https://ihub.to/",
|
||||
"descriptionmsg": "mw-spoiler-desc",
|
||||
"license-name": "[https://choosealicense.com/licenses/mit/ MIT]",
|
||||
"type": "parserhook",
|
||||
"require": {
|
||||
"MediaWiki": ">= 1.31.0",
|
||||
"extensions": {
|
||||
"MW_EXT_Kernel": "*"
|
||||
}
|
||||
},
|
||||
"AutoloadClasses": {
|
||||
"MediaWiki\\Extension\\PkgStore\\MW_EXT_Spoiler": "MW_EXT_Spoiler.class.php"
|
||||
},
|
||||
"Hooks": {
|
||||
"ParserFirstCallInit": [
|
||||
"MediaWiki\\Extension\\PkgStore\\MW_EXT_Spoiler::onParserFirstCallInit"
|
||||
],
|
||||
"BeforePageDisplay": [
|
||||
"MediaWiki\\Extension\\PkgStore\\MW_EXT_Spoiler::onBeforePageDisplay"
|
||||
]
|
||||
},
|
||||
"MessagesDirs": {
|
||||
"MW_EXT_Spoiler": [
|
||||
"i18n"
|
||||
]
|
||||
},
|
||||
"ResourceModules": {
|
||||
"ext.mw.spoiler.styles": {
|
||||
"styles": [
|
||||
"styles/theme.css"
|
||||
],
|
||||
"position": "top",
|
||||
"targets": [
|
||||
"desktop",
|
||||
"mobile"
|
||||
]
|
||||
}
|
||||
},
|
||||
"ResourceFileModulePaths": {
|
||||
"localBasePath": "modules",
|
||||
"remoteExtPath": "MW_EXT_Spoiler/modules"
|
||||
},
|
||||
"manifest_version": 2
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"@metadata": {
|
||||
"authors": [
|
||||
"iHub TO"
|
||||
]
|
||||
},
|
||||
"mw-spoiler-desc": "Блок со скрытой и отображаемой информацией.",
|
||||
"mw-spoiler-title": "Скрытая информация"
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
.mw-spoiler {
|
||||
box-shadow: 0 2px 3px rgba(10, 10, 10, .1), 0 0 0 1px rgba(10, 10, 10, .1);
|
||||
margin: 1em 0;
|
||||
padding: 1em;
|
||||
|
||||
summary {
|
||||
cursor: pointer;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
&[open] {
|
||||
.mw-spoiler-content {
|
||||
animation: open .5s ease-in-out;
|
||||
}
|
||||
}
|
||||
|
||||
&-body {
|
||||
border-top: 1px solid hsl(0, 0%, 86%);
|
||||
padding: 1em 0 0;
|
||||
margin: 1em 0 0;
|
||||
}
|
||||
|
||||
&-content {
|
||||
background: hsl(0, 0%, 98%);
|
||||
border: 1px solid hsl(0, 0%, 86%);
|
||||
box-shadow: inset 0 1px 2px rgba(10, 10, 10, .1);
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
@keyframes open {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.mw-hide {
|
||||
&-body {
|
||||
cursor: help;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
&-body {
|
||||
visibility: visible;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
.mw-spoiler{box-shadow:0 2px 3px rgba(10,10,10,0.1),0 0 0 1px rgba(10,10,10,0.1);margin:1em 0;padding:1em}.mw-spoiler summary{cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.mw-spoiler[open] .mw-spoiler-content{animation:open .5s ease-in-out}.mw-spoiler-body{border-top:1px solid #dbdbdb;padding:1em 0 0;margin:1em 0 0}.mw-spoiler-content{background:#fafafa;border:1px solid #dbdbdb;box-shadow:inset 0 1px 2px rgba(10,10,10,0.1);padding:1em}@keyframes open{0%{opacity:0}100%{opacity:1}}.mw-hide-body{cursor:help;visibility:hidden}.mw-hide:hover-body{visibility:visible}
|
|
@ -0,0 +1 @@
|
|||
@import 'main.scss';
|
Loading…
Reference in New Issue