Skip to content

Commit

Permalink
♻️ Refactoring (PreMiD#5059)
Browse files Browse the repository at this point in the history
Signed-off-by: SeMiD <contact@premid.app>

Co-authored-by: SeMiD <contact@premid.app>
  • Loading branch information
SeMiD and SeMiD authored Dec 19, 2021
1 parent 82a2d7d commit 11c709a
Show file tree
Hide file tree
Showing 27 changed files with 325 additions and 278 deletions.
24 changes: 17 additions & 7 deletions util/tools/auto/schemaValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const latestMetadataSchema = async (): Promise<string[]> => {
)
.filter((c) => c.name.endsWith(".json"))
.map((c) => c.name.match(/\d.\d/g)[0]);
return [`https://schemas.premid.app/metadata/${versions.at(-1)}`, versions.at(-1)];
return [
`https://schemas.premid.app/metadata/${versions.at(-1)}`,
versions.at(-1)
];
},
stats = {
validated: 0,
Expand Down Expand Up @@ -63,7 +66,9 @@ const latestMetadataSchema = async (): Promise<string[]> => {
folder = metaFile.split("/")[2];

if (!meta) {
failedToValidate(folder, [`::error file=${metaFile},title=Invalid JSON::Unable to parse the JSON file`]);
failedToValidate(folder, [
`::error file=${metaFile},title=Invalid JSON::Unable to parse the JSON file`
]);
continue;
}

Expand Down Expand Up @@ -135,9 +140,10 @@ const latestMetadataSchema = async (): Promise<string[]> => {

for (const invalidLang of invalidLangs) {
errors.push(
`::error file=${metaFile},line=${
getLine("description", invalidLang)
},title=instance.description.${invalidLang}::"${invalidLang}" is not a valid language or is a unsupported language`
`::error file=${metaFile},line=${getLine(
"description",
invalidLang
)},title=instance.description.${invalidLang}::"${invalidLang}" is not a valid language or is a unsupported language`
);
}

Expand All @@ -157,7 +163,8 @@ const latestMetadataSchema = async (): Promise<string[]> => {
case "Literal":
return node.loc.start.line;
case "Object":
return node.children.find((c) => c.key.value === value).loc.start.line;
return node.children.find((c) => c.key.value === value).loc.start
.line;
case "Array": {
if (typeof value === "number")
return node.children[value].loc.start.line;
Expand All @@ -173,7 +180,10 @@ const latestMetadataSchema = async (): Promise<string[]> => {
}
}
}
} else return AST.children.find((c) => c.key.value === line)?.loc?.start?.line ?? 0;
} else
return (
AST.children.find((c) => c.key.value === line)?.loc?.start?.line ?? 0
);
}
}

Expand Down
8 changes: 5 additions & 3 deletions websites/#/Фугапедия/dist/metadata.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{
"$schema": "https://schemas.premid.app/metadata/1.5",
"service": "Фугапедия",
"altnames": ["Fugapedia"],
"altnames": [
"Fugapedia"
],
"author": {
"name": "Syjalo",
"id": "406028548034396160"
},
"category": "other",
"logo": "https://i.imgur.com/L6kpaCb.jpg",
"thumbnail": "https://i.imgur.com/ZRXkQlr.jpg",
"version": "1.1.0",
"version": "1.1.1",
"color": "#ffffff",
"url": [
"fugapedia.xyz",
Expand Down Expand Up @@ -47,4 +49,4 @@
"value": true
}
]
}
}
42 changes: 27 additions & 15 deletions websites/#/Фугапедия/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ const presence = new Presence({
browsingTimestamp = Math.floor(Date.now() / 1000);

