Reorganize some Info
s
This commit is contained in:
parent
b4e060c954
commit
00f4961316
28 changed files with 37 additions and 65 deletions
|
@ -1,6 +1,6 @@
|
|||
import {type Handler} from "@netlify/functions";
|
||||
import * as osu from "osu-api-v2-js";
|
||||
import {type OsuInfo} from "#Infos/RhythmGames/Osu.js";
|
||||
import {type OsuInfo} from "#Infos/Gaming/Osu.js";
|
||||
import {MongoClient} from "mongodb";
|
||||
import {type Token} from "./token.js";
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import {type Handler} from "@netlify/functions";
|
||||
import {type SpeedruncomInfo} from "#Infos/Speedrun/Speedruncom.js";
|
||||
import {type SpeedruncomInfo} from "#Infos/Gaming/Speedruncom.js";
|
||||
|
||||
interface Runs {
|
||||
data: {
|
|
@ -1,5 +1,5 @@
|
|||
import {type Handler} from "@netlify/functions";
|
||||
import {type AnilistInfo} from "#Infos/Anime/Anilist.js";
|
||||
import {type AnilistInfo} from "#Infos/Media/Anilist.js";
|
||||
|
||||
const handler: Handler = async () => {
|
||||
const anilist = await fetch("https://graphql.anilist.co", {
|
||||
|
@ -52,9 +52,9 @@ const handler: Handler = async () => {
|
|||
total: json.media.episodes,
|
||||
},
|
||||
score: json.score,
|
||||
startDate: json.startedAt.year ? new Date(`${json.startedAt.year}-${json.startedAt.month}-${json.startedAt.day}`).toISOString() : new Date().toISOString(),
|
||||
startDate: json.startedAt.year ? new Date(`${json.startedAt.year}-${json.startedAt.month}-${json.startedAt.day}Z`).toISOString() : new Date().toISOString(),
|
||||
updateDate: new Date(json.updatedAt * 1000).toISOString(),
|
||||
endDate: json.completedAt.year ? new Date(`${json.completedAt.year}-${json.completedAt.month}-${json.completedAt.day}`).toISOString() : new Date().toISOString(),
|
||||
endDate: json.completedAt.year ? new Date(`${json.completedAt.year}-${json.completedAt.month}-${json.completedAt.day}Z`).toISOString() : new Date().toISOString(),
|
||||
cover: json.media.coverImage.medium,
|
||||
url: json.media.siteUrl,
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
import {type Handler} from "@netlify/functions";
|
||||
import {type LastfmInfo} from "#Infos/Music/Lastfm.js";
|
||||
import {type LastfmInfo} from "#Infos/Media/Lastfm.js";
|
||||
|
||||
const handler: Handler = async () => {
|
||||
const lastfm = await (await fetch(`https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=TTTaevas&api_key=${process.env.API_LASTFM}&format=json&limit=1`)).json() as {
|
|
@ -14,7 +14,7 @@ export interface GithubInfo {
|
|||
}
|
||||
|
||||
export default function GitHub() {
|
||||
const {data, error, setError} = DataHandler<GithubInfo>("/.netlify/functions/github", 60 * 20);
|
||||
const {data, error, setError} = DataHandler<GithubInfo>("coding_github", 60 * 20);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -7,7 +7,7 @@ export type GitlabInfo = {
|
|||
} | undefined;
|
||||
|
||||
export default function GitLab() {
|
||||
const {data, error, setError} = DataHandler<GitlabInfo>("/.netlify/functions/gitlab", 60 * 20);
|
||||
const {data, error, setError} = DataHandler<GitlabInfo>("coding_gitlab", 60 * 20);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -10,7 +10,7 @@ export type KitsudevInfo = {
|
|||
} | undefined;
|
||||
|
||||
export default function KitsuDev() {
|
||||
const {data, error, setError} = DataHandler<KitsudevInfo>("/.netlify/functions/kitsudev", 60 * 20);
|
||||
const {data, error, setError} = DataHandler<KitsudevInfo>("coding_kitsudev", 60 * 20);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import React, {useState, useEffect} from "react";
|
||||
|
||||
/** Takes care of getting data regularly */
|
||||
export default function DataHandler<T extends unknown | undefined>(url: string, updateEveryXSeconds: number, expectData = true) {
|
||||
export default function DataHandler<T extends unknown | undefined>(netlifyFunctionName: string, updateEveryXSeconds: number, expectData = true) {
|
||||
const [data, setData]: [T | undefined, React.Dispatch<React.SetStateAction<T | undefined>>] = useState();
|
||||
const [error, setError] = useState(false);
|
||||
const [count, setCount] = useState(0);
|
||||
|
@ -9,7 +9,7 @@ export default function DataHandler<T extends unknown | undefined>(url: string,
|
|||
// Try to get and set data
|
||||
const updateData = async () => {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const response = await fetch("/.netlify/functions/" + netlifyFunctionName);
|
||||
if (!response.ok) {throw "failed";};
|
||||
setData(expectData ? await response.json() : true);
|
||||
setError(false);
|
||||
|
|
|
@ -18,7 +18,7 @@ export type KitsuclubInfo = {
|
|||
} | undefined;
|
||||
|
||||
export default function KitsuClub() {
|
||||
const {data, error, setError} = DataHandler<KitsuclubInfo>("/.netlify/functions/kitsuclub", 60 * 20);
|
||||
const {data, error, setError} = DataHandler<KitsuclubInfo>("fediverse_kitsuclub", 60 * 20);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -12,7 +12,7 @@ export type OsuInfo = {
|
|||
} | undefined;
|
||||
|
||||
export default function Osu(args: {ruleset: Ruleset}) {
|
||||
const {data, error, setError} = DataHandler<OsuInfo>(`/.netlify/functions/osu?ruleset=${args.ruleset}`, 60 * 45);
|
||||
const {data, error, setError} = DataHandler<OsuInfo>(`gaming_osu?ruleset=${args.ruleset}`, 60 * 45);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
const ruleset = Ruleset[args.ruleset];
|
|
@ -16,7 +16,7 @@ export type SpeedruncomInfo = {
|
|||
} | undefined;
|
||||
|
||||
export default function Speedruncom() {
|
||||
const {data, error, setError} = DataHandler<SpeedruncomInfo>("/.netlify/functions/speedruncom", 60 * 60);
|
||||
const {data, error, setError} = DataHandler<SpeedruncomInfo>("gaming_speedruncom", 60 * 60);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
|
@ -1,6 +1,7 @@
|
|||
import React, {useEffect, useState} from "react";
|
||||
import Info from "../Info.js";
|
||||
|
||||
import Speedruncom from "./Speedruncom.js";
|
||||
import Osu from "./Osu.js";
|
||||
import { Ruleset } from "osu-api-v2-js";
|
||||
import DataHandler from "#Infos/DataHandler.js";
|
||||
|
@ -9,19 +10,23 @@ export default function RhythmGames() {
|
|||
const {data, error} = DataHandler<boolean>("/.netlify/functions/token?service=osu", 60 * 60 * 8, false);
|
||||
const [websites, setWebsites] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
||||
setWebsites([<Speedruncom key={"speedruncom"}/>]);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
const osu = <Osu ruleset={Ruleset.osu} key={"osu"}/>;
|
||||
const taiko = <Osu ruleset={Ruleset.taiko} key={"taiko"}/>;
|
||||
const fruits = <Osu ruleset={Ruleset.fruits} key={"fruits"}/>;
|
||||
const mania = <Osu ruleset={Ruleset.mania} key={"mania"}/>;
|
||||
setWebsites([osu, taiko, fruits, mania]);
|
||||
// const fruits = <Osu ruleset={Ruleset.fruits} key={"fruits"}/>;
|
||||
// const mania = <Osu ruleset={Ruleset.mania} key={"mania"}/>;
|
||||
setWebsites(websites.concat([osu, taiko]));
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
return (
|
||||
<Info
|
||||
type="Rhythm Games"
|
||||
type="Gaming"
|
||||
websites={websites}
|
||||
error={error}
|
||||
/>
|
|
@ -14,7 +14,7 @@ export type HacktheboxInfo = {
|
|||
} | undefined;
|
||||
|
||||
export default function Hackthebox() {
|
||||
const {data, error, setError} = DataHandler<HacktheboxInfo>("/.netlify/functions/hackthebox", 60 * 60);
|
||||
const {data, error, setError} = DataHandler<HacktheboxInfo>("hacking_hackthebox", 60 * 60);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -37,7 +37,7 @@ function Button(item: Item) {
|
|||
}
|
||||
|
||||
export default function Wanikani() {
|
||||
const {data, error, setError} = DataHandler<WanikaniInfo>("/.netlify/functions/wanikani", 60 * 60);
|
||||
const {data, error, setError} = DataHandler<WanikaniInfo>("japanese_wanikani", 60 * 60);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -18,7 +18,7 @@ export type AnilistInfo = {
|
|||
} | undefined;
|
||||
|
||||
export default function Anilist() {
|
||||
const {data, error, setError} = DataHandler<AnilistInfo>("/.netlify/functions/anilist", 60 * 30);
|
||||
const {data, error, setError} = DataHandler<AnilistInfo>("media_anilist", 60 * 30);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
|
@ -15,7 +15,7 @@ export type LastfmInfo = {
|
|||
} | undefined;
|
||||
|
||||
export default function Lastfm() {
|
||||
const {data, error, setError} = DataHandler<LastfmInfo>("/.netlify/functions/lastfm", 60 * 2);
|
||||
const {data, error, setError} = DataHandler<LastfmInfo>("media_lastfm", 60 * 2);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
|
@ -1,14 +1,17 @@
|
|||
import React from "react";
|
||||
import Info from "../Info.js";
|
||||
import Lastfm from "./Lastfm.js";
|
||||
import Anilist from "./Anilist.js";
|
||||
|
||||
export default function Anime() {
|
||||
export default function Media() {
|
||||
const lastfm = <Lastfm key={"Lastfm"}/>;
|
||||
const anilist = <Anilist key={"Anilist"}/>;
|
||||
|
||||
return (
|
||||
<Info
|
||||
type="Anime"
|
||||
type="Media"
|
||||
websites={[
|
||||
lastfm,
|
||||
anilist,
|
||||
]}
|
||||
/>
|
|
@ -1,16 +0,0 @@
|
|||
import React from "react";
|
||||
import Info from "../Info.js";
|
||||
import Lastfm from "./Lastfm.js";
|
||||
|
||||
export default function Anime() {
|
||||
const lastfm = <Lastfm key={"Lastfm"}/>;
|
||||
|
||||
return (
|
||||
<Info
|
||||
type="Music"
|
||||
websites={[
|
||||
lastfm,
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
import React from "react";
|
||||
import Info from "../Info.js";
|
||||
import Speedruncom from "./Speedruncom.js";
|
||||
|
||||
export default function Speedrun() {
|
||||
const speedruncom = <Speedruncom key={"speedruncom"}/>;
|
||||
|
||||
return (
|
||||
<Info
|
||||
type="Speedrun"
|
||||
websites={[
|
||||
speedruncom,
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
|
@ -10,7 +10,7 @@ export type UmamiInfo = {
|
|||
} | undefined;
|
||||
|
||||
export default function Umami() {
|
||||
const {data, error, setError} = DataHandler<UmamiInfo>("/.netlify/functions/umami", 60 * 5);
|
||||
const {data, error, setError} = DataHandler<UmamiInfo>("website_umami", 60 * 5);
|
||||
const [elements, setElements] = useState([] as React.JSX.Element[]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
import React, {Component} from "react";
|
||||
import Music from "./Music/index.js";
|
||||
import Speedrun from "./Speedrun/index.js";
|
||||
import Media from "./Media/index.js";
|
||||
// import Hacking from "./Hacking/index.js";
|
||||
import Coding from "./Coding/index.js";
|
||||
import RhythmGames from "./RhythmGames/index.js";
|
||||
import Anime from "./Anime/index.js";
|
||||
import Gaming from "./Gaming/index.js";
|
||||
// import Japanese from "./Japanese/index.js";
|
||||
import Fediverse from "./Fediverse/index.js";
|
||||
import Website from "./Website/index.js";
|
||||
|
@ -18,13 +16,11 @@ export default class Infos extends Component {
|
|||
bg-gradient-to-r from-sky-600 to-indigo-600">
|
||||
<div draggable="false" ref={this.dragbar} className="z-[100] h-full w-[25px] fixed right-[7px] lg:right-[340px] cursor-ew-resize select-none hover:bg-gradient-to-r from-white/80 to-white/1 active:to-white/20"></div>
|
||||
<div className="z-[90] p-2.5 flex flex-wrap text-white">
|
||||
<Music/>
|
||||
<Media/>
|
||||
<Fediverse/>
|
||||
<Coding/>
|
||||
<Speedrun/>
|
||||
<Anime/>
|
||||
{/*<Japanese/>*/}
|
||||
<RhythmGames/>
|
||||
<Gaming/>
|
||||
{/*<Hacking/>*/}
|
||||
<Website/>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue