增加VisualEditor保存窗口的选择分类按钮

master
落雨楓 2 years ago
parent 7b57ec5134
commit bcb7f0b063

@ -41,7 +41,7 @@ class Isekai {
$outputPage->addModuleStyles('ext.isekai.styles');
$outputPage->addModules('ext.isekai');
$outputPage->addModules('ext.fontawesome');
//$outputPage->addModules('ext.fontawesome');
//$outputPage->addModules('ext.treeview');
// 加载动画,三秒内未加载完成则强制显示
@ -84,6 +84,10 @@ var _hmt = _hmt || [];
HTML
);
if ($outputPage->getUser() && $outputPage->getUser()->isRegistered()) {
$outputPage->addBodyClasses(['logged-in']);
}
self::showAds($outputPage);
}
@ -114,6 +118,7 @@ HTML
$outputPage->addHTML(
<<<HTML
<script type="text/javascript">
window.addEventListener('load', function () {
if (window.innerWidth >= 1100) {
var adElem = document.createElement('div');
adElem.className = 'googlead-container googlead-container-sidebar';
@ -124,6 +129,7 @@ HTML
(adsbygoogle = window.adsbygoogle || []).push({});
}
}
})
</script>
HTML
);
@ -176,44 +182,76 @@ HTML
if (!$outputPage->isArticle()) return;
$title = $outputPage->getTitle();
if ($title && $title->isSubpage()) {
//更改显示的标题
$titleText = $title->getPrefixedText();
$baseTitleText = basename($titleText);
$htmlTitle = $outputPage->getHTMLTitle();
if (strpos($htmlTitle, $baseTitleText) === 0) {
// 将HTML标题替换为完整标题
$outputPage->setHTMLTitle($titleText . substr($htmlTitle, strlen($baseTitleText)));
}
if ($title) {
if ($title->isSubpage()) {
//更改显示的标题
$titleText = $title->getPrefixedText();
$currentDisplayTitle = $outputPage->getDisplayTitle();
$htmlTitle = $outputPage->getHTMLTitle();
if (strpos($htmlTitle, $currentDisplayTitle) === 0) {
// 将HTML标题替换为完整标题
$htmlTitleText = $currentDisplayTitle . ' (' . dirname($titleText) . ')';
$outputPage->setHTMLTitle($htmlTitleText . substr($htmlTitle, strlen($currentDisplayTitle)));
$outputPage->addMeta('title', $htmlTitleText);
}
//面包屑
$titlePathList = explode('/', $titleText);
$titlePathLen = count($titlePathList);
$breadcrumbsHtml = [
Html::openElement('ol', ['class' => 'breadcrumb']),
];
$linkRender = MediaWikiServices::getInstance()->getLinkRenderer();
foreach ($titlePathList as $key => $titleName) {
if ($key === $titlePathLen - 1) {
$breadcrumbsHtml[] = Html::element('li', ['class' => 'active'], $titleName);
} else {
$titleSubPath = implode('/', array_slice($titlePathList, 0, $key + 1));
$currentTitle = Title::newFromText($titleSubPath);
if ($currentTitle) {
$link = $linkRender->makeLink(Title::newFromText($titleSubPath), $titleName);
//面包屑
$titlePathList = explode('/', $titleText);
$titlePathLen = count($titlePathList);
$breadcrumbsHtml = [
Html::openElement('ol', ['class' => 'breadcrumb']),
];
$linkRender = MediaWikiServices::getInstance()->getLinkRenderer();
foreach ($titlePathList as $key => $titleName) {
if ($key === $titlePathLen - 1) {
$breadcrumbsHtml[] = Html::element('li', ['class' => 'active'], $titleName);
} else {
$link = $titleSubPath;
$titleSubPath = implode('/', array_slice($titlePathList, 0, $key + 1));
$currentTitle = Title::newFromText($titleSubPath);
if ($currentTitle) {
$link = $linkRender->makeLink(Title::newFromText($titleSubPath), $titleName);
} else {
$link = $titleSubPath;
}
if ($key === 0) {
$breadcrumbsHtml[] = Html::openElement('li', ['class' => 'root']) . $link . Html::closeElement('li');
} else {
$breadcrumbsHtml[] = Html::openElement('li') . $link . Html::closeElement('li');
}
$breadcrumbsHtml[] = Html::openElement('span', ['class' => 'breadcrumb-divider']) . '/' . Html::closeElement('span');
}
$breadcrumbsHtml[] = Html::openElement('li') . $link . Html::closeElement('li');
}
}
$breadcrumbsHtml[] = Html::closeElement('ol');
$html = implode($breadcrumbsHtml);
$breadcrumbsHtml[] = Html::closeElement('ol');
$html = implode($breadcrumbsHtml);
// 阻止出现subtitle空行
$subtitle = $outputPage->getSubtitle();
$outputPage->setSubtitle($subtitle . $html);
// 阻止出现subtitle空行
$subtitle = $outputPage->getSubtitle();
$outputPage->setSubtitle($subtitle . $html);
} else {
$currentDisplayTitle = $outputPage->getDisplayTitle();
if ($currentDisplayTitle) {
$currentDisplayTitle = strip_tags($currentDisplayTitle);
$outputPage->addMeta('title', $currentDisplayTitle);
if ($currentDisplayTitle !== $title->getPrefixedText()) {
// 输出原标题
$breadcrumbsHtml = [
Html::openElement('ol', ['class' => 'breadcrumb']),
Html::element('li', ['class' => 'root active'], $title->getPrefixedText()),
Html::closeElement('ol'),
];
$html = implode($breadcrumbsHtml);
$subtitle = $outputPage->getSubtitle();
$outputPage->setSubtitle($subtitle . $html);
}
} else {
$outputPage->addMeta('title', $title->getPrefixedText());
}
}
}
}
@ -224,7 +262,7 @@ HTML
//更改显示的标题
$titleText = $title->getPrefixedText();
if ($titleText) {
$parser->getOutput()->setTitleText('<span class="mw-page-title-main">' . basename($titleText) . '</span>');
$parser->getOutput()->setTitleText(basename($titleText));
}
}
}
@ -296,4 +334,31 @@ HTML
'section' => 'misc/isekai-ads',
];
}
public static function onCirrusSearchAnalysisConfig(array &$config, $builder) {
if (isset($config['filter']['smartcn_stop'])) { // 处理中文Analysis Config
}
}
public static function onMugenAppGetAvatar(&$avatarUrl, $size, $user) {
if (!$user) {
$avatarUrl = "https://account.isekai.cn/realms/isekai/avatar/default";
return;
}
$userName = $user->getName();
$avatarBase = 'https://account.isekai.cn/realms/isekai/avatar/by-username/' . $userName;
if ($size <= 64) {
$avatarUrl = "$avatarBase?size=md";
} else if ($size <= 128) {
$avatarUrl = "$avatarBase?size=lg";
} else if ($size <= 256) {
$avatarUrl = "$avatarBase?size=xl";
} else {
$avatarUrl = "$avatarBase?size=xxl";
}
}
}

