From 013bef88637b992de95824f7055d6dcb4d242f23 Mon Sep 17 00:00:00 2001 From: KitsuneSolar Date: Sun, 16 Jul 2023 23:53:17 +0000 Subject: [PATCH] 2023-07-16 23:53:17 --- .gitignore | 1 + CHANGELOG.md | 0 CONTRIBUTING.md | 13 ++++++ LICENSE | 2 +- MW_EXT_Emoji.class.php | 81 +++++++++++++++++++++++++++++++++++++ MW_EXT_Emoji.i18n.magic.php | 29 +++++++++++++ MW_EXT_Emoji.php | 16 ++++++++ README.md | 19 ++++++++- composer.json | 47 +++++++++++++++++++++ extension.json | 55 +++++++++++++++++++++++++ i18n/ru.json | 8 ++++ modules/styles/_main.scss | 9 +++++ modules/styles/theme.css | 1 + modules/styles/theme.scss | 1 + 14 files changed, 280 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 MW_EXT_Emoji.class.php create mode 100644 MW_EXT_Emoji.i18n.magic.php create mode 100644 MW_EXT_Emoji.php create mode 100644 composer.json create mode 100644 extension.json create mode 100644 i18n/ru.json create mode 100644 modules/styles/_main.scss create mode 100644 modules/styles/theme.css create mode 100644 modules/styles/theme.scss diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e69de29 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..969906b --- /dev/null +++ b/CONTRIBUTING.md @@ -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) diff --git a/LICENSE b/LICENSE index 8dbae8f..62a7665 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2023 Package Store +Copyright (c) 2023 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 diff --git a/MW_EXT_Emoji.class.php b/MW_EXT_Emoji.class.php new file mode 100644 index 0000000..d8134bb --- /dev/null +++ b/MW_EXT_Emoji.class.php @@ -0,0 +1,81 @@ +setFunctionHook('emoji', [__CLASS__, 'onRenderTag']); + } + + /** + * Render tag function. + * + * @param Parser $parser + * @param string $id + * @param string $size + * + * @return string + * @throws ConfigException + */ + public static function onRenderTag(Parser $parser, string $id = '', string $size = ''): string + { + // Argument: id. + $getID = MW_EXT_Kernel::outClear($id ?? '' ?: ''); + $outID = self::getEmoji($getID); + + // Argument: size. + $getSize = MW_EXT_Kernel::outClear($size ?? '' ?: ''); + $outSize = empty($getSize) ? '' : ' width: ' . $getSize . 'em; height: ' . $getSize . 'em;'; + + // Out HTML. + $outHTML = ''; + + // Out parser. + return $parser->insertStripItem($outHTML, $parser->getStripState()); + } + + /** + * Load resource function. + * + * @param OutputPage $out + * @param Skin $skin + * + * @return void + */ + public static function onBeforePageDisplay(OutputPage $out, Skin $skin): void + { + $out->addModuleStyles(['ext.mw.emoji.styles']); + } +} diff --git a/MW_EXT_Emoji.i18n.magic.php b/MW_EXT_Emoji.i18n.magic.php new file mode 100644 index 0000000..61ccd24 --- /dev/null +++ b/MW_EXT_Emoji.i18n.magic.php @@ -0,0 +1,29 @@ + + */ +$magicWords = []; + +/** + * English. + * + * @author iHub TO + */ +$magicWords['en'] = [ + 'emoji' => [0, 'emoji'], +]; + +/** + * Russian. + * + * @author iHub TO + */ +$magicWords['ru'] = [ + 'emoji' => [0, 'emoji'], +]; diff --git a/MW_EXT_Emoji.php b/MW_EXT_Emoji.php new file mode 100644 index 0000000..59219a0 --- /dev/null +++ b/MW_EXT_Emoji.php @@ -0,0 +1,16 @@ +=8.2", + "pkgstore/mediawiki-ext-kernel": "*" + }, + "autoload": { + "classmap": [ + "MW_EXT_Emoji.class.php" + ] + }, + "config": { + "optimize-autoloader": true, + "prepend-autoloader": false + }, + "extra": { + "installer-name": "MW_EXT_Emoji" + } +} diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..e3b69cf --- /dev/null +++ b/extension.json @@ -0,0 +1,55 @@ +{ + "name": "MW_EXT_Emoji", + "version": "1.0.0", + "author": [ + "[https://ihub.to/ iHub TO]", + "[https://kitsune.solar/ Kitsune Solar]", + "..." + ], + "url": "https://ihub.to/", + "descriptionmsg": "mw-emoji-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_Emoji": "MW_EXT_Emoji.class.php" + }, + "Hooks": { + "ParserFirstCallInit": [ + "MediaWiki\\Extension\\PkgStore\\MW_EXT_Emoji::onParserFirstCallInit" + ], + "BeforePageDisplay": [ + "MediaWiki\\Extension\\PkgStore\\MW_EXT_Emoji::onBeforePageDisplay" + ] + }, + "ExtensionMessagesFiles": { + "MW_EXT_EmojiMagic": "MW_EXT_Emoji.i18n.magic.php" + }, + "MessagesDirs": { + "MW_EXT_Emoji": [ + "i18n" + ] + }, + "ResourceModules": { + "ext.mw.emoji.styles": { + "styles": [ + "styles/theme.css" + ], + "position": "top", + "targets": [ + "desktop", + "mobile" + ] + } + }, + "ResourceFileModulePaths": { + "localBasePath": "modules", + "remoteExtPath": "MW_EXT_Emoji/modules" + }, + "manifest_version": 2 +} diff --git a/i18n/ru.json b/i18n/ru.json new file mode 100644 index 0000000..60b3c3b --- /dev/null +++ b/i18n/ru.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": [ + "iHub TO" + ] + }, + "mw-emoji-desc": "" +} diff --git a/modules/styles/_main.scss b/modules/styles/_main.scss new file mode 100644 index 0000000..6491f0a --- /dev/null +++ b/modules/styles/_main.scss @@ -0,0 +1,9 @@ +.mw-emoji { + $size: 1.4em; + display: inline-block; + background-size: contain; + background: transparent no-repeat 50%; + vertical-align: middle; + width: $size; + height: $size; +} diff --git a/modules/styles/theme.css b/modules/styles/theme.css new file mode 100644 index 0000000..dd6edab --- /dev/null +++ b/modules/styles/theme.css @@ -0,0 +1 @@ +.mw-emoji{display:inline-block;background-size:contain;background:transparent no-repeat 50%;vertical-align:middle;width:1.4em;height:1.4em} diff --git a/modules/styles/theme.scss b/modules/styles/theme.scss new file mode 100644 index 0000000..2059d52 --- /dev/null +++ b/modules/styles/theme.scss @@ -0,0 +1 @@ +@import 'main.scss'; \ No newline at end of file