local no errors
Some checks failed
Rebuild signaller for deprived.dev to rebuild site / test_service (push) Failing after 9s
Some checks failed
Rebuild signaller for deprived.dev to rebuild site / test_service (push) Failing after 9s
This commit is contained in:
parent
a7a53e6fb6
commit
7a21f70144
7 changed files with 104 additions and 5 deletions
12
package-lock.json
generated
12
package-lock.json
generated
|
|
@ -14,7 +14,8 @@
|
||||||
"pocketbase": "^0.26.2",
|
"pocketbase": "^0.26.2",
|
||||||
"svelte-katex": "^0.1.2",
|
"svelte-katex": "^0.1.2",
|
||||||
"svelte-media-queries": "^1.6.2",
|
"svelte-media-queries": "^1.6.2",
|
||||||
"theme-change": "^2.5.0"
|
"theme-change": "^2.5.0",
|
||||||
|
"zod": "^4.1.11"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-auto": "^3.0.0",
|
"@sveltejs/adapter-auto": "^3.0.0",
|
||||||
|
|
@ -3808,6 +3809,15 @@
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.2.tgz",
|
||||||
"integrity": "sha512-rAbqEGa8ovJy4pyBxZM70hg4pE6gDgaQ0Sl9M3enG3I0d6H4XSAM3GeNGLKnsBpuijUow064sf7ww1nutC5/3w=="
|
"integrity": "sha512-rAbqEGa8ovJy4pyBxZM70hg4pE6gDgaQ0Sl9M3enG3I0d6H4XSAM3GeNGLKnsBpuijUow064sf7ww1nutC5/3w=="
|
||||||
|
},
|
||||||
|
"node_modules/zod": {
|
||||||
|
"version": "4.1.11",
|
||||||
|
"resolved": "https://registry.npmjs.org/zod/-/zod-4.1.11.tgz",
|
||||||
|
"integrity": "sha512-WPsqwxITS2tzx1bzhIKsEs19ABD5vmCVa4xBo2tq/SrV4RNZtfws1EnCWQXM6yh8bD08a1idvkB5MZSBiZsjwg==",
|
||||||
|
"license": "MIT",
|
||||||
|
"funding": {
|
||||||
|
"url": "https://github.com/sponsors/colinhacks"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
"pocketbase": "^0.26.2",
|
"pocketbase": "^0.26.2",
|
||||||
"svelte-katex": "^0.1.2",
|
"svelte-katex": "^0.1.2",
|
||||||
"svelte-media-queries": "^1.6.2",
|
"svelte-media-queries": "^1.6.2",
|
||||||
"theme-change": "^2.5.0"
|
"theme-change": "^2.5.0",
|
||||||
|
"zod": "^4.1.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
src/env.d.ts
vendored
Normal file
10
src/env.d.ts
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
interface ImportMetaEnv {
|
||||||
|
readonly PUBLIC_URL_BASE: string;
|
||||||
|
readonly PUBLIC_POCKET_URL: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ImportMeta {
|
||||||
|
readonly env: ImportMetaEnv;
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
import fly from "@e/fly";
|
import fly from "@e/fly";
|
||||||
import MediaQuery from "svelte-media-queries";
|
import MediaQuery from "svelte-media-queries";
|
||||||
import Dices from "@lucide/svelte/icons/dices";
|
import Dices from "@lucide/svelte/icons/dices";
|
||||||
|
import { re } from "@ts/Redaction/Redactor";
|
||||||
let hideOnPrint: boolean = $state(false);
|
let hideOnPrint: boolean = $state(false);
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
|
|
@ -26,7 +27,9 @@
|
||||||
afterNavigate(() => {
|
afterNavigate(() => {
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
hideOnPrint = params.get("hideOnPrint") === "1";
|
hideOnPrint = params.get("hideOnPrint") === "1";
|
||||||
// console.log(hideOnPrint);
|
if (!!params.get("key")) {
|
||||||
|
localStorage.setItem("key", params.get("key")!);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
import onMount from "@e/onMount";
|
import onMount from "@e/onMount";
|
||||||
|
|
@ -37,6 +40,7 @@
|
||||||
const lock = document.createElement("meta");
|
const lock = document.createElement("meta");
|
||||||
lock.name = "darkreader-lock";
|
lock.name = "darkreader-lock";
|
||||||
document.head.appendChild(lock);
|
document.head.appendChild(lock);
|
||||||
|
re.TryGetUnredacter();
|
||||||
});
|
});
|
||||||
|
|
||||||
function nextTheme() {
|
function nextTheme() {
|
||||||
|
|
|
||||||
50
src/ts/Redaction/Profile.ts
Normal file
50
src/ts/Redaction/Profile.ts
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
// npm i zod
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
|
const Link = z.object({
|
||||||
|
text: z.string().min(1),
|
||||||
|
link: z.string().url(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const Experience = z.object({
|
||||||
|
imageId: z.string().min(1),
|
||||||
|
name: z.string().min(1),
|
||||||
|
date: z.string().min(1),
|
||||||
|
});
|
||||||
|
|
||||||
|
const EducationLoose = z.object({
|
||||||
|
imageId: z.string().min(1).optional(),
|
||||||
|
name: z.string().min(1).optional(),
|
||||||
|
});
|
||||||
|
|
||||||
|
const ProfileSchema = z.object({
|
||||||
|
name: z.string().min(1),
|
||||||
|
shortProfileHiddenContent: z.array(z.string()),
|
||||||
|
email: z.string().email(),
|
||||||
|
phone: z.string().min(1),
|
||||||
|
linkedIn: Link,
|
||||||
|
itch: Link,
|
||||||
|
experience: z.array(Experience),
|
||||||
|
education: z
|
||||||
|
.array(EducationLoose)
|
||||||
|
.transform((arr) =>
|
||||||
|
arr.filter(
|
||||||
|
(e): e is { imageId: string; name: string } => !!e.imageId && !!e.name,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
});
|
||||||
|
|
||||||
|
export type LinkT = z.infer<typeof Link>;
|
||||||
|
export type ExperienceT = z.infer<typeof Experience>;
|
||||||
|
export type EducationT = { imageId: string; name: string };
|
||||||
|
export type Profile = Omit<z.infer<typeof ProfileSchema>, "education"> & {
|
||||||
|
education: EducationT[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export function parseProfile(json: unknown): Profile {
|
||||||
|
return ProfileSchema.parse(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
// --- usage ---
|
||||||
|
// const raw = JSON.parse(yourJsonString);
|
||||||
|
// const profile = parseProfile(raw);
|
||||||
25
src/ts/Redaction/Redactor.ts
Normal file
25
src/ts/Redaction/Redactor.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
import PocketBase from "pocketbase";
|
||||||
|
import { parseProfile, type Profile } from "./Profile";
|
||||||
|
import { PUBLIC_POCKET_URL } from "$env/static/public";
|
||||||
|
|
||||||
|
let pb = new PocketBase(PUBLIC_POCKET_URL);
|
||||||
|
|
||||||
|
class Redactor {
|
||||||
|
async TryGetUnredacter(): Promise<Profile> {
|
||||||
|
const url =
|
||||||
|
'https://pocket.deprived.dev/api/collections/redacted_content/records?page=1&perPage=1&filter=plain_id="redacted_json"&skipTotal=1';
|
||||||
|
const res = await fetch(url, {
|
||||||
|
body: localStorage.getItem("key"),
|
||||||
|
method: "GET",
|
||||||
|
});
|
||||||
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||||
|
console.log(res);
|
||||||
|
const data = await res.json();
|
||||||
|
console.log(data);
|
||||||
|
const item = data?.items?.[0];
|
||||||
|
const raw = JSON.parse(item.file);
|
||||||
|
return parseProfile(raw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export let re = new Redactor();
|
||||||
|
|
@ -3,8 +3,7 @@
|
||||||
|
|
||||||
import PocketBase from "pocketbase";
|
import PocketBase from "pocketbase";
|
||||||
import ShopItem from "./classes/ShopItem";
|
import ShopItem from "./classes/ShopItem";
|
||||||
import { env } from "$env/dynamic/public";
|
import { PUBLIC_POCKET_URL } from "$env/static/public";
|
||||||
export const PUBLIC_URL_BASE = env.PUBLIC_URL_BASE ?? "";
|
|
||||||
|
|
||||||
export let pb = new PocketBase(PUBLIC_POCKET_URL);
|
export let pb = new PocketBase(PUBLIC_POCKET_URL);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue