refactor: massive USRPFP overhaul (#3)

This repo completely overhauls how USRPFP works. Some changes include:
- Deleted some leftover files
- Edited README.md a bit
- Avatars and badges are now stored in `db/data.json`
- CSS file (`db/dist.css`) is automatically generated by a GitHub
workflow

If you have questions, lmk
This commit is contained in:
nexpid 2023-08-29 12:12:01 +02:00 committed by GitHub
parent ea2d738175
commit 5a5d2c2a2b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 288 additions and 377 deletions

39
.github/scripts/convert/index.mjs vendored Normal file
View file

@ -0,0 +1,39 @@
import { readFile, writeFile } from "fs/promises";
import { join } from "path";
console.time("Done");
console.log("Reading avatarsdatabase.css...");
const avis = (await readFile(join("../../", "avatarsdatabase.css"), "utf8"))
.replace(/\r/g, "")
.split("\n");
const imageMatcher = /url\((?:'|")([^'"]+)(?:'|")\)/;
const avatarMatcher = /^\/\* Custom avatar for ([0-9]+) \*\/$/;
const badgeMatcher = /^\/\* Custom badge for (.*?) \*\/$/;
const avatars = {};
for (let i = 0; i < avis.length; i++) {
const l = avis[i];
const id = l.match(avatarMatcher)?.[1];
if (id) avatars[id] = avis[i + 2].match(imageMatcher)[1];
}
const badges = {};
for (let i = 0; i < avis.length; i++) {
const l = avis[i];
const username = l.match(badgeMatcher)?.[1];
if (username) badges[username] = avis[i + 10].match(imageMatcher)[1];
}
await writeFile(
join("../../", "db", "data.json"),
JSON.stringify(
{
avatars,
badges,
},
undefined,
4
)
);