@ -45,6 +45,12 @@
],
"EditPage::attemptSave": [
"Isekai\\Isekai::onAttemptSave"
],
"CirrusSearchAnalysisConfig": [
"Isekai\\Isekai::onCirrusSearchAnalysisConfig"
],
"MugenAppGetAvatar": [
"Isekai\\Isekai::onMugenAppGetAvatar"
]
},
"ResourceModules": {
@ -52,7 +58,8 @@
"scripts": ["ext.isekai.js"],
"dependencies": [
"oojs-ui-core",
"oojs-ui-windows"
"oojs-ui-windows",
"mediawiki.user"
],
"targets": [
"desktop",
@ -72,7 +79,8 @@
"isekai-ads-prompt-title",
"isekai-ads-prompt-content",
"isekai-ads-prompt-btn-cancel",
"nav-login-createaccount"
"nav-login-createaccount",
"visualeditor-savedialog-label-set-categories"
]
},
"ext.isekai.styles": {

@ -30,5 +30,7 @@
"isekai-ads-prompt-title": "Please allow ads on Fanta World Wiki",
"isekai-ads-prompt-content": "<p>Looks like you're using an ad blocker.</p><p>Fanta World Wiki rely on advertising to help fund our site.</p><p>If you want to support Fanta World Wiki, you can turn off Adblock, Adblock Pro, and other plugins on this site.</p>",
"isekai-ads-prompt-btn-cancel": "No longer display"
"isekai-ads-prompt-btn-cancel": "No longer display",
"visualeditor-savedialog-label-set-categories": "Select categories"
}

@ -30,5 +30,7 @@
"isekai-ads-prompt-title": "您似乎屏蔽了广告",
"isekai-ads-prompt-content": "<p>目前,页面广告是异世界百科的唯一收入来源。</p><p>如果您想要支持异世界百科可以在此站点上关闭Adblock、Adblock Pro等插件。</p><p>如果想要移除广告空位,可以在用户-参数设置中关闭广告。</p>",
"isekai-ads-prompt-btn-cancel": "不再显示"
"isekai-ads-prompt-btn-cancel": "不再显示",
"visualeditor-savedialog-label-set-categories": "设置分类"
}

@ -30,5 +30,7 @@
"isekai-ads-prompt-title": "您似乎屏蔽了廣告",
"isekai-ads-prompt-content": "<p>目前,頁面廣告是異世界百科的唯一收入來源。</p><p>如果您想要支持異世界百科可以在此網站上關閉Adblock、Adblock Pro等擴展程式。</p><p>如果想要移除廣告空位,可以在用戶-參數設置中關閉廣告。</p>",
"isekai-ads-prompt-btn-cancel": "不再顯示"
"isekai-ads-prompt-btn-cancel": "不再顯示",
"visualeditor-savedialog-label-set-categories": "設置分類"
}

@ -140,6 +140,17 @@ html.content-loaded body.skin-timeless {
color: #fff;
}
@media (prefers-color-scheme: dark) {
body.auto-color-scheme .black-space {
background-color: #fff;
color: #fff;
&:hover {
color: #222;
}
}
}
#toc > ul {
overflow-y: auto;
max-height: 50vh;
@ -188,6 +199,7 @@ html.content-loaded body.skin-timeless {
background-color: #f5f5f5;
border-radius: 4px;
margin-block-start: 0;
margin-left: 0;
font-size: 14px;
> li {
@ -198,10 +210,15 @@ html.content-loaded body.skin-timeless {
}
}
> li+li:before {
.breadcrumb-divider {
padding: 0 5px;
color: #ccc;
content: "/\00a0";
}
> li.root:before {
padding: 0 5px 0 0;
color: #ccc;
content: "/";
}
a {
@ -262,3 +279,9 @@ html.content-loaded body.skin-timeless {
display: none;
}
}
// 对登录用户隐藏标题
@media (max-width: 576px) {
.logged-in #p-logo-text {
display: none;
}
}

@ -0,0 +1,7 @@
<?php
namespace Isekai\Specials;
class SpecialGetPageModules {
}
Loading…
Cancel
Save