Compare commits
No commits in common. "350fe68bf72516ea4f07a89799728e16c154afae" and "38f1e1ca41f164f6ca2a2d0c72e960bb993c8b19" have entirely different histories.
350fe68bf7
...
38f1e1ca41
21 changed files with 97 additions and 91 deletions
|
|
@ -1,6 +1,10 @@
|
|||
from backend.main import app
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
origins = [
|
||||
"http://localhost",
|
||||
]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=[
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
PUBLIC_API_URL="https://api.blauwasser-mausis.de"
|
||||
1
blog/.gitignore
vendored
1
blog/.gitignore
vendored
|
|
@ -15,6 +15,7 @@ pnpm-debug.log*
|
|||
|
||||
# environment variables
|
||||
.env
|
||||
.env.production
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
||||
|
|
|
|||
13
blog/package-lock.json
generated
13
blog/package-lock.json
generated
|
|
@ -5,7 +5,6 @@
|
|||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "blog",
|
||||
"version": "0.0.1",
|
||||
"dependencies": {
|
||||
"@astrojs/mdx": "^7.0.8",
|
||||
|
|
@ -6362,9 +6361,9 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/smol-toml": {
|
||||
"version": "1.9.0",
|
||||
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.9.0.tgz",
|
||||
"integrity": "sha512-hpd+HLON7HdZXqYchMM/+LaTTbdK0AU3NngIJ4KVyWbY9bfQqdL9cD+4yf6dUoU2Ap4VsU0JkQi6FxAI1B2mXQ==",
|
||||
"version": "1.8.0",
|
||||
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.8.0.tgz",
|
||||
"integrity": "sha512-kCZr2V3ch9i00x8zXRhjUNVcjG9ijES5dDudkXvUVCT5QlJNQWElSJdZqyPemffHoLNUYwOcou0Fy+ojN0uHSQ==",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">= 18"
|
||||
|
|
@ -6383,9 +6382,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/source-map-js": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",
|
||||
"integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==",
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,11 @@ const { posts } = Astro.props;
|
|||
---
|
||||
|
||||
<div class="post-grid">
|
||||
{posts.map((post_file: any) => <PostPreviewSmall post={post_file.data} />)}
|
||||
{
|
||||
posts.map((post_file: any) => (
|
||||
<PostPreviewSmall post={post_file.data} />
|
||||
))
|
||||
}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
|
|
@ -17,6 +21,6 @@ const { posts } = Astro.props;
|
|||
display: grid;
|
||||
gap: 64px;
|
||||
width: 100%;
|
||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||
grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import { useState } from "preact/hooks";
|
||||
import { api } from "../lib/api";
|
||||
import { handleBackAndReload, logout } from "./Util";
|
||||
import { logout } from "./Util";
|
||||
import type { JSX } from "preact/jsx-runtime";
|
||||
import { navigate } from "astro/virtual-modules/transitions-router.js";
|
||||
|
||||
export default function DeleteUser() {
|
||||
const [error, setError] = useState('');
|
||||
|
|
@ -20,7 +21,7 @@ export default function DeleteUser() {
|
|||
} finally {
|
||||
if (!hasError) {
|
||||
logout()
|
||||
handleBackAndReload()
|
||||
navigate("/")
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useEffect, useState } from 'preact/hooks';
|
||||
import { api, AUTH_TOKEN_KEY } from '../lib/api';
|
||||
import { handleBackAndReload, saveUser } from './Util';
|
||||
import { api, AUTH_TOKEN_KEY, USER_KEY, type User } from '../lib/api';
|
||||
import { saveUser } from './Util';
|
||||
|
||||
export default function LoginForm() {
|
||||
const [userCode, setUserCode] = useState('');
|
||||
|
|
@ -33,7 +33,7 @@ export default function LoginForm() {
|
|||
}
|
||||
hasError = true
|
||||
} finally {
|
||||
if (!hasError) handleBackAndReload()
|
||||
if (!hasError) navigation.back()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import { handleBackAndReload } from "./Util";
|
||||
|
||||
export default function NavBack() {
|
||||
|
||||
function take_me_to_the_moon() {
|
||||
navigation.back();
|
||||
}
|
||||
|
||||
return (
|
||||
<button class="back-btn" onClick={handleBackAndReload}>Zurück</button>
|
||||
<button class="back-btn" onClick={take_me_to_the_moon}>Zurück</button>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useState } from 'preact/hooks';
|
||||
import { api, type User } from '../lib/api';
|
||||
import React from 'preact/compat';
|
||||
import { handleBackAndReload, isEmailValid } from './Util';
|
||||
import { isEmailValid } from './Util';
|
||||
|
||||
export default function RegisterForm() {
|
||||
const [user, setUser] = React.useState<User>({ 'email': '', 'name': '', 'subscription': true });
|
||||
|
|
@ -31,7 +31,7 @@ export default function RegisterForm() {
|
|||
}
|
||||
hasError = true
|
||||
} finally {
|
||||
if (!hasError) handleBackAndReload()
|
||||
if (!hasError) navigation.back()
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +0,0 @@
|
|||
type SubmitProps = {
|
||||
eventString: string;
|
||||
text: string;
|
||||
};
|
||||
|
||||
export default function Submit({ eventString, text }: SubmitProps) {
|
||||
function handleClick() {
|
||||
window.dispatchEvent(new Event(`submit-${eventString}`));
|
||||
}
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleClick}
|
||||
className="submit-btn"
|
||||
>
|
||||
⚓︎ {text}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,28 +1,27 @@
|
|||
import { jwtDecode } from "jwt-decode"
|
||||
import { AUTH_TOKEN_KEY, USER_KEY, type User } from "../lib/api"
|
||||
import { navigate } from "astro:transitions/client"
|
||||
|
||||
export function saveUser(user: User) {
|
||||
localStorage.setItem(USER_KEY, JSON.stringify(user))
|
||||
localStorage.setItem(USER_KEY, JSON.stringify(user))
|
||||
}
|
||||
|
||||
export function getUser(): User | null {
|
||||
checkJWTValidity()
|
||||
checkJWTValidity()
|
||||
|
||||
const user_string = localStorage.getItem(USER_KEY)
|
||||
if (user_string) return JSON.parse(user_string) as User
|
||||
else logout()
|
||||
return null
|
||||
const user_string = localStorage.getItem(USER_KEY)
|
||||
if (user_string) return JSON.parse(user_string) as User
|
||||
else logout()
|
||||
return null
|
||||
}
|
||||
|
||||
export function logout() {
|
||||
localStorage.removeItem(USER_KEY)
|
||||
localStorage.removeItem(AUTH_TOKEN_KEY)
|
||||
localStorage.removeItem(USER_KEY)
|
||||
localStorage.removeItem(AUTH_TOKEN_KEY)
|
||||
}
|
||||
|
||||
export function isEmailValid(email: string): boolean {
|
||||
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||||
return emailRegex.test(email);
|
||||
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
|
||||
return emailRegex.test(email);
|
||||
}
|
||||
|
||||
export function checkJWTValidity() {
|
||||
|
|
@ -40,13 +39,4 @@ export function isTokenExpired(token: string): boolean {
|
|||
} catch {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
export const handleBackAndReload = () => {
|
||||
if (document.referrer) {
|
||||
navigate(document.referrer, { history: 'replace' });
|
||||
setTimeout(() => window.location.reload(), 50);
|
||||
} else {
|
||||
navigate('/');
|
||||
}
|
||||
};
|
||||
}
|
||||
13
blog/src/islands/auth.server.tsx
Normal file
13
blog/src/islands/auth.server.tsx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import jwt from 'jsonwebtoken';
|
||||
|
||||
const isTokenExpired = (token: string): boolean => {
|
||||
try {
|
||||
const { exp } = jwt.decode(token) as { exp: number };
|
||||
const expirationDatetimeInSeconds = exp * 1000;
|
||||
return Date.now() >= expirationDatetimeInSeconds;
|
||||
} catch {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
export { isTokenExpired };
|
||||
|
|
@ -34,7 +34,7 @@ const localeDate = formatLocalizedDateString(postData.date);
|
|||
</div>
|
||||
<article class="markdown-content">
|
||||
<slot />
|
||||
<NavBack client:load />
|
||||
<NavBack client:visible />
|
||||
<p class="disclaimer">
|
||||
Disclaimer: Dieser Artikel ist ausschließlich privat und wird nicht
|
||||
durch Produktplatzierung, Affiliate-Links oder ähnliches Unterstützt.
|
||||
|
|
@ -52,9 +52,6 @@ const localeDate = formatLocalizedDateString(postData.date);
|
|||
|
||||
<style>
|
||||
#background {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
background-image: linear-gradient(
|
||||
to bottom,
|
||||
var(--primary-dark),
|
||||
|
|
@ -66,10 +63,9 @@ const localeDate = formatLocalizedDateString(postData.date);
|
|||
}
|
||||
|
||||
#hr-knast {
|
||||
padding: 16px 64px 0 64px;
|
||||
padding: 16px 64px 0 64px ;
|
||||
background-color: white;
|
||||
max-width: 900px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
hr {
|
||||
|
|
@ -108,6 +104,16 @@ const localeDate = formatLocalizedDateString(postData.date);
|
|||
line-height: 1.6;
|
||||
}
|
||||
|
||||
#header #title {
|
||||
font-size: 2.5rem;
|
||||
padding: 0 64px;
|
||||
}
|
||||
|
||||
#header #subtitle {
|
||||
font-size: 1.8rem;
|
||||
padding: 0 64px;
|
||||
}
|
||||
|
||||
.info {
|
||||
padding: 32px 64px 0 64px;
|
||||
font-size: medium;
|
||||
|
|
@ -117,16 +123,12 @@ const localeDate = formatLocalizedDateString(postData.date);
|
|||
#title {
|
||||
margin-bottom: 0;
|
||||
order: 3;
|
||||
font-size: 2.5rem;
|
||||
padding: 0 64px;
|
||||
}
|
||||
|
||||
#subtitle {
|
||||
margin-top: 0;
|
||||
font-weight: lighter;
|
||||
order: 4;
|
||||
font-size: 1.8rem;
|
||||
padding: 0 64px;
|
||||
}
|
||||
|
||||
#introduction {
|
||||
|
|
@ -200,9 +202,8 @@ const localeDate = formatLocalizedDateString(postData.date);
|
|||
.info {
|
||||
order: 1;
|
||||
font-size: 1rem !important;
|
||||
padding-top: 16px !important;
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
padding: 0 24px;
|
||||
}
|
||||
|
||||
#title-img {
|
||||
|
|
@ -212,22 +213,15 @@ const localeDate = formatLocalizedDateString(postData.date);
|
|||
#title {
|
||||
margin: 0;
|
||||
order: 2;
|
||||
padding: 0 24px;
|
||||
}
|
||||
|
||||
#subtitle {
|
||||
order: 3;
|
||||
padding: 0 24px;
|
||||
}
|
||||
|
||||
#introduction {
|
||||
font-size: 1.25rem !important;
|
||||
order: 5;
|
||||
padding: 32px 24px 0 24px;
|
||||
}
|
||||
|
||||
article {
|
||||
padding: 0 24px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
---
|
||||
import NavBack from "../islands/NavBack";
|
||||
import Submit from "../islands/Submit";
|
||||
import Main from "../layouts/Main.astro";
|
||||
|
||||
const { title, subtitle, text, buttonText, eventString } = Astro.props;
|
||||
|
|
@ -17,7 +16,12 @@ const { title, subtitle, text, buttonText, eventString } = Astro.props;
|
|||
<slot />
|
||||
<div id="buttons">
|
||||
<NavBack client:load />
|
||||
<Submit eventString={eventString} text={buttonText} client:load />
|
||||
<button
|
||||
onclick={`window.dispatchEvent(new Event("${eventString}"))`}
|
||||
class="submit-btn"
|
||||
>
|
||||
⚓︎ {buttonText}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@ import "../styles/global.css";
|
|||
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta
|
||||
charset="utf-8"
|
||||
/>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
<link
|
||||
rel="alternate"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
export function formatLocalizedDateString(date: Date): string {
|
||||
var options: Intl.DateTimeFormatOptions = { weekday: undefined, year: '2-digit', month: '2-digit', day: '2-digit' };
|
||||
return date.toLocaleDateString('de-DE', options)
|
||||
return date.toLocaleDateString('de-DE')
|
||||
}
|
||||
18
blog/src/pages/admin/newsletter/[secret].astro
Normal file
18
blog/src/pages/admin/newsletter/[secret].astro
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
import { api } from '../../../lib/api';
|
||||
|
||||
const { secret } = Astro.props;
|
||||
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const response = await api.approveNewsletter(secret);
|
||||
|
||||
return response.map(product => ({
|
||||
params: { id: product.id },
|
||||
props: { product }
|
||||
}));
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
<h1>{product.name}</h1>
|
||||
|
|
@ -10,7 +10,7 @@ import Form from "../layouts/Form.astro";
|
|||
Code ein, denn du nach dem registrieren via E-Mail erhalten
|
||||
hast."
|
||||
buttonText="Anmelden"
|
||||
eventString="login"
|
||||
eventString="submit-login"
|
||||
>
|
||||
<LoginForm client:load />
|
||||
<a href="/register">Noch keinen Account? Hier registrieren</a>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import Form from "../layouts/Form.astro";
|
|||
subtitle="E-Mail Erinnerung für neue Artikel"
|
||||
text="Endlich könnt E-Mail Erinnerungen erhalten, wenn wir neue Artikel veröffentlichen. Für die spätere Kommentarfunktion fragen wir gleich den Namen mit ab."
|
||||
buttonText="Registrieren"
|
||||
eventString="register"
|
||||
eventString="submit-register"
|
||||
>
|
||||
<RegisterForm client:load/>
|
||||
</Form>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import Form from "../layouts/Form.astro";
|
|||
subtitle="Hier kannst du dein Konto verwalten."
|
||||
text=""
|
||||
buttonText="Speichern"
|
||||
eventString="toggle-subscription"
|
||||
eventString="submit-toggle-subscription"
|
||||
>
|
||||
<UserDetails client:load />
|
||||
<ToggleSubscription client:load />
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ body {
|
|||
flex-direction: column;
|
||||
flex: 1;
|
||||
padding: 0;
|
||||
min-width: 350px;
|
||||
min-width: 380px;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue