Filters Redesign (#658)

* Add XCheckboxFilter

* Fix madara typo

* Change the branch name in config

* Add typing for madara popoularnovels filters

* Add preview and refactor PluginWrapper

* Add preview HTML sanitize and other improv.

* Web improvements + sanitizeHTML

* Add dark mode

* Add git run less to compile less

* Add less.js to remove the need for compiling less
This commit is contained in:
Marcin Majewski
2023-12-27 15:49:46 +01:00
committed by GitHub
parent 9cdace3460
commit d7a76063bf
170 changed files with 94169 additions and 80752 deletions
+30 -19
View File
@@ -7,32 +7,43 @@ type GeneratedScript = {
pluginScript: string;
};
export type ScrpitGeneratorFunction = () => GeneratedScript[];
export type ScrpitGeneratorFunction = (name: string) => GeneratedScript[];
const isScriptGenerator = (s: unknown): s is ScrpitGeneratorFunction => {
return !!s && typeof s === "function";
};
const generate = async (name: string): Promise<boolean> => {
const generateAll: ScrpitGeneratorFunction | unknown =
require(`./${name}/generator`).generateAll;
if (!isScriptGenerator(generateAll)) return false;
const sources = generateAll();
for (let source of sources) {
const { lang, filename, pluginScript } = source;
if(!lang || !filename || !pluginScript){
console.warn(name, ": lang, filename, pluginScript are required!");
continue;
try {
const generateAll: ScrpitGeneratorFunction | unknown =
require(`./${name}/generator`).generateAll;
if (!isScriptGenerator(generateAll)) return false;
const sources = generateAll(name);
for (let source of sources) {
const { lang, filename, pluginScript } = source;
if (!lang || !filename || !pluginScript) {
console.warn(
name,
": lang, filename, pluginScript are required!"
);
continue;
}
const pluginsDir = path.join(
path.dirname(path.dirname(__dirname)),
"plugins"
);
const filePath = path.join(
pluginsDir,
lang.toLowerCase(),
filename.replace(/[\s-\.]+/g, "") + `[${name}].ts`
);
fs.writeFileSync(filePath, pluginScript, { encoding: "utf-8" });
}
const pluginsDir = path.join(
path.dirname(path.dirname(__dirname)),
"plugins"
);
const filePath = path.join(pluginsDir, lang.toLowerCase(), filename.replace(/[\s-\.]+/g, "") + `[${name}].ts`);
fs.writeFileSync(filePath, pluginScript, { encoding: "utf-8" });
return true;
} catch (e) {
console.log(`${name} is broken! ${e}`);
return false;
}
return true;
};
const run = async () => {
@@ -44,7 +55,7 @@ const run = async () => {
for (let name of sources) {
const success = await generate(name);
if (success) console.log(name + " OK");
if (success) console.log(`[${name}] OK`);
}
};