presence.on("UpdateData", async () => {
const [
privacyMode,
showTime,
showButtons
] = await Promise.all([
const [privacyMode, showTime, showButtons] = await Promise.all([
presence.getSetting("privacyMode"),
presence.getSetting("showTime"),
presence.getSetting("showButtons")
Expand All @@ -24,7 +20,9 @@ presence.on("UpdateData", async () => {
presenceData.details = "Читает статью";
if (!privacyMode) {
// An article title
presenceData.state = document.querySelector("p.text-4xl.font-bold.font-3").textContent;
presenceData.state = document.querySelector(
"p.text-4xl.font-bold.font-3"
).textContent;
if (showButtons) {
presenceData.buttons = [
{
Expand All @@ -38,7 +36,9 @@ presence.on("UpdateData", async () => {
presenceData.details = "Смотрит правку";
if (!privacyMode) {
// An edit title
presenceData.state = document.querySelector("p.text-4xl.font-bold.font-3").textContent;
presenceData.state = document.querySelector(
"p.text-4xl.font-bold.font-3"
).textContent;
if (showButtons) {
presenceData.buttons = [
{
Expand All @@ -52,7 +52,9 @@ presence.on("UpdateData", async () => {
presenceData.details = "Смотрит категорию";
if (!privacyMode) {
// A category name
presenceData.state = document.querySelector("p.text-4xl.font-bold.font-3").textContent;
presenceData.state = document.querySelector(
"p.text-4xl.font-bold.font-3"
).textContent;
if (showButtons) {
presenceData.buttons = [
{
Expand Down Expand Up @@ -85,7 +87,9 @@ presence.on("UpdateData", async () => {
presenceData.details = "В портале";
if (!privacyMode) {
// A portal name
presenceData.state = document.querySelector("p.text-4xl.font-semibold.text-white").textContent;
presenceData.state = document.querySelector(
"p.text-4xl.font-semibold.text-white"
).textContent;
if (showButtons) {
presenceData.buttons = [
{
Expand All @@ -100,7 +104,9 @@ presence.on("UpdateData", async () => {
presenceData.details = "Читает книгу";
if (!privacyMode) {
// A book name
presenceData.state = document.querySelector("p.text-4xl.font-bold.font-3").textContent;
presenceData.state = document.querySelector(
"p.text-4xl.font-bold.font-3"
).textContent;
if (showButtons) {
presenceData.buttons = [
{
Expand All @@ -116,10 +122,13 @@ presence.on("UpdateData", async () => {
if (!privacyMode) {
presenceData.state = `${
// A user nickname
document.querySelector("p.text-2xl.text-black.font-medium.ml-4.place-self-center").firstChild.textContent
document.querySelector(
"p.text-2xl.text-black.font-medium.ml-4.place-self-center"
).firstChild.textContent
} (${
// A user name
document.querySelector("p.text-lg.text-gray-600.ml-4.place-self-center").textContent
document.querySelector("p.text-lg.text-gray-600.ml-4.place-self-center")
.textContent
})`;
if (showButtons) {
presenceData.buttons = [
Expand All @@ -140,11 +149,14 @@ presence.on("UpdateData", async () => {
presenceData.details = "Читает условия";
presenceData.state = "размещения рекламы";
} else if (path === "/account") {
if (document.querySelector("#admintools")) presenceData.details = "Что-то делает в админ-панели";
if (document.querySelector("#admintools"))
presenceData.details = "Что-то делает в админ-панели";
else presenceData.details = "Редактирует свой аккаунт";
} else if (path === "/sub") presenceData.details = "Собирается купить подписку";
} else if (path === "/sub")
presenceData.details = "Собирается купить подписку";
else if (path === "/upload") presenceData.details = "Загружает изображение";
else if (path === "/api.php") presenceData.details = "Читает документацию API";
else if (path === "/api.php")
presenceData.details = "Читает документацию API";
else presenceData.details = "Что-то делает на Фугапедии";

presence.setActivity(presenceData);
Expand Down
42 changes: 21 additions & 21 deletions websites/A/AnimeOnsen/dist/metadata.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"$schema": "https://schemas.premid.app/metadata/1.5",
"author": {
"name": "Mist8kenGAS",
"id": "275272170807099399"
},
"service": "AnimeOnsen",
"description": {
"en": "AnimeOnsen is a video streaming platform for anime shows and movies."
},
"url": "animeonsen.xyz",
"version": "1.0.0",
"logo": "https://i.imgur.com/O99W6aY.png",
"thumbnail": "https://i.imgur.com/KdbSpCP.png",
"color": "#1a1a1a",
"tags": [
"anime",
"video",
"streaming"
],
"category": "anime",
"regExp": "(www.)?(animeonsen.xyz)"
"$schema": "https://schemas.premid.app/metadata/1.5",
"author": {
"name": "Mist8kenGAS",
"id": "275272170807099399"
},
"service": "AnimeOnsen",
"description": {
"en": "AnimeOnsen is a video streaming platform for anime shows and movies."
},
"url": "animeonsen.xyz",
"version": "1.0.1",
"logo": "https://i.imgur.com/O99W6aY.png",
"thumbnail": "https://i.imgur.com/KdbSpCP.png",
"color": "#1a1a1a",
"tags": [
"anime",
"video",
"streaming"
],
"category": "anime",
"regExp": "(www.)?(animeonsen.xyz)"
}
Loading

0 comments on commit 11c709a

Please sign in to comment.