-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(mw/config): parser config for MoegirlPedia
close #19
- Loading branch information
1 parent
96c4c83
commit 3aa9c3c
Showing
6 changed files
with
39 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,7 +75,7 @@ export const getMwConfig = async (): Promise<MwConfig> => { | |
const parserConfig: Config = await (await fetch( | ||
`${CDN}/npm/[email protected]/config/moegirl.json`, | ||
)).json(); | ||
mw.config.set('wikilintConfig', parserConfig); | ||
setObject('wikilintConfig', parserConfig); | ||
config = getStaticMwConfig(parserConfig); | ||
} else { | ||
// 以下情形均需要发送API请求 | ||
|
@@ -147,10 +147,11 @@ export const getMwConfig = async (): Promise<MwConfig> => { | |
* @param mwConfig | ||
*/ | ||
export const getParserConfig = (minConfig: Config, mwConfig: MwConfig): Config => { | ||
if (mw.config.exists('wikilintConfig')) { | ||
return mw.config.get('wikilintConfig') as Config; | ||
let config: Config | null = getObject('wikilintConfig'); | ||
if (config) { | ||
return config; | ||
} | ||
const config: Config = { | ||
config = { | ||
...minConfig, | ||
ext: Object.keys(mwConfig.tags), | ||
namespaces: mw.config.get('wgFormattedNamespaces'), | ||
|
@@ -162,6 +163,9 @@ export const getParserConfig = (minConfig: Config, mwConfig: MwConfig): Config = | |
protocol: mwConfig.urlProtocols.replace(/\|\\?\/\\?\//u, ''), | ||
redirection: mwConfig.redirection || minConfig.redirection, | ||
}; | ||
if (location.hostname.endsWith('.moegirl.org.cn')) { | ||
config.html[2].push('img'); | ||
} | ||
[config.parserFunction[0]] = mwConfig.functionSynonyms; | ||
if (mw.loader.getState('ext.CodeMirror') === null) { | ||
for (const [key, val] of Object.entries(mwConfig.functionSynonyms[0])) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"extends": "../tsconfig.json", | ||
"include": [ | ||
"*.ts" | ||
], | ||
"compilerOptions": { | ||
"resolveJsonModule": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters