chore: format

This commit is contained in:
2025-10-10 16:43:21 +02:00
parent f0aabd63b6
commit 75c29e0ba4
551 changed files with 433948 additions and 94145 deletions

View File

@@ -1,46 +1,48 @@
<script lang="ts">
import { _ } from 'svelte-i18n';
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle
} from '$lib/components/ui/dialog';
import { Button } from '$lib/components/ui/button';
import { Separator } from '$lib/components/ui/separator';
import type { Snippet } from 'svelte';
import Label from '../ui/label/label.svelte';
import Input from '../ui/input/input.svelte';
import { toast } from 'svelte-sonner';
import { _ } from "svelte-i18n";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "$lib/components/ui/dialog";
import { Button } from "$lib/components/ui/button";
import { Separator } from "$lib/components/ui/separator";
import type { Snippet } from "svelte";
import Label from "../ui/label/label.svelte";
import Input from "../ui/input/input.svelte";
import { toast } from "svelte-sonner";
interface Props {
open: boolean;
email: string;
children?: Snippet;
}
interface Props {
open: boolean;
email: string;
children?: Snippet;
}
let isLoading = $state(false);
let isLoading = $state(false);
async function handleSubscription(e: Event) {
e.preventDefault();
try {
isLoading = true;
await fetch("/newsletter", {
method: "POST",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({email})
})
toast.success($_('newsletter_signup.toast_subscribe', { values: { email } }));
} finally {
isLoading = false;
open = false;
}
}
async function handleSubscription(e: Event) {
e.preventDefault();
try {
isLoading = true;
await fetch("/newsletter", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ email }),
});
toast.success(
$_("newsletter_signup.toast_subscribe", { values: { email } }),
);
} finally {
isLoading = false;
open = false;
}
}
let { open = $bindable(), email = $bindable() }: Props = $props();
let { open = $bindable(), email = $bindable() }: Props = $props();
</script>
<Dialog bind:open>

View File

@@ -1,11 +1,11 @@
<script>
import { _ } from 'svelte-i18n';
import { Button } from '../ui/button';
import { Card, CardContent } from '../ui/card';
import NewsletterSignupPopup from './newsletter-signup-popup.svelte';
let isPopupOpen = $state(false);
import { _ } from "svelte-i18n";
import { Button } from "../ui/button";
import { Card, CardContent } from "../ui/card";
import NewsletterSignupPopup from "./newsletter-signup-popup.svelte";
let isPopupOpen = $state(false);
let {email = ""} = $props();
let { email = "" } = $props();
</script>
<!-- Newsletter Signup -->

View File

@@ -841,7 +841,7 @@ export default {
close: "Close",
subscribe: "Subscribe",
subscribing: "Subscribing",
toast_subscribe: "Your email has been added to the newsletter list!"
toast_subscribe: "Your email has been added to the newsletter list!",
},
sharing_popup_button: {
share: "Share",

View File

@@ -2,7 +2,10 @@ import { error } from "@sveltejs/kit";
import { getArticleBySlug } from "$lib/services.js";
export async function load({ fetch, params, locals }) {
try {
return { article: await getArticleBySlug(params.slug, fetch), authStatus: locals.authStatus };
return {
article: await getArticleBySlug(params.slug, fetch),
authStatus: locals.authStatus,
};
} catch {
error(404, "Article not found");
}

View File

@@ -1,19 +1,22 @@
import { LETTERSPACE_API_KEY, LETTERSPACE_API_URL, LETTERSPACE_LIST_ID } from '$env/static/private';
import { json } from '@sveltejs/kit';
import {
LETTERSPACE_API_KEY,
LETTERSPACE_API_URL,
LETTERSPACE_LIST_ID,
} from "$env/static/private";
import { json } from "@sveltejs/kit";
export async function POST({ request, fetch }) {
const { email } = await request.json();
const lists = [LETTERSPACE_LIST_ID];
const { email } = await request.json();
const lists = [LETTERSPACE_LIST_ID];
await fetch(`${LETTERSPACE_API_URL}/subscribers`, {
method: "POST",
headers: {
'Content-Type': 'application/json',
'X-API-Key': LETTERSPACE_API_KEY
},
body: JSON.stringify({ email, lists })
});
await fetch(`${LETTERSPACE_API_URL}/subscribers`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": LETTERSPACE_API_KEY,
},
body: JSON.stringify({ email, lists }),
});
return json({ email }, { status: 201 });
}
return json({ email }, { status: 201 });
}

