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_List.class.php b/MW_EXT_List.class.php new file mode 100644 index 0000000..042825e --- /dev/null +++ b/MW_EXT_List.class.php @@ -0,0 +1,137 @@ +setFunctionHook('list', [__CLASS__, 'onRenderTag']); + } + + /** + * Render tag function. + * + * @param Parser $parser + * @param string $type + * @param string $style + * + * @return string|null + */ + public static function onRenderTag(Parser $parser, string $type = '', string $style = ''): ?string + { + // Argument: type. + $getType = MW_EXT_Kernel::outClear($type ?? '' ?: ''); + $outType = MW_EXT_Kernel::outNormalize($getType); + + // Check license type, set error category. + if (!self::getList($outType)) { + $parser->addTrackingCategory('mw-list-error-category'); + + return null; + } + + // Argument: style. + $getStyle = MW_EXT_Kernel::outClear($style ?? '' ?: ''); + $outStyle = MW_EXT_Kernel::outNormalize($getStyle); + + // Get data. + $getList = self::getList($outType); + + // Sort data. + asort($getList); + + // Build style class. + switch ($outStyle) { + case 'grid': + $outClass = 'grid'; + break; + case 'list': + $outClass = 'list'; + break; + case 'inline': + $outClass = 'inline'; + break; + default: + $parser->addTrackingCategory('mw-list-error-category'); + + return null; + } + + // Set URL item. + $outItem = ''; + + foreach ($getList as $item) { + $title = empty($item['title']) ? '' : $item['title']; + $icon = empty($item['icon']) ? 'fas fa-globe' : $item['icon']; + $bg_color = empty($item['style']['background-color']) ? '' : 'background-color:' . $item['style']['background-color'] . ';'; + $color = empty($item['style']['color']) ? '' : 'color:' . $item['style']['color'] . ';'; + $href = empty($item['url']) ? '' : $item['url']; + $desc = MW_EXT_Kernel::getMessageText('list', $item['description']); + + if ($outClass === 'grid') { + $outItem .= '
'; + $outItem .= '
'; + $outItem .= '

' . $title . '

' . $desc . '
'; + $outItem .= '
'; + } else if ($outClass === 'list') { + $outItem .= '
  • ' . $title . '
  • '; + } + } + + // Out HTML. + $outHTML = '
    '; + + if ($outClass === 'grid') { + $outHTML .= '
    ' . $outItem . '
    '; + + } else if ($outClass === 'list') { + $outHTML .= '
      ' . $outItem . '
    '; + } + + $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.list.styles']); + } +} diff --git a/MW_EXT_List.i18n.magic.php b/MW_EXT_List.i18n.magic.php new file mode 100644 index 0000000..7168365 --- /dev/null +++ b/MW_EXT_List.i18n.magic.php @@ -0,0 +1,32 @@ + + */ + +$magicWords = []; + +/** + * English. + * + * @author iHub TO + * ------------------------------------------------------------------------------------------------------------------ */ + +$magicWords['en'] = [ + 'list' => [0, 'list'], +]; + +/** + * Russian. + * + * @author iHub TO + * ------------------------------------------------------------------------------------------------------------------ */ + +$magicWords['ru'] = [ + 'list' => [0, 'list'], +]; diff --git a/MW_EXT_List.php b/MW_EXT_List.php new file mode 100644 index 0000000..4ad58da --- /dev/null +++ b/MW_EXT_List.php @@ -0,0 +1,16 @@ +=8.2", + "composer/installers": "^1.0.1", + "pkgstore/mediawiki-ext-kernel": "*" + }, + "autoload": { + "classmap": [ + "MW_EXT_List.class.php" + ] + }, + "config": { + "optimize-autoloader": true, + "prepend-autoloader": false + }, + "extra": { + "installer-name": "MW_EXT_List" + } +} diff --git a/extension.json b/extension.json new file mode 100644 index 0000000..50d20e6 --- /dev/null +++ b/extension.json @@ -0,0 +1,55 @@ +{ + "name": "MW_EXT_List", + "version": "1.0.0", + "author": [ + "[https://ihub.to/ iHub TO]", + "[https://kitsune.solar/ Kitsune Solar]", + "..." + ], + "url": "https://ihub.to/", + "descriptionmsg": "mw-meta-desc", + "license-name": "[https://choosealicense.com/licenses/mit/ MIT]", + "type": "other", + "require": { + "MediaWiki": ">= 1.30.0", + "extensions": { + "MW_EXT_Core": "*" + } + }, + "AutoloadClasses": { + "MediaWiki\\Extension\\PkgStore\\MW_EXT_List": "MW_EXT_List.class.php" + }, + "Hooks": { + "ParserFirstCallInit": [ + "MediaWiki\\Extension\\PkgStore\\MW_EXT_List::onParserFirstCallInit" + ], + "BeforePageDisplay": [ + "MediaWiki\\Extension\\PkgStore\\MW_EXT_List::onBeforePageDisplay" + ] + }, + "ExtensionMessagesFiles": { + "MW_EXT_ListMagic": "MW_EXT_List.i18n.magic.php" + }, + "MessagesDirs": { + "MW_EXT_List": [ + "i18n" + ] + }, + "ResourceModules": { + "ext.mw.list.styles": { + "styles": [ + "styles/theme.css" + ], + "position": "top", + "targets": [ + "desktop", + "mobile" + ] + } + }, + "ResourceFileModulePaths": { + "localBasePath": "modules", + "remoteExtPath": "MW_EXT_List/modules" + }, + "manifest_version": 2 +} diff --git a/i18n/ru.json b/i18n/ru.json new file mode 100644 index 0000000..874625f --- /dev/null +++ b/i18n/ru.json @@ -0,0 +1,20 @@ +{ + "@metadata": { + "authors": [ + "iHub TO" + ] + }, + "mw-list-desc": "Интеграция списка ресурсов METADATA. Специально для проектов [METADATA / FOUNDATION https://metadata.foundation/].", + "mw-list-furs-chat": "Чат сообщества FURRY.", + "mw-list-furs-news": "Новости о FURRY.", + "mw-list-furs-stream": "Стримы сообщества FURRY.", + "mw-list-furs-today": "Журнал сообщества FURRY.", + "mw-list-furs-wiki": "WIKI-система сообщества FURRY.", + "mw-list-radio-wtf": "Свободная интернет-радиостанция.", + "mw-list-metadata-foundation": "Фонд по разработке и поддержке веб-технологий.", + "mw-list-metastore-pro": "Платформа по исследованиям и разработкам METADATA.", + "mw-list-flarum-help": "Поддержка CMS Flarum.", + "mw-list-humhub-help": "Поддержка CMS HumHub.", + "mw-list-ipb-help": "Поддержка CMS IPB.", + "mw-list-xenforo-help": "Поддержка CMS XenForo." +} diff --git a/modules/styles/_main.scss b/modules/styles/_main.scss new file mode 100644 index 0000000..bc1ccf6 --- /dev/null +++ b/modules/styles/_main.scss @@ -0,0 +1,55 @@ +.mw-list { + &-grid { + .mw-list { + &-content { + display: grid; + grid-gap: 1em; + grid-template-columns: repeat(auto-fit, minmax(20em, 1fr)); + + a { + display: block; + + &:hover { + text-decoration: none; + } + + i { + display: block; + color: hsl(0, 0%, 100%); + font-size: 2em; + } + } + + h4 { + font-family: 'Roboto Condensed', sans-serif; + font-size: 1.2em; + margin: 0; + padding: 0; + text-transform: uppercase; + } + + > div { + display: grid; + grid-gap: 1em; + grid-template-columns: min-content 1fr; + + > div { + &:first-child { + a { + background-color: hsl(217, 71%, 53%); + padding: 1em; + border-radius: 50%; + } + } + + &:last-child { + > div { + font-size: .9em; + } + } + } + } + } + } + } +} diff --git a/modules/styles/theme.css b/modules/styles/theme.css new file mode 100644 index 0000000..ac2cf52 --- /dev/null +++ b/modules/styles/theme.css @@ -0,0 +1 @@ +.mw-list-grid .mw-list-content{display:grid;grid-gap:1em;grid-template-columns:repeat(auto-fit, minmax(20em, 1fr))}.mw-list-grid .mw-list-content a{display:block}.mw-list-grid .mw-list-content a:hover{text-decoration:none}.mw-list-grid .mw-list-content a i{display:block;color:#fff;font-size:2em}.mw-list-grid .mw-list-content h4{font-family:'Roboto Condensed', sans-serif;font-size:1.2em;margin:0;padding:0;text-transform:uppercase}.mw-list-grid .mw-list-content>div{display:grid;grid-gap:1em;grid-template-columns:min-content 1fr}.mw-list-grid .mw-list-content>div>div:first-child a{background-color:#3273dc;padding:1em;border-radius:50%}.mw-list-grid .mw-list-content>div>div:last-child>div{font-size:.9em} diff --git a/modules/styles/theme.scss b/modules/styles/theme.scss new file mode 100644 index 0000000..a3db8d3 --- /dev/null +++ b/modules/styles/theme.scss @@ -0,0 +1 @@ +@import 'main.scss'; diff --git a/store/list.json b/store/list.json new file mode 100644 index 0000000..030cf50 --- /dev/null +++ b/store/list.json @@ -0,0 +1,126 @@ +{ + "list": { + "project": [ + { + "title": "FURS.Chat", + "icon": "fas fa-paw", + "style": { + "background-color": "#f00", + "color": "" + }, + "description": "furs-chat", + "url": "https://furs.chat" + }, + { + "title": "FURS.News", + "icon": "fas fa-paw", + "style": { + "background-color": "", + "color": "" + }, + "description": "furs-news", + "url": "https://furs.news" + }, + { + "title": "FURS.Stream", + "icon": "fas fa-paw", + "style": { + "background-color": "", + "color": "" + }, + "description": "furs-stream", + "url": "https://furs.stream" + }, + { + "title": "FURS.Today", + "icon": "fas fa-paw", + "style": { + "background-color": "", + "color": "" + }, + "description": "furs-today", + "url": "https://furs.today" + }, + { + "title": "FURS.Wiki", + "icon": "fas fa-paw", + "style": { + "background-color": "", + "color": "" + }, + "description": "furs-wiki", + "url": "https://furs.wiki" + }, + { + "title": "Radio.WTF", + "icon": "fas fa-broadcast-tower", + "style": { + "background-color": "", + "color": "" + }, + "description": "radio-wtf", + "url": "https://radio.wtf" + }, + { + "title": "METADATA / FOUNDATION", + "icon": "fas fa-globe", + "style": { + "background-color": "", + "color": "" + }, + "description": "metadata-foundation", + "url": "https://metadata.foundation" + }, + { + "title": "METASTORE", + "icon": "fas fa-store", + "style": { + "background-color": "", + "color": "" + }, + "description": "metastore-pro", + "url": "https://metastore.pro" + }, + { + "title": "Flarum.HELP", + "icon": "fas fa-question-circle", + "style": { + "background-color": "", + "color": "" + }, + "description": "flarum-help", + "url": "https://flarum.help" + }, + { + "title": "HumHub.HELP", + "icon": "fas fa-question-circle", + "style": { + "background-color": "", + "color": "" + }, + "description": "humhub-help", + "url": "https://humhub.help" + }, + { + "title": "IPB.HELP", + "icon": "fas fa-question-circle", + "style": { + "background-color": "", + "color": "" + }, + "description": "ipb-help", + "url": "https://ipb.help" + }, + { + "title": "XenForo.HELP", + "icon": "fas fa-question-circle", + "style": { + "background-color": "", + "color": "" + }, + "description": "xenforo-help", + "url": "https://xenforo.help" + } + ] + } +} \ No newline at end of file