(Infos) Add KitsuDev and change Speedrun.com

This commit is contained in:
Taevas 2025-02-26 23:58:49 +01:00
parent a4496117f8
commit a1827a31e9
7 changed files with 84 additions and 9 deletions

View file

@ -27,6 +27,7 @@
<a rel="me" href="https://libre.fm/user/Taevas">Libre.fm</a> <a rel="me" href="https://libre.fm/user/Taevas">Libre.fm</a>
<a rel="me" href="https://beehaw.org/u/Taevas">Beehaw (Lemmy)</a> <a rel="me" href="https://beehaw.org/u/Taevas">Beehaw (Lemmy)</a>
<a rel="me" href="https://kitsunes.club/@taevas">KitsuClub (Sharkey)</a> <a rel="me" href="https://kitsunes.club/@taevas">KitsuClub (Sharkey)</a>
<a rel="me" href="https://kitsunes.dev/Taevas">KitsuDev (Forgejo)</a>
<a rel="me" href="https://musicbrainz.org/user/Taevas">MusicBrainz</a> <a rel="me" href="https://musicbrainz.org/user/Taevas">MusicBrainz</a>
<a rel="me" href="https://listenbrainz.org/user/Taevas">ListenBrainz</a> <a rel="me" href="https://listenbrainz.org/user/Taevas">ListenBrainz</a>
</span> </span>

View file

@ -3,13 +3,13 @@ import {api} from "./shared/api.js";
import {type HacktheboxInfo} from "#Infos/Hacking/Hackthebox.js"; import {type HacktheboxInfo} from "#Infos/Hacking/Hackthebox.js";
const handler: Handler = async () => { const handler: Handler = async () => {
const hackthebox: {profile: {activity: HacktheboxInfo[]}} = await api<{ const hackthebox = await api<{
profile: { profile: {
activity: HacktheboxInfo[]; activity: HacktheboxInfo[];
}; };
}>("https://www.hackthebox.com/api/v4/profile/activity/1063999"); }>("https://www.hackthebox.com/api/v4/profile/activity/1063999");
const pwn = hackthebox.profile.activity.find((a: HacktheboxInfo) => a!.object_type === "machine"); const pwn = hackthebox.profile.activity.find((a: HacktheboxInfo) => a?.object_type === "machine");
if (!pwn) { if (!pwn) {
return { return {
statusCode: 404, statusCode: 404,

View file

@ -0,0 +1,26 @@
import {type Handler} from "@netlify/functions";
import {api} from "./shared/api.js";
import { type KitsudevInfo } from "#Infos/Coding/KitsuDev.js";
const handler: Handler = async () => {
const kitsudev = await api<[{
repo: {
full_name: string
html_url: string
}
created: string
}]>("https://kitsunes.dev/api/v1/users/Taevas/activities/feeds?limit=1");
const info: KitsudevInfo = {
name: kitsudev[0].repo.full_name,
url: kitsudev[0].repo.html_url,
date: kitsudev[0].created
};
return {
statusCode: 200,
body: JSON.stringify(info),
};
};
export {handler};

View file

@ -84,6 +84,10 @@ const handler: Handler = async () => {
video: data.run.videos.links.at(0)?.uri, video: data.run.videos.links.at(0)?.uri,
}; };
while (run.time.startsWith("0") || run.time.startsWith(":")) {
run.time = run.time.substring(1);
}
return { return {
statusCode: 200, statusCode: 200,
body: JSON.stringify(run), body: JSON.stringify(run),

View file

@ -0,0 +1,37 @@
import React, {useState, useEffect} from "react";
import Website from "../Website.js";
import DataHandler from "#Infos/DataHandler.js";
import Link from "#parts/Link.js";
export type KitsudevInfo = {
name: string
url: string
date: string;
} | undefined;
export default function KitsuDev() {
const {data, error, setError} = DataHandler<KitsudevInfo>("/.netlify/functions/kitsudev", 60 * 20);
const [elements, setElements] = useState([] as React.JSX.Element[]);
useEffect(() => {
if (data) {
try {
setElements([
<p key={"kitsudev-date"}>Latest activity: <strong>{data.date.substring(0, data.date.indexOf("T"))}</strong></p>,
<Link key={"kitsudev-link"} classes="mt-1 px-1 py-2 inline-block w-full font-bold leading-[18px] bg-white text-blue-800" link={data.url} text={data.name}/>
]);
} catch {
setError(true);
}
}
}, [data]);
return (
<Website
name="KitsuDev"
link="https://kitsunes.dev/Taevas"
elements={elements}
error={error}
/>
);
}

View file

@ -2,10 +2,12 @@ import React from "react";
import Info from "../Info.js"; import Info from "../Info.js";
import GitHub from "./GitHub.js"; import GitHub from "./GitHub.js";
import GitLab from "./GitLab.js"; import GitLab from "./GitLab.js";
import KitsuDev from "./KitsuDev.js";
export default function Coding() { export default function Coding() {
const github = <GitHub key={"github"}/>; const github = <GitHub key={"github"}/>;
const gitlab = <GitLab key={"gitlab"}/>; const gitlab = <GitLab key={"gitlab"}/>;
const kitsudev = <KitsuDev key={"kitsudev"}/>;
return ( return (
<Info <Info
@ -13,6 +15,7 @@ export default function Coding() {
websites={[ websites={[
github, github,
gitlab, gitlab,
kitsudev,
]} ]}
/> />
); );

View file

@ -1,7 +1,8 @@
import React, {useState, useEffect} from "react"; import React, {useState, useEffect} from "react";
import Website from "../Website.js"; import Website from "../Website.js";
import ButtonLink from "#parts/ButtonLink.js";
import DataHandler from "#Infos/DataHandler.js"; import DataHandler from "#Infos/DataHandler.js";
import Link from "#parts/Link.js";
import ButtonLink from "#parts/ButtonLink.js";
export type SpeedruncomInfo = { export type SpeedruncomInfo = {
place: number; place: number;
@ -23,15 +24,18 @@ export default function Speedruncom() {
try { try {
setElements([ setElements([
<div key={"data"} className="flex pb-2"> <div key={"data"} className="flex pb-2">
<img alt="game thumbnail" src={data.thumbnail} className="h-32 m-auto" /> <img alt="game thumbnail" src={data.thumbnail} className="h-24 m-auto" />
<div className="m-auto pl-2"> <div className="m-auto pl-2">
<p className="mb-2">Placed <strong>#{data.place}</strong> on:</p> <Link key={"more"} classes="mt-1 px-1 py-2 inline-block w-full font-bold leading-[18px] bg-white text-blue-800" link={data.link}
<p className="font-bold">{data.game}</p> text={`${data.game} (${data.details.toString()}) in ${data.time}`}/>
{data.details.map((d, i) => <p key={`detail-${i}`}>{d}</p>)} <p className="mt-2">Placed <strong>#{data.place}</strong></p>
<p className="font-bold">{data.date}</p>
</div> </div>
</div>, </div>,
<p key={"date"} className="mt-2 font-bold">{data.date}</p>, <> {
<ButtonLink key={"more"} link={data.link} text="Run Details" />, data.video ? <ButtonLink key={"youtube"} link={data.video} text="YouTube video"/> : ""
} </>
]); ]);
} catch { } catch {
setError(true); setError(true);