View File

@@ -1,69 +1,69 @@
<script lang="ts">
import { _ } from 'svelte-i18n';
import { goto } from '$app/navigation';
import { Button } from '$lib/components/ui/button';
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle
} from '$lib/components/ui/card';
import { Input } from '$lib/components/ui/input';
import { Label } from '$lib/components/ui/label';
import { Checkbox } from '$lib/components/ui/checkbox';
import { toast } from 'svelte-sonner';
import * as Alert from '$lib/components/ui/alert';
import PeonyIcon from '$lib/components/icon/peony-icon.svelte';
import { register } from '$lib/services';
import PeonyBackground from '$lib/components/background/peony-background.svelte';
import Meta from '$lib/components/meta/meta.svelte';
import { onMount } from 'svelte';
import Logo from '$lib/components/logo/logo.svelte';
import { _ } from "svelte-i18n";
import { goto } from "$app/navigation";
import { Button } from "$lib/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "$lib/components/ui/card";
import { Input } from "$lib/components/ui/input";
import { Label } from "$lib/components/ui/label";
import { Checkbox } from "$lib/components/ui/checkbox";
import { toast } from "svelte-sonner";
import * as Alert from "$lib/components/ui/alert";
import PeonyIcon from "$lib/components/icon/peony-icon.svelte";
import { register } from "$lib/services";
import PeonyBackground from "$lib/components/background/peony-background.svelte";
import Meta from "$lib/components/meta/meta.svelte";
import { onMount } from "svelte";
import Logo from "$lib/components/logo/logo.svelte";
let firstName = $state('');
let lastName = $state('');
let email = $state('');
let password = $state('');
let confirmPassword = $state('');
let showPassword = $state(false);
let showConfirmPassword = $state(false);
let agreeTerms = $state(false);
let isLoading = $state(false);
let isError = $state(false);
let error = $state('');
let firstName = $state("");
let lastName = $state("");
let email = $state("");
let password = $state("");
let confirmPassword = $state("");
let showPassword = $state(false);
let showConfirmPassword = $state(false);
let agreeTerms = $state(false);
let isLoading = $state(false);
let isError = $state(false);
let error = $state("");
async function handleSubmit(e: Event) {
e.preventDefault();
try {
if (!agreeTerms) {
throw new Error($_('auth.signup.agree_error'));
}
if (password !== confirmPassword) {
throw new Error($_('auth.signup.password_error'));
}
isLoading = true;
isError = false;
error = '';
await register(email, password, firstName, lastName);
toast.success($_('auth.signup.toast_register', { values: { email } }));
goto('/login');
} catch (err: any) {
error = err.message;
isError = true;
} finally {
isLoading = false;
}
}
async function handleSubmit(e: Event) {
e.preventDefault();
try {
if (!agreeTerms) {
throw new Error($_("auth.signup.agree_error"));
}
if (password !== confirmPassword) {
throw new Error($_("auth.signup.password_error"));
}
isLoading = true;
isError = false;
error = "";
await register(email, password, firstName, lastName);
toast.success($_("auth.signup.toast_register", { values: { email } }));
goto("/login");
} catch (err: any) {
error = err.message;
isError = true;
} finally {
isLoading = false;
}
}
const { data } = $props();
const { data } = $props();
onMount(() => {
if (!data.authStatus.authenticated) {
return;
}
goto('/me');
});
onMount(() => {
if (!data.authStatus.authenticated) {
return;
}
goto("/me");
});
</script>
<Meta

View File

