feat: april fools!

This commit is contained in:
not-nullptr 2025-03-24 16:08:06 +00:00
parent dc20519c86
commit ec8a85ae30
5 changed files with 17 additions and 107 deletions

View File

@ -0,0 +1,5 @@
export const load = () => {
const isAprilFools =
new Date().getDate() === 1 && new Date().getMonth() === 3;
return { isAprilFools };
};

View File

@ -18,7 +18,7 @@
} from "$lib/store/index.svelte"; } from "$lib/store/index.svelte";
import "../app.scss"; import "../app.scss";
let { children } = $props(); let { children, data } = $props();
let enablePlausible = $state(false); let enablePlausible = $state(false);
let scrollPositions = new Map<string, number>(); let scrollPositions = new Map<string, number>();
@ -115,6 +115,13 @@
src="{PUB_PLAUSIBLE_URL}/js/script.js" src="{PUB_PLAUSIBLE_URL}/js/script.js"
></script> ></script>
{/if} {/if}
{#if data.isAprilFools}
<style>
* {
font-family: "Comic Sans MS", "Comic Sans", cursive !important;
}
</style>
{/if}
</svelte:head> </svelte:head>
<!-- FIXME: if user resizes between desktop/mobile, highlight of page disappears (only shows on original size) --> <!-- FIXME: if user resizes between desktop/mobile, highlight of page disappears (only shows on original size) -->

View File

@ -1,7 +1,7 @@
import { browser } from "$app/environment"; import { browser } from "$app/environment";
export const load = ({ data }) => { export const load = ({ data }) => {
if (!browser) return; if (!browser) return data;
window.plausible = window.plausible =
window.plausible || window.plausible ||
((_, opts) => { ((_, opts) => {
@ -9,6 +9,7 @@ export const load = ({ data }) => {
status: 200, status: 200,
}); });
}); });
return data; return data;
}; };

View File

@ -1,19 +1,11 @@
<script lang="ts"> <script lang="ts">
// this comment was written on 15/11/2024 at 16:01 GMT.
// i bet to myself that i could complete this whole redesign implementation
// by the time realmy got started on it. i guess we'll see how that goes
//
// ship fast n break things !!
// -- nullptr
// that definitely happened
// -- JovannMC
import Uploader from "$lib/components/functional/Uploader.svelte"; import Uploader from "$lib/components/functional/Uploader.svelte";
import { converters } from "$lib/converters"; import { converters } from "$lib/converters";
import { vertdLoaded } from "$lib/store/index.svelte"; import { vertdLoaded } from "$lib/store/index.svelte";
import { AudioLines, Check, Film, Image } from "lucide-svelte"; import { AudioLines, Check, Film, Image } from "lucide-svelte";
const { data } = $props();
const getSupportedFormats = (name: string) => const getSupportedFormats = (name: string) =>
converters.find((c) => c.name === name)?.supportedFormats.join(", ") || converters.find((c) => c.name === name)?.supportedFormats.join(", ") ||
"none"; "none";

View File

@ -1,95 +0,0 @@
/// <reference types="@sveltejs/kit" />
// code modified from https://svelte.dev/docs/kit/service-workers
import { build, files, version } from "$service-worker";
// create a unique cache name for this deployment
const CACHE = `cache-${version}`;
const ASSETS = [
...build, // the app itself
...files, // everything in `static`
];
self.addEventListener("install", (event) => {
// create a new cache and add all files to it
async function addFilesToCache() {
try {
const cache = await caches.open(CACHE);
await cache.addAll(ASSETS);
console.log(`assets cached successfully: ${ASSETS}`);
} catch (err) {
console.error(`failed to cache assets: ${err}`);
}
}
console.log(`installing service worker for version ${version}`);
event.waitUntil(addFilesToCache());
});
self.addEventListener("activate", (event) => {
// remove previous cached data from disk
async function deleteOldCaches() {
try {
const keys = await caches.keys();
for (const key of keys) {
if (key !== CACHE) {
await caches.delete(key);
console.log(`deleted old cache: ${key}`);
}
}
} catch (error) {
console.error(`failed to delete old caches: ${error}`);
}
}
event.waitUntil(deleteOldCaches());
});
self.addEventListener("fetch", (event) => {
// ignore requests other than GET
if (event.request.method !== "GET") return;
async function respond() {
const url = new URL(event.request.url);
const cache = await caches.open(CACHE);
// assets can always be served from the cache
if (ASSETS.includes(url.pathname)) {
const response = await cache.match(url.pathname);
if (response) {
console.log(`serving ${url.pathname} from cache`);
return response;
}
}
// for everything else, try the network first, but
// fall back to the cache if we're offline
try {
const response = await fetch(event.request);
// if we're offline, fetch can return a value that is not a Response instead
// of throwing, and we can't pass this non-Response to respondWith
if (!(response instanceof Response)) {
throw new Error("invalid response from fetch");
}
if (response.status === 200)
cache.put(event.request, response.clone());
return response;
} catch (err) {
const response = await cache.match(event.request);
if (response) {
console.log(`Returning ${event.request.url} from cache`);
return response;
}
// if there's no cache, then just error out
// as there is nothing we can do to respond to this request
throw err;
}
}
event.respondWith(respond());
});