增加定制功能屏蔽开关

master
落雨楓 1 year ago
parent 1643f1bfc1
commit 04470231bf

@ -184,6 +184,9 @@
}, },
"IsekaiActivateEditorRequiredWords": { "IsekaiActivateEditorRequiredWords": {
"value": 300 "value": 300
},
"IsekaiMiscIsIsekaiWiki": {
"value": true
} }
}, },
"manifest_version": 2 "manifest_version": 2

@ -29,16 +29,22 @@ class Isekai {
} }
public static function setHeader(OutputPage $outputPage) { public static function setHeader(OutputPage $outputPage) {
$outputPage->addHeadItem('dns-prefetch-main', Html::element('link', ['rel' => 'dns-prefetch', 'href' => '//www.isekai.cn'])); $config = MediaWikiServices::getInstance()->getMainConfig();
$outputPage->addHeadItem('sitemap-link', Html::element('link', [ $isIsekaiWiki = $config->get('IsekaiMiscIsIsekaiWiki');
'rel' => 'sitemap', 'type' => 'application/xml',
'title' => 'Sitemap', 'href' => '/sitemap/sitemap-index-wiki.xml', 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->addHeadItem('dns-prefetch-static', \Html::element('link', ['rel' => 'dns-prefetch', 'href' => '//static-www.isekai.cn']));
$outputPage->addMeta('robots', 'all'); $outputPage->addMeta('robots', 'all');
$outputPage->addMeta('revisit-after', '1 days'); $outputPage->addMeta('revisit-after', '1 days');
$outputPage->addMeta('author', '异世界百科');
$outputPage->addModuleStyles(['ext.isekai.styles']); $outputPage->addModuleStyles(['ext.isekai.styles']);
$outputPage->addModules(['ext.isekai', 'ext.isekai.function-btn']); $outputPage->addModules(['ext.isekai', 'ext.isekai.function-btn']);
@ -68,10 +74,11 @@ HTML
); );
} }
// 百度统计 if ($isIsekaiWiki) {
$outputPage->addHeadItem( // 百度统计
'baiduhm', $outputPage->addHeadItem(
<<<HTML 'baiduhm',
<<<HTML
<script type="text/javascript"> <script type="text/javascript">
var _hmt = _hmt || []; var _hmt = _hmt || [];
(function() { (function() {
@ -82,13 +89,16 @@ var _hmt = _hmt || [];
})(); })();
</script> </script>
HTML HTML
); );
}
if ($outputPage->getUser() && $outputPage->getUser()->isRegistered()) { if ($outputPage->getUser() && $outputPage->getUser()->isRegistered()) {
$outputPage->addBodyClasses(['logged-in']); $outputPage->addBodyClasses(['logged-in']);
} }
self::showAds($outputPage); if ($isIsekaiWiki) {
self::showAds($outputPage);
}
} }
public static function showAds(OutputPage $outputPage) { public static function showAds(OutputPage $outputPage) {
@ -322,17 +332,22 @@ HTML
} }
public static function onGetPreferences(User $user, array &$preferences){ public static function onGetPreferences(User $user, array &$preferences){
$preferences['isekai-show-ads-bottom'] = [ $config = MediaWikiServices::getInstance()->getMainConfig();
'type' => 'toggle', $isIsekaiWiki = $config->get('IsekaiMiscIsIsekaiWiki');
'label-message' => 'isekai-show-ads-bottom',
'section' => 'misc/isekai-ads', if ($isIsekaiWiki) {
]; $preferences['isekai-show-ads-bottom'] = [
'type' => 'toggle',
$preferences['isekai-show-ads-sidebar'] = [ 'label-message' => 'isekai-show-ads-bottom',
'type' => 'toggle', 'section' => 'misc/isekai-ads',
'label-message' => 'isekai-show-ads-sidebar', ];
'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) { public static function onCirrusSearchAnalysisConfig(array &$config, $builder) {

Loading…
Cancel
Save