@@ -1,66 +1,65 @@
<script lang="ts">
import { _ } from 'svelte-i18n';
import { Button } from '$lib/components/ui/button';
import { Card, CardContent } from '$lib/components/ui/card';
import { Input } from '$lib/components/ui/input';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger
} from '$lib/components/ui/select';
import { getAssetUrl } from '$lib/directus';
import Meta from '$lib/components/meta/meta.svelte';
import TimeAgo from 'javascript-time-ago';
import { formatVideoDuration } from '$lib/utils';
import { _ } from "svelte-i18n";
import { Button } from "$lib/components/ui/button";
import { Card, CardContent } from "$lib/components/ui/card";
import { Input } from "$lib/components/ui/input";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
} from "$lib/components/ui/select";
import { getAssetUrl } from "$lib/directus";
import Meta from "$lib/components/meta/meta.svelte";
import TimeAgo from "javascript-time-ago";
import { formatVideoDuration } from "$lib/utils";
const timeAgo = new TimeAgo('en');
const timeAgo = new TimeAgo("en");
let searchQuery = $state('');
let sortBy = $state('trending');
let categoryFilter = $state('all');
let durationFilter = $state('all');
let searchQuery = $state("");
let sortBy = $state("trending");
let categoryFilter = $state("all");
let durationFilter = $state("all");
const { data } = $props();
const { data } = $props();
const filteredVideos = $derived(() => {
return data.videos
.filter((video) => {
const matchesSearch = video.title
.toLowerCase()
.includes(searchQuery.toLowerCase());
// ||
// video.model.toLowerCase().includes(searchQuery.toLowerCase());
const matchesCategory = categoryFilter === 'all';
const matchesDuration =
durationFilter === 'all' ||
(durationFilter === 'short' && video.movie.duration < 10 * 60) ||
(durationFilter === 'medium' &&
video.movie.duration >= 10 * 60 &&
video.movie.duration < 20 * 60) ||
(durationFilter === 'long' && video.movie.duration >= 20 * 60);
return matchesSearch && matchesCategory && matchesDuration;
})
.sort((a, b) => {
// if (sortBy === "trending")
// return (
// parseInt(b.views.replace(/[^\d]/g, "")) -
// parseInt(a.views.replace(/[^\d]/g, ""))
// );
if (sortBy === 'recent')
return (
new Date(b.upload_date).getTime() -
new Date(a.upload_date).getTime()
);
// if (sortBy === "popular")
// return (
// parseInt(b.likes.replace(/[^\d]/g, "")) -
// parseInt(a.likes.replace(/[^\d]/g, ""))
// );
if (sortBy === 'duration') return b.movie.duration - a.movie.duration;
return a.title.localeCompare(b.title);
});
});
const filteredVideos = $derived(() => {
return data.videos
.filter((video) => {
const matchesSearch = video.title
.toLowerCase()
.includes(searchQuery.toLowerCase());
// ||
// video.model.toLowerCase().includes(searchQuery.toLowerCase());
const matchesCategory = categoryFilter === "all";
const matchesDuration =
durationFilter === "all" ||
(durationFilter === "short" && video.movie.duration < 10 * 60) ||
(durationFilter === "medium" &&
video.movie.duration >= 10 * 60 &&
video.movie.duration < 20 * 60) ||
(durationFilter === "long" && video.movie.duration >= 20 * 60);
return matchesSearch && matchesCategory && matchesDuration;
})
.sort((a, b) => {
// if (sortBy === "trending")
// return (
// parseInt(b.views.replace(/[^\d]/g, "")) -
// parseInt(a.views.replace(/[^\d]/g, ""))
// );
if (sortBy === "recent")
return (
new Date(b.upload_date).getTime() - new Date(a.upload_date).getTime()
);
// if (sortBy === "popular")
// return (
// parseInt(b.likes.replace(/[^\d]/g, "")) -
// parseInt(a.likes.replace(/[^\d]/g, ""))
// );
if (sortBy === "duration") return b.movie.duration - a.movie.duration;
return a.title.localeCompare(b.title);
});
});
</script>
<Meta title={$_('videos.title')} description={$_('videos.description')} />