2023-07-16 23:53:17
This commit is contained in:
parent
e79a37c494
commit
013bef8863
|
@ -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,81 @@
|
|||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\PkgStore;
|
||||
|
||||
use ConfigException;
|
||||
use MWException;
|
||||
use OutputPage, Parser, Skin;
|
||||
|
||||
/**
|
||||
* Class MW_EXT_Emoji
|
||||
*/
|
||||
class MW_EXT_Emoji
|
||||
{
|
||||
/**
|
||||
* Get emoji file.
|
||||
*
|
||||
* @param $id
|
||||
*
|
||||
* @return string
|
||||
* @throws ConfigException
|
||||
*/
|
||||
private static function getEmoji($id): string
|
||||
{
|
||||
$path = MW_EXT_Kernel::getConfig('ScriptPath') . '/vendor/metastore/lib-emoji/resources/assets/images/';
|
||||
$id = MW_EXT_Kernel::outNormalize($id);
|
||||
return $path . $id . '.svg';
|
||||
}
|
||||
|
||||
/**
|
||||
* Register tag function.
|
||||
*
|
||||
* @param Parser $parser
|
||||
*
|
||||
* @return void
|
||||
* @throws MWException
|
||||
*/
|
||||
public static function onParserFirstCallInit(Parser $parser): void
|
||||
{
|
||||
$parser->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 = '<span style="background-image: url(' . $outID . ');' . $outSize . '" class="mw-emoji navigation-not-searchable"></span>';
|
||||
|
||||
// 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']);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Internationalization file for extension MW_EXT_Emoji (magic words).
|
||||
*
|
||||
* @file
|
||||
* @ingroup Extensions
|
||||
* @license MIT
|
||||
* @author iHub TO <https://ihub.to>
|
||||
*/
|
||||
$magicWords = [];
|
||||
|
||||
/**
|
||||
* English.
|
||||
*
|
||||
* @author iHub TO <https://ihub.to>
|
||||
*/
|
||||
$magicWords['en'] = [
|
||||
'emoji' => [0, 'emoji'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Russian.
|
||||
*
|
||||
* @author iHub TO <https://ihub.to>
|
||||
*/
|
||||
$magicWords['ru'] = [
|
||||
'emoji' => [0, 'emoji'],
|
||||
];
|
|
@ -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_Emoji');
|
||||
// Keep i18n globals so mergeMessageFileList.php doesn't break.
|
||||
$wgExtensionMessagesFiles['MW_EXT_Emoji'] = __DIR__ . '/i18n';
|
||||
|
||||
return;
|
||||
} else {
|
||||
die('This version of the MW_EXT_Emoji extension requires MediaWiki 1.31+');
|
||||
}
|
19
README.md
19
README.md
|
@ -1 +1,18 @@
|
|||
# mediawiki-ext-emoji
|
||||
# Information
|
||||
|
||||
Добавление **emoji** в статью.
|
||||
|
||||
## Install
|
||||
|
||||
1. Загрузите папки и файлы в директорию `extensions/MW_EXT_Emoji`.
|
||||
2. В самый низ файла `LocalSettings.php` добавьте строку:
|
||||
|
||||
```php
|
||||
wfLoadExtension( 'MW_EXT_Emoji' );
|
||||
```
|
||||
|
||||
## Syntax
|
||||
|
||||
```html
|
||||
{{#emoji: [ID]|[SIZE]}}
|
||||
```
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
{
|
||||
"name": "pkgstore/mediawiki-ext-emoji",
|
||||
"type": "mediawiki-extension",
|
||||
"description": "MediaWiki emoji extension.",
|
||||
"license": "MIT",
|
||||
"homepage": "https://ihub.to/",
|
||||
"keywords": [
|
||||
"mediawiki",
|
||||
"emoji"
|
||||
],
|
||||
"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-emoji/issues",
|
||||
"source": "https://github.com/pkgstore/mediawiki-ext-emoji"
|
||||
},
|
||||
"require": {
|
||||
"composer/installers": "^1.0.1",
|
||||
"metastore/lib-emoji": "*",
|
||||
"php": ">=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"
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"@metadata": {
|
||||
"authors": [
|
||||
"iHub TO"
|
||||
]
|
||||
},
|
||||
"mw-emoji-desc": ""
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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}
|
|
@ -0,0 +1 @@
|
|||
@import 'main.scss';
|
Loading…
Reference in New Issue