From 04470231bf92c3b9698ba1788b4fe1ec3b15e665 Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Mon, 20 Nov 2023 16:48:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=9A=E5=88=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=B1=8F=E8=94=BD=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extension.json | 3 +++ includes/Isekai.php | 61 ++++++++++++++++++++++++++++----------------- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/extension.json b/extension.json index 52aec8b..2b6bef1 100644 --- a/extension.json +++ b/extension.json @@ -184,6 +184,9 @@ }, "IsekaiActivateEditorRequiredWords": { "value": 300 + }, + "IsekaiMiscIsIsekaiWiki": { + "value": true } }, "manifest_version": 2 diff --git a/includes/Isekai.php b/includes/Isekai.php index 3594d8e..4fddc22 100644 --- a/includes/Isekai.php +++ b/includes/Isekai.php @@ -29,16 +29,22 @@ class Isekai { } public static function setHeader(OutputPage $outputPage) { - $outputPage->addHeadItem('dns-prefetch-main', Html::element('link', ['rel' => 'dns-prefetch', 'href' => '//www.isekai.cn'])); - $outputPage->addHeadItem('sitemap-link', Html::element('link', [ - 'rel' => 'sitemap', 'type' => 'application/xml', - 'title' => 'Sitemap', 'href' => '/sitemap/sitemap-index-wiki.xml', - ])); + $config = MediaWikiServices::getInstance()->getMainConfig(); + $isIsekaiWiki = $config->get('IsekaiMiscIsIsekaiWiki'); + + if ($isIsekaiWiki) { + $outputPage->addHeadItem('dns-prefetch-main', Html::element('link', ['rel' => 'dns-prefetch', 'href' => '//www.isekai.cn'])); + $outputPage->addMeta('author', '异世界百科'); + + $outputPage->addHeadItem('sitemap-link', Html::element('link', [ + 'rel' => 'sitemap', 'type' => 'application/xml', + 'title' => 'Sitemap', 'href' => '/sitemap/sitemap-index-wiki.xml', + ])); + } // $outputPage->addHeadItem('dns-prefetch-static', \Html::element('link', ['rel' => 'dns-prefetch', 'href' => '//static-www.isekai.cn'])); $outputPage->addMeta('robots', 'all'); $outputPage->addMeta('revisit-after', '1 days'); - $outputPage->addMeta('author', '异世界百科'); $outputPage->addModuleStyles(['ext.isekai.styles']); $outputPage->addModules(['ext.isekai', 'ext.isekai.function-btn']); @@ -68,10 +74,11 @@ HTML ); } - // 百度统计 - $outputPage->addHeadItem( - 'baiduhm', - <<addHeadItem( + 'baiduhm', + << var _hmt = _hmt || []; (function() { @@ -82,13 +89,16 @@ var _hmt = _hmt || []; })(); HTML - ); + ); + } if ($outputPage->getUser() && $outputPage->getUser()->isRegistered()) { $outputPage->addBodyClasses(['logged-in']); } - self::showAds($outputPage); + if ($isIsekaiWiki) { + self::showAds($outputPage); + } } public static function showAds(OutputPage $outputPage) { @@ -322,17 +332,22 @@ HTML } public static function onGetPreferences(User $user, array &$preferences){ - $preferences['isekai-show-ads-bottom'] = [ - 'type' => 'toggle', - 'label-message' => 'isekai-show-ads-bottom', - 'section' => 'misc/isekai-ads', - ]; - - $preferences['isekai-show-ads-sidebar'] = [ - 'type' => 'toggle', - 'label-message' => 'isekai-show-ads-sidebar', - 'section' => 'misc/isekai-ads', - ]; + $config = MediaWikiServices::getInstance()->getMainConfig(); + $isIsekaiWiki = $config->get('IsekaiMiscIsIsekaiWiki'); + + if ($isIsekaiWiki) { + $preferences['isekai-show-ads-bottom'] = [ + 'type' => 'toggle', + 'label-message' => 'isekai-show-ads-bottom', + 'section' => 'misc/isekai-ads', + ]; + + $preferences['isekai-show-ads-sidebar'] = [ + 'type' => 'toggle', + 'label-message' => 'isekai-show-ads-sidebar', + 'section' => 'misc/isekai-ads', + ]; + } } public static function onCirrusSearchAnalysisConfig(array &$config, $builder) {