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 backend.main import app
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
|
origins = [
|
||||||
|
"http://localhost",
|
||||||
|
]
|
||||||
|
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
CORSMiddleware,
|
CORSMiddleware,
|
||||||
allow_origins=[
|
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
|
# environment variables
|
||||||
.env
|
.env
|
||||||
|
.env.production
|
||||||
|
|
||||||
# macOS-specific files
|
# macOS-specific files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
|
||||||
13
blog/package-lock.json
generated
13
blog/package-lock.json
generated
|
|
@ -5,7 +5,6 @@
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "blog",
|
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/mdx": "^7.0.8",
|
"@astrojs/mdx": "^7.0.8",
|
||||||
|
|
@ -6362,9 +6361,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/smol-toml": {
|
"node_modules/smol-toml": {
|
||||||
"version": "1.9.0",
|
"version": "1.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/smol-toml/-/smol-toml-1.8.0.tgz",
|
||||||
"integrity": "sha512-hpd+HLON7HdZXqYchMM/+LaTTbdK0AU3NngIJ4KVyWbY9bfQqdL9cD+4yf6dUoU2Ap4VsU0JkQi6FxAI1B2mXQ==",
|
"integrity": "sha512-kCZr2V3ch9i00x8zXRhjUNVcjG9ijES5dDudkXvUVCT5QlJNQWElSJdZqyPemffHoLNUYwOcou0Fy+ojN0uHSQ==",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 18"
|
"node": ">= 18"
|
||||||
|
|
@ -6383,9 +6382,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/source-map-js": {
|
"node_modules/source-map-js": {
|
||||||
"version": "1.2.2",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",
|
||||||
"integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==",
|
"integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",
|
||||||
"license": "BSD-3-Clause",
|
"license": "BSD-3-Clause",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,11 @@ const { posts } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<div class="post-grid">
|
<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>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -17,6 +21,6 @@ const { posts } = Astro.props;
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 64px;
|
gap: 64px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
import { api } from "../lib/api";
|
import { api } from "../lib/api";
|
||||||
import { handleBackAndReload, logout } from "./Util";
|
import { logout } from "./Util";
|
||||||
import type { JSX } from "preact/jsx-runtime";
|
import type { JSX } from "preact/jsx-runtime";
|
||||||
|
import { navigate } from "astro/virtual-modules/transitions-router.js";
|
||||||
|
|
||||||
export default function DeleteUser() {
|
export default function DeleteUser() {
|
||||||
const [error, setError] = useState('');
|
const [error, setError] = useState('');
|
||||||
|
|
@ -20,7 +21,7 @@ export default function DeleteUser() {
|
||||||
} finally {
|
} finally {
|
||||||
if (!hasError) {
|
if (!hasError) {
|
||||||
logout()
|
logout()
|
||||||
handleBackAndReload()
|
navigate("/")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { useEffect, useState } from 'preact/hooks';
|
import { useEffect, useState } from 'preact/hooks';
|
||||||
import { api, AUTH_TOKEN_KEY } from '../lib/api';
|
import { api, AUTH_TOKEN_KEY, USER_KEY, type User } from '../lib/api';
|
||||||
import { handleBackAndReload, saveUser } from './Util';
|
import { saveUser } from './Util';
|
||||||
|
|
||||||
export default function LoginForm() {
|
export default function LoginForm() {
|
||||||
const [userCode, setUserCode] = useState('');
|
const [userCode, setUserCode] = useState('');
|
||||||
|
|
@ -33,7 +33,7 @@ export default function LoginForm() {
|
||||||
}
|
}
|
||||||
hasError = true
|
hasError = true
|
||||||
} finally {
|
} finally {
|
||||||
if (!hasError) handleBackAndReload()
|
if (!hasError) navigation.back()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import { handleBackAndReload } from "./Util";
|
|
||||||
|
|
||||||
export default function NavBack() {
|
export default function NavBack() {
|
||||||
|
|
||||||
|
function take_me_to_the_moon() {
|
||||||
|
navigation.back();
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
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 { useEffect, useState } from 'preact/hooks';
|
||||||
import { api, type User } from '../lib/api';
|
import { api, type User } from '../lib/api';
|
||||||
import React from 'preact/compat';
|
import React from 'preact/compat';
|
||||||
import { handleBackAndReload, isEmailValid } from './Util';
|
import { isEmailValid } from './Util';
|
||||||
|
|
||||||
export default function RegisterForm() {
|
export default function RegisterForm() {
|
||||||
const [user, setUser] = React.useState<User>({ 'email': '', 'name': '', 'subscription': true });
|
const [user, setUser] = React.useState<User>({ 'email': '', 'name': '', 'subscription': true });
|
||||||
|
|
@ -31,7 +31,7 @@ export default function RegisterForm() {
|
||||||
}
|
}
|
||||||
hasError = true
|
hasError = true
|
||||||
} finally {
|
} 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,6 +1,5 @@
|
||||||
import { jwtDecode } from "jwt-decode"
|
import { jwtDecode } from "jwt-decode"
|
||||||
import { AUTH_TOKEN_KEY, USER_KEY, type User } from "../lib/api"
|
import { AUTH_TOKEN_KEY, USER_KEY, type User } from "../lib/api"
|
||||||
import { navigate } from "astro:transitions/client"
|
|
||||||
|
|
||||||
export function saveUser(user: User) {
|
export function saveUser(user: User) {
|
||||||
localStorage.setItem(USER_KEY, JSON.stringify(user))
|
localStorage.setItem(USER_KEY, JSON.stringify(user))
|
||||||
|
|
@ -41,12 +40,3 @@ export function isTokenExpired(token: string): boolean {
|
||||||
return true
|
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>
|
</div>
|
||||||
<article class="markdown-content">
|
<article class="markdown-content">
|
||||||
<slot />
|
<slot />
|
||||||
<NavBack client:load />
|
<NavBack client:visible />
|
||||||
<p class="disclaimer">
|
<p class="disclaimer">
|
||||||
Disclaimer: Dieser Artikel ist ausschließlich privat und wird nicht
|
Disclaimer: Dieser Artikel ist ausschließlich privat und wird nicht
|
||||||
durch Produktplatzierung, Affiliate-Links oder ähnliches Unterstützt.
|
durch Produktplatzierung, Affiliate-Links oder ähnliches Unterstützt.
|
||||||
|
|
@ -52,9 +52,6 @@ const localeDate = formatLocalizedDateString(postData.date);
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#background {
|
#background {
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
flex-direction: column;
|
|
||||||
background-image: linear-gradient(
|
background-image: linear-gradient(
|
||||||
to bottom,
|
to bottom,
|
||||||
var(--primary-dark),
|
var(--primary-dark),
|
||||||
|
|
@ -69,7 +66,6 @@ const localeDate = formatLocalizedDateString(postData.date);
|
||||||
padding: 16px 64px 0 64px ;
|
padding: 16px 64px 0 64px ;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
max-width: 900px;
|
max-width: 900px;
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hr {
|
hr {
|
||||||
|
|
@ -108,6 +104,16 @@ const localeDate = formatLocalizedDateString(postData.date);
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#header #title {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
padding: 0 64px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header #subtitle {
|
||||||
|
font-size: 1.8rem;
|
||||||
|
padding: 0 64px;
|
||||||
|
}
|
||||||
|
|
||||||
.info {
|
.info {
|
||||||
padding: 32px 64px 0 64px;
|
padding: 32px 64px 0 64px;
|
||||||
font-size: medium;
|
font-size: medium;
|
||||||
|
|
@ -117,16 +123,12 @@ const localeDate = formatLocalizedDateString(postData.date);
|
||||||
#title {
|
#title {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
order: 3;
|
order: 3;
|
||||||
font-size: 2.5rem;
|
|
||||||
padding: 0 64px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#subtitle {
|
#subtitle {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
font-weight: lighter;
|
font-weight: lighter;
|
||||||
order: 4;
|
order: 4;
|
||||||
font-size: 1.8rem;
|
|
||||||
padding: 0 64px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#introduction {
|
#introduction {
|
||||||
|
|
@ -200,9 +202,8 @@ const localeDate = formatLocalizedDateString(postData.date);
|
||||||
.info {
|
.info {
|
||||||
order: 1;
|
order: 1;
|
||||||
font-size: 1rem !important;
|
font-size: 1rem !important;
|
||||||
padding-top: 16px !important;
|
padding-top: 16px;
|
||||||
padding-bottom: 16px;
|
padding-bottom: 16px;
|
||||||
padding: 0 24px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#title-img {
|
#title-img {
|
||||||
|
|
@ -212,22 +213,15 @@ const localeDate = formatLocalizedDateString(postData.date);
|
||||||
#title {
|
#title {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
order: 2;
|
order: 2;
|
||||||
padding: 0 24px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#subtitle {
|
#subtitle {
|
||||||
order: 3;
|
order: 3;
|
||||||
padding: 0 24px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#introduction {
|
#introduction {
|
||||||
font-size: 1.25rem !important;
|
font-size: 1.25rem !important;
|
||||||
order: 5;
|
order: 5;
|
||||||
padding: 32px 24px 0 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
article {
|
|
||||||
padding: 0 24px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
---
|
---
|
||||||
import NavBack from "../islands/NavBack";
|
import NavBack from "../islands/NavBack";
|
||||||
import Submit from "../islands/Submit";
|
|
||||||
import Main from "../layouts/Main.astro";
|
import Main from "../layouts/Main.astro";
|
||||||
|
|
||||||
const { title, subtitle, text, buttonText, eventString } = Astro.props;
|
const { title, subtitle, text, buttonText, eventString } = Astro.props;
|
||||||
|
|
@ -17,7 +16,12 @@ const { title, subtitle, text, buttonText, eventString } = Astro.props;
|
||||||
<slot />
|
<slot />
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<NavBack client:load />
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,7 @@ import "../styles/global.css";
|
||||||
|
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta
|
<meta charset="utf-8" />
|
||||||
charset="utf-8"
|
|
||||||
/>
|
|
||||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||||
<link
|
<link
|
||||||
rel="alternate"
|
rel="alternate"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
export function formatLocalizedDateString(date: Date): string {
|
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')
|
||||||
return date.toLocaleDateString('de-DE', options)
|
|
||||||
}
|
}
|
||||||
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
|
Code ein, denn du nach dem registrieren via E-Mail erhalten
|
||||||
hast."
|
hast."
|
||||||
buttonText="Anmelden"
|
buttonText="Anmelden"
|
||||||
eventString="login"
|
eventString="submit-login"
|
||||||
>
|
>
|
||||||
<LoginForm client:load />
|
<LoginForm client:load />
|
||||||
<a href="/register">Noch keinen Account? Hier registrieren</a>
|
<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"
|
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."
|
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"
|
buttonText="Registrieren"
|
||||||
eventString="register"
|
eventString="submit-register"
|
||||||
>
|
>
|
||||||
<RegisterForm client:load/>
|
<RegisterForm client:load/>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import Form from "../layouts/Form.astro";
|
||||||
subtitle="Hier kannst du dein Konto verwalten."
|
subtitle="Hier kannst du dein Konto verwalten."
|
||||||
text=""
|
text=""
|
||||||
buttonText="Speichern"
|
buttonText="Speichern"
|
||||||
eventString="toggle-subscription"
|
eventString="submit-toggle-subscription"
|
||||||
>
|
>
|
||||||
<UserDetails client:load />
|
<UserDetails client:load />
|
||||||
<ToggleSubscription client:load />
|
<ToggleSubscription client:load />
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ body {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
min-width: 350px;
|
min-width: 380px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nav-link {
|
.nav-link {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue