2023-07-16 23:53:37

This commit is contained in:
z17CX 2023-07-16 23:53:37 +00:00
parent 366e6d18dc
commit 99df3fd6d2
Signed by: z17cx
GPG Key ID: 3F5F87C84EE943E4
14 changed files with 263 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea/

0
CHANGELOG.md Normal file
View File

13
CONTRIBUTING.md Normal file
View File

@ -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)

View File

@ -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

77
MW_EXT_Quote.class.php Normal file
View File

@ -0,0 +1,77 @@
<?php
namespace MediaWiki\Extension\PkgStore;
use MWException;
use OutputPage, Parser, PPFrame, Skin;
/**
* Class MW_EXT_Quote
*/
class MW_EXT_Quote
{
/**
* Register tag function.
*
* @param Parser $parser
*
* @return void
* @throws MWException
*/
public static function onParserFirstCallInit(Parser $parser): void
{
$parser->setHook('quote', [__CLASS__, 'onRenderTag']);
}
/**
* Render tag function.
*
* @param $input
* @param array $args
* @param Parser $parser
* @param PPFrame $frame
*
* @return string
*/
public static function onRenderTag($input, array $args, Parser $parser, PPFrame $frame): string
{
// Argument: source.
$getSource = MW_EXT_Kernel::outClear($args['source'] ?? '' ?: '');
$outSource = $getSource;
// Argument: person.
$getSign = MW_EXT_Kernel::outClear($args['sign'] ?? '' ?: '');
$outSign = empty($getSign) ? '' : '<span><i class="far fa-user fa-fw"></i> <a href="' . $outSource . '" target="_blank">' . $getSign . '</a></span>';
// Argument: date.
$getDate = MW_EXT_Kernel::outClear($args['date'] ?? '' ?: '');
$outDate = empty($getDate) ? '' : '<span><i class="far fa-clock fa-fw"></i> ' . $getDate . '</span>';
// Get content.
$getContent = trim($input);
$outContent = $parser->recursiveTagParse($getContent, $frame);
// Check person and date arguments, and set footer.
if ($outSign || $outDate) {
$outFooter = '<footer><cite>' . $outSign . $outDate . '</cite></footer>';
} else {
$outFooter = '';
}
// Out parser.
return '<blockquote class="mw-quote navigation-not-searchable" cite="' . $outSource . '"><div class="mw-quote-content">' . $outContent . '</div>' . $outFooter . '</blockquote>';
}
/**
* Load resource function.
*
* @param OutputPage $out
* @param Skin $skin
*
* @return void
*/
public static function onBeforePageDisplay(OutputPage $out, Skin $skin): void
{
$out->addModuleStyles(['ext.mw.quote.styles']);
}
}

16
MW_EXT_Quote.php Normal file
View File

@ -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_Quote');
// Keep i18n globals so mergeMessageFileList.php doesn't break.
$wgExtensionMessagesFiles['MW_EXT_Quote'] = __DIR__ . '/i18n';
return;
} else {
die('This version of the MW_EXT_Quote extension requires MediaWiki 1.31+');
}

View File

@ -1 +1,18 @@
# mediawiki-ext-quote
# Information
Интеграция цитаты в статью.
## Install
1. Загрузите папки и файлы в директорию `extensions/MW_EXT_Quote`.
2. В самый низ файла `LocalSettings.php` добавьте строку:
```php
wfLoadExtension( 'MW_EXT_Quote' );
```
## Syntax
```html
<quote source="[SOURCE]" date="[DATE]" sign="[PERSON]">[CONTENT]</quote>
```

46
composer.json Normal file
View File

@ -0,0 +1,46 @@
{
"name": "pkgstore/mediawiki-ext-quote",
"type": "mediawiki-extension",
"description": "MediaWiki quote extension.",
"license": "MIT",
"homepage": "https://ihub.to/",
"keywords": [
"mediawiki",
"quote"
],
"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-quote/issues",
"source": "https://github.com/pkgstore/mediawiki-ext-quote"
},
"require": {
"composer/installers": "^1.0.1",
"php": ">=8.2",
"pkgstore/mediawiki-ext-kernel": "*"
},
"autoload": {
"classmap": [
"MW_EXT_Quote.class.php"
]
},
"config": {
"optimize-autoloader": true,
"prepend-autoloader": false
},
"extra": {
"installer-name": "MW_EXT_Quote"
}
}

52
extension.json Normal file
View File

@ -0,0 +1,52 @@
{
"name": "MW_EXT_Quote",
"version": "1.0.0",
"author": [
"[https://ihub.to/ iHub TO]",
"[https://kitsune.solar/ Kitsune Solar]",
"..."
],
"url": "https://ihub.to/",
"descriptionmsg": "mw-quote-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_Quote": "MW_EXT_Quote.class.php"
},
"Hooks": {
"ParserFirstCallInit": [
"MediaWiki\\Extension\\PkgStore\\MW_EXT_Quote::onParserFirstCallInit"
],
"BeforePageDisplay": [
"MediaWiki\\Extension\\PkgStore\\MW_EXT_Quote::onBeforePageDisplay"
]
},
"MessagesDirs": {
"MW_EXT_Quote": [
"i18n"
]
},
"ResourceModules": {
"ext.mw.quote.styles": {
"styles": [
"styles/theme.css"
],
"position": "top",
"targets": [
"desktop",
"mobile"
]
}
},
"ResourceFileModulePaths": {
"localBasePath": "modules",
"remoteExtPath": "MW_EXT_Quote/modules"
},
"manifest_version": 2
}

8
i18n/ru.json Normal file
View File

@ -0,0 +1,8 @@
{
"@metadata": {
"authors": [
"iHub TO"
]
},
"mw-quote-desc": "Интеграция цитаты в статью."
}

23
modules/styles/_main.scss Normal file
View File

@ -0,0 +1,23 @@
.mw-quote {
background-color: hsl(0, 0%, 96%);
border-left: 3px solid hsl(0, 0%, 86%);
margin: 1em 0;
padding: 1em;
width: 50%;
footer {
color: hsl(0, 0%, 48%);
font-style: italic;
text-align: right;
}
cite {
span {
display: inline-block;
&:last-child {
margin-left: .5rem;
}
}
}
}

View File

@ -0,0 +1,5 @@
@media (max-width: 1087px) {
.mw-quote {
width: auto;
}
}

1
modules/styles/theme.css Normal file
View File

@ -0,0 +1 @@
.mw-quote{background-color:#f5f5f5;border-left:3px solid #dbdbdb;margin:1em 0;padding:1em;width:50%}.mw-quote footer{color:#7a7a7a;font-style:italic;text-align:right}.mw-quote cite span{display:inline-block}.mw-quote cite span:last-child{margin-left:.5rem}@media (max-width: 1087px){.mw-quote{width:auto}}

View File

@ -0,0 +1,2 @@
@import 'main.scss';
@import 'media.scss';