oops went on a massive code sesh and theres like a whole website now

This commit is contained in:
2026-11-03 19:01:41 +00:00
parent e4e28174bf
commit 7e8f329109
27 changed files with 492 additions and 102 deletions

View File

@@ -1,12 +1,46 @@
<!doctype html>
<html lang="en">
<head>
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Squada+One&display=swap"
rel="stylesheet"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Fira+Mono:wght@400;500;700&display=swap"
rel="stylesheet"
/>
<!-- Not Fonts -->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="text-scale" content="scale" />
%sveltekit.head%
</head>
<body class="bg-ctp-mantle text-ctp-text" data-sveltekit-preload-data="hover">
<style>
.fira-mono-regular {
font-family: 'Fira Mono', monospace;
font-weight: 400;
font-style: normal;
}
.fira-mono-medium {
font-family: 'Fira Mono', monospace;
font-weight: 500;
font-style: normal;
}
.fira-mono-bold {
font-family: 'Fira Mono', monospace;
font-weight: 700;
font-style: normal;
}
</style>
<body class="fira-mono-regular bg-ctp-mantle text-ctp-text" data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>

8
src/env.ts Normal file
View File

@@ -0,0 +1,8 @@
import { defineEnvVars } from '@sveltejs/kit/env';
export const variables = defineEnvVars({
JELLYFIN_URL: {},
JELLYFIN_API_KEY: {},
JELLYFIN_PLAYLIST_ID: {},
JELLYFIN_USER_ID: {}
});

124
src/lib/server/jellyfin.ts Normal file
View File

@@ -0,0 +1,124 @@
import { JELLYFIN_URL, JELLYFIN_API_KEY, JELLYFIN_USER_ID } from '$app/env/private';
const CACHE_TTL = 3 * 60 * 60 * 1000;
interface JellyfinSong {
Id: string;
Name: string;
Album?: string;
AlbumId?: string;
Artists?: string[];
DateCreated?: string;
}
interface PlaylistItemsResponse {
Items: JellyfinSong[];
TotalRecordCount: number;
}
export interface LatestSong {
id: string;
name: string;
artist: string;
album: string;
dateAdded: string | null;
coverArt: string | null;
}
interface CacheEntry<T> {
value: T;
expiresAt: number;
}
const playlistCache = new Map<string, CacheEntry<LatestSong | null>>();
const pendingRequests = new Map<string, Promise<LatestSong | null>>();
async function fetchLatestPlaylistSong(
fetch: typeof globalThis.fetch,
playlistId: string
): Promise<LatestSong | null> {
const url = new URL(`${JELLYFIN_URL}/Playlists/${playlistId}/Items`);
url.searchParams.set('UserId', JELLYFIN_USER_ID);
url.searchParams.set('Limit', '1');
const headers = {
'X-Emby-Token': JELLYFIN_API_KEY
};
const countResponse = await fetch(url, { headers });
if (!countResponse.ok) {
const body = await countResponse.text();
throw new Error(`Jellyfin error: ${countResponse.status} - ${body}`);
}
const countData: PlaylistItemsResponse = await countResponse.json();
const total = countData.TotalRecordCount;
if (!total) return null;
url.searchParams.set('StartIndex', String(total - 1));
const lastResponse = await fetch(url, { headers });
if (!lastResponse.ok) {
const body = await lastResponse.text();
throw new Error(`Jellyfin error: ${lastResponse.status} - ${body}`);
}
const lastData: PlaylistItemsResponse = await lastResponse.json();
const song = lastData.Items?.[0];
if (!song) return null;
const artworkId = song.AlbumId ?? song.Id;
return {
id: song.Id,
name: song.Name,
artist: song.Artists?.join(', ') ?? 'Unknown artist',
album: song.Album ?? 'Unknown album',
dateAdded: song.DateCreated ?? null,
coverArt: `/artwork/${encodeURIComponent(artworkId)}`
};
}
export async function getLatestPlaylistSong(
fetch: typeof globalThis.fetch,
playlistId: string
): Promise<LatestSong | null> {
const cached = playlistCache.get(playlistId);
if (cached && cached.expiresAt > Date.now()) {
return cached.value;
}
const pending = pendingRequests.get(playlistId);
if (pending) return pending;
const request = fetchLatestPlaylistSong(fetch, playlistId)
.then((song) => {
playlistCache.set(playlistId, {
value: song,
expiresAt: Date.now() + CACHE_TTL
});
return song;
})
.finally(() => {
pendingRequests.delete(playlistId);
});
pendingRequests.set(playlistId, request);
return request;
}
export function invalidatePlaylistCache(playlistId: string): void {
playlistCache.delete(playlistId);
}

View File

@@ -0,0 +1,15 @@
import type { PageServerLoad } from './$types';
import { getLatestPlaylistSong } from '#lib/server/jellyfin';
import { JELLYFIN_PLAYLIST_ID } from '$app/env/private';
export const load: PageServerLoad = () => {
const latestSong = getLatestPlaylistSong(globalThis.fetch, JELLYFIN_PLAYLIST_ID);
latestSong.catch(() => {});
return {
streamed: {
latestSong
}
};
};

View File

@@ -1,10 +1,81 @@
<div class="m-6 grid grid-cols-1 grid-rows-3 gap-5">
<div class="main-container" style="--container-color:var(--ctp-mauve);">
<p class="text-bold text-xl">Adumh00man</p>
<p></p>
<script lang="ts">
import type { PageData } from './$types';
let { data }: { data: PageData } = $props();
</script>
<div class="m-6 mx-auto grid max-w-7xl grid-cols-1 grid-rows-3 gap-5">
<div
class="main-container grid grid-cols-[2fr_1fr] py-7 pl-10"
style="--container-color:var(--ctp-mauve);"
>
<div class="ml-6 py-4">
<div class="flex">
<img src="/adumh00man.png" class="mt-[13px] mr-2 ml-[-15px] h-12" alt="" />
<p class="title-font text-bold text-[50px]">Adumh00man</p>
</div>
<p id="description-block" class="pr-10 pl-4 text-justify">
Adumh00man is a mysterious all-powerful being pretending to be a cat pretending to be a nix
youtuber. Currently maintaining an awesome nix config, and using nixos fulltime, his
programming languages of choice are rust and svelte (if you can count svelte as a language).
He is also an avid homelabber, running all of his services on-prem so that the evil
corporations that be can't control him when the world is eventually owned by them. This
includes his
<a class="text-link" href="https://git.voidarc.co.uk/voidarc">git server</a>, his
<a class="text-link" href="https://blog.voidarc.co.uk">blog</a>, and some other services he
uses to "legally aqquire media" (yarr me hearties).
</p>
</div>
<div class="my-4 mr-4 grid min-w-100 flex-col gap-2 pr-3">
<div
class="sub-container flex items-center gap-3 overflow-hidden pr-3"
style="--container-color:var(--ctp-green);"
>
{#await data.streamed.latestSong}
<p>Loading latest song...</p>
{:then song}
<img src={song.coverArt} class="h-full w-auto shrink-0 object-contain" alt="" />
<div class="flex min-w-0 flex-col justify-center">
<p class="fira-mono-medium">Currently Listening to…</p>
<div
id="music-title-block"
onclick={() =>
window.open(
`https://soundcloud.com/search?q=${song.name} ${song.artist}`,
'_blank'
)}
style="cursor: pointer;"
role="link"
onkeydown={(e) => {
if (e.key === 'Enter') {
}
}}
tabindex="0"
title="{song.name} - {song.artist}"
class="pl-2"
>
<p class="fira-mono-bold w-full truncate text-2xl">
{song.name}
</p>
<p class="fira-mono-medium w-full truncate text-xl">
{song.artist} - {song.album}
</p>
</div>
</div>
{:catch error}
<p>{error}</p>
{/await}
</div>
<div class="sub-container" style="--container-color:var(--ctp-peach);">watching</div>
<div class="sub-container" style="--container-color:var(--ctp-red);">reading</div>
</div>
</div>
<div class="grid grid-cols-2 grid-rows-1 gap-4">
<div class="main-container"></div>
<div class="main-container"></div>
<div class="grid grid-cols-[4fr_3fr] grid-rows-1 gap-4">
<div class="main-container" style="--container-color:var(--ctp-blue);">
<div class="section-title fira-mono-bold mr-3 py-2 text-4xl">Content</div>
</div>
<div class="main-container" style="--container-color:var(--ctp-green);">
<div class="section-title fira-mono-bold mr-3 py-2 text-4xl">Commits</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,32 @@
import { error } from '@sveltejs/kit';
import type { RequestHandler } from './$types';
import { JELLYFIN_URL, JELLYFIN_API_KEY } from '$app/env/private';
export const GET: RequestHandler = async ({ params, fetch }) => {
const { itemId } = params;
if (!/^[a-zA-Z0-9-]+$/.test(itemId)) {
error(400, 'Invalid item ID');
}
const response = await fetch(
`${JELLYFIN_URL}/Items/${encodeURIComponent(itemId)}/Images/Primary`,
{
headers: {
'X-Emby-Token': JELLYFIN_API_KEY
}
}
);
if (!response.ok) {
error(response.status, 'Artwork unavailable');
}
return new Response(response.body, {
headers: {
'Content-Type': response.headers.get('Content-Type') ?? 'image/jpeg',
'Cache-Control': 'private, max-age=3600'
}
});
};

View File

@@ -110,7 +110,23 @@
--ctp-crust-oklch: 0.1828 0.0204 284.2038;
}
.main-container {
* {
transition:
color 200ms,
background-color 200ms,
border-color 200ms,
fill 200ms,
stroke 200ms;
}
.title-font {
font-family: 'Squada One', sans-serif;
font-weight: 400;
font-style: normal;
}
.main-container,
.sub-container {
--container-color: var(--ctp-lavender);
background-color: var(--ctp-surface0);
border-left: 10px solid var(--container-color);
@@ -118,3 +134,32 @@
padding-top: 10px;
padding-bottom: 10px;
}
.sub-container {
background-color: var(--ctp-surface1);
border-left-width: 6px;
aspect-ratio: 20/5;
}
.text-link {
text-decoration: underline;
color: var(--ctp-blue);
}
#description-block {
border-left: 10px solid var(--ctp-surface2);
}
#music-title-block {
border-left: 4px solid var(--ctp-overlay1);
}
#music-title-block:hover {
color: var(--ctp-lavender);
border-left-color: var(--ctp-mauve);
}
.section-title {
border-bottom: 2px solid var(--ctp-overlay2);
text-indent: 1ch;
}