Compare commits

...
Sign in to create a new pull request.

94 commits

Author SHA1 Message Date
Chiara
3ff5dc80b1 changed date for newsletter
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 33s
2026-11-09 13:17:22 +01:00
Chiara
88cfc2ad28 quatschj
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 29s
Build and Deploy Astro App / build_and_deploy (push) Successful in 40s
2026-11-08 18:39:50 +01:00
Chiara
8a8628480f rechtschreibfehler 2026-11-08 18:39:12 +01:00
Chiara
9174d26959 last review and images 2026-11-08 18:36:39 +01:00
Chiara
868539cfad Merge branch 'reactions' into artikel/erste_fahrt 2026-11-08 18:01:04 +01:00
Chiara
1bdc48f5c9 Reaction Button Styling 2026-11-08 17:53:48 +01:00
Chiara
3178ccac2f Textkorrektur 2026-11-08 17:02:19 +01:00
Chiara
bf5e594ed1 Alttexte 2026-11-08 16:59:43 +01:00
Chiara
9ca26d6980 Korrektur 2026-11-04 14:25:41 +01:00
Chiara
ea6e2a8382 Erste Fahrt 2026-11-03 15:09:11 +01:00
Chiara
36c983d0b2 Bilder einfügen 2026-11-03 15:09:00 +01:00
Chiara
c4babe243f Erste Fahrt weitergeschrieben 2026-11-02 16:36:46 +01:00
Chiara
7a2a68a03a Bilder erste Fahrt 2026-11-02 16:36:35 +01:00
f6b382e04d Vorschreiben 2026-10-26 12:00:50 +01:00
c1400a2876 Struktur 2026-10-26 10:00:41 +01:00
Chiara
e43a68a0ae Bilder
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 29s
2026-10-23 13:09:13 +02:00
Chiara
c0d8d9ca41 spelling 2026-10-23 13:04:22 +02:00
Chiara
44f5ad13f6 package upgrade 2026-10-23 12:54:35 +02:00
Chiara
d82ed055c1 alt text 2026-10-23 12:52:57 +02:00
Chiara
e10c4e2655 review 2026-10-23 12:41:11 +02:00
Chiara
103adb9857 Chiara done 2026-10-21 16:55:44 +02:00
Chiara
143b8cdae3 Back-btn zurück angepasst 2026-10-21 15:00:43 +02:00
Chiara
ad9afdd41d Titelbild in Blog größer 2026-10-21 12:30:03 +02:00
Chiara
e0aee2f227 back-btn design 2026-10-21 12:21:14 +02:00
Chiara
7c97382134 Design Anpassungen im Blogeintrag und bei Bilder Elementen 2026-10-21 12:13:59 +02:00
Chiara
b05c55dab7 Bild eingefügt 2026-10-20 18:28:23 +02:00
Chiara
58d575f4e9 Zwischenstand mit Bildern 2026-10-20 18:26:31 +02:00
16a1705d4c zwisxhenstand 2026-10-20 16:43:15 +02:00
c414e4ba77 quick fix 2
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 19s
2026-10-09 15:16:58 +02:00
2956093239 quick fix
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 19s
2026-10-09 15:13:39 +02:00
11cba5caf0 works now! 2026-10-09 14:28:30 +02:00
8c5962cf73 spelling
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 28s
2026-10-08 20:14:52 +02:00
2ef941994e Bilder richtig formatiert
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 28s
2026-10-08 20:12:16 +02:00
48a6dbe8a8 spelling
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 31s
2026-10-08 19:56:00 +02:00
Chiara
2af4401d8f Review 2026-10-08 19:54:02 +02:00
70d1f786d9 fixed redirect after action 2026-10-08 16:00:01 +02:00
ba7bdd2726 überarbeitung 2026-10-08 15:52:02 +02:00
44a3e20199 Bilder eingefügt 2026-10-08 14:59:46 +02:00
f6900a7837 Rohfassung 2026-10-08 13:28:00 +02:00
0a18da80c2 escape images with escape
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 28s
2026-10-06 20:44:57 +02:00
bb6c8ad993 optimization
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 28s
2026-10-06 20:37:53 +02:00
61cfc1bedc Chiaras Meckerei
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 32s
2026-10-06 20:20:19 +02:00
Chiara
0ea283435e welcome template
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 25s
Build and Deploy Astro App / build_and_deploy (push) Successful in 36s
2026-10-06 19:47:45 +02:00
7d256c9f3f updated links 2026-10-06 14:12:50 +02:00
1381f3fdbd forgot! 2026-10-06 14:01:20 +02:00
f59b78bdea stuff 2026-10-06 13:56:13 +02:00
Chiara
c30f6313bc new newsletter templates 2026-10-06 13:00:46 +02:00
Chiara
350fe68bf7 changed nav back
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 25s
Build and Deploy Astro App / build_and_deploy (push) Successful in 38s
2026-10-06 09:37:34 +02:00
5abed41dd6 better styling
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 31s
2026-10-05 19:14:55 +02:00
cb7a6fa891 fixed styling 2026-10-05 19:07:54 +02:00
af6decdc5f fix columns
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 31s
2026-10-05 18:05:53 +02:00
5c26f7e8da add .env
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 31s
2026-10-05 08:07:08 -07:00
8098a90d6a test
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 30s
2026-10-05 07:58:08 -07:00
300c6b3ff9 CSP angepasst
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 31s
2026-10-05 07:47:07 -07:00
155d22a9f3 fix?
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 31s
2026-10-05 07:43:38 -07:00
dc24968674 fixed stuff?
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 30s
2026-10-05 07:38:35 -07:00
a037a19abd dsd 2026-10-05 07:27:34 -07:00
64a0499911 test
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 30s
2026-10-05 16:22:39 +02:00
bc34802cd8 fixed blog centered
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 30s
2026-10-05 16:18:33 +02:00
58b8d8e18e deleted faulty file
All checks were successful
Build and Deploy Astro App / build_and_deploy (push) Successful in 31s
2026-10-05 16:11:27 +02:00
38f1e1ca41 user error
Some checks failed
Build and Deploy Astro App / build_and_deploy (push) Failing after 26s
Build and Deploy Backend / build_and_deploy (push) Successful in 24s
2026-10-05 16:07:52 +02:00
8529176fb9 datenschutz angepasst 2026-10-05 15:51:53 +02:00
b6c839d99f fixed shit 2026-10-05 15:45:38 +02:00
778bcfd6bd small fixes 2026-10-05 15:32:44 +02:00
a6a0b7ab26 styling done 2026-10-05 15:26:31 +02:00
b1349a7892 design works 2026-10-05 15:09:45 +02:00
fd081f1c6f large preview mobile 2026-10-05 14:25:57 +02:00
1db2fbca86 largePreview done 2026-10-05 14:24:22 +02:00
440f0c40e5 deleted leftovers 2026-10-05 14:10:29 +02:00
525116eb78 header simplyfied 2026-10-05 14:07:14 +02:00
c36c7179cf logo color fixed 2026-10-05 13:54:23 +02:00
c69bd172c4 introduction eingefügt 2026-10-05 13:39:02 +02:00
6e0e4ab636 works now 2026-10-05 13:17:55 +02:00
f44012353d order and background on mobile 2026-10-05 12:33:03 +02:00
8d9cdc92d5 somewhat there 2026-10-05 09:48:56 +02:00
572a62eda2 transformed mobile header 2026-10-05 09:09:55 +02:00
1c7d906dba styling user stuff 2026-10-05 08:35:29 +02:00
a8f6b6560f user screen 2026-10-05 07:27:50 +02:00
f8738c5bef zwischenstand 2026-10-04 21:56:30 +02:00
b8abc47097 registrieren works 2026-10-04 20:39:52 +02:00
c15c671bf7 Form Template 2026-10-04 19:17:16 +02:00
6a658ef747 Login done 2026-10-04 18:32:16 +02:00
dd61486b13 color added 2026-10-04 15:20:37 +02:00
f6346f8165 user action in header 2026-10-04 15:13:06 +02:00
acd020ed3b Merge branch 'main' into dev 2026-10-04 14:41:48 +02:00
f929cb0cd8 newsletter days corrected
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 21s
2026-10-02 19:39:47 +02:00
47a71ff40b more dumbness
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 20s
2026-10-02 06:22:13 +02:00
f3da08619e fixed dumbness
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 20s
2026-10-02 06:14:40 +02:00
0d069deb34 fixed newsletter data
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 21s
2026-10-02 06:12:08 +02:00
34ed6f3144 fixed batchMail?
All checks were successful
Build and Deploy Backend / build_and_deploy (push) Successful in 20s
2026-10-02 06:00:53 +02:00
badfcfc43b aktueller Stand API integration 2026-09-30 16:29:07 +02:00
89e2b480a2 Merge branch 'main' into dev 2026-09-30 09:05:37 +02:00
6f666984c8 delete all chache files from git 2026-09-29 10:29:21 +02:00
e3f91514ed ignore pyc files 2026-09-29 10:23:54 +02:00
151 changed files with 3038 additions and 1507 deletions

11
.vscode/settings.json vendored
View file

@ -1,15 +1,24 @@
{ {
"cSpell.language": "en,de-DE", "cSpell.language": "en,de-DE",
"cSpell.words": [ "cSpell.words": [
"Bilgenpumpe",
"Bugstrahlruder",
"Chiara", "Chiara",
"Folierung",
"dotenv", "dotenv",
"Elli",
"Folierung",
"Hobbithöhle", "Hobbithöhle",
"Klampen",
"mailtrap", "mailtrap",
"Masala", "Masala",
"mausis",
"Pomorie", "Pomorie",
"Reinke", "Reinke",
"rundgelutschte", "rundgelutschte",
"Törnplanung",
"Trintella",
"uuidv",
"Uvendeli",
"vergenusswurzeln" "vergenusswurzeln"
], ],
"python.testing.pytestArgs": [ "python.testing.pytestArgs": [

Binary file not shown.

Binary file not shown.

View file

@ -18,6 +18,7 @@ dependencies = [
"feedparser==6.0.14", "feedparser==6.0.14",
"PyJWT==2.15.0", "PyJWT==2.15.0",
"python-dotenv>=1.0.0", "python-dotenv>=1.0.0",
"validators>=0.35.0",
] ]
[project.scripts] [project.scripts]

View file

@ -1,5 +1,5 @@
BACKEND_URL="http://localhost:8000" BACKEND_URL="http://localhost:8000"
FRONTEND_URL="http://localhost:4321" FRONTEND_URL="http://localhost:4322"
JWT_SECRET="IamALocalSecretAndMustBeReplacedInProduction" JWT_SECRET="IamALocalSecretAndMustBeReplacedInProduction"
ENVIRONMENT="local" ENVIRONMENT="local"
MAILTRAP_API_TOKEN="FakedyFake" MAILTRAP_API_TOKEN="FakedyFake"

View file

@ -30,8 +30,10 @@ security = HTTPBearer()
def get_token(credentials = Security(security)) -> str: def get_token(credentials = Security(security)) -> str:
parts = credentials.credentials.split() parts = credentials.credentials.split()
if len(parts) == 2 and parts[0].lower() == "bearer": if parts[0].lower() == "bearer":
return parts[1] return parts[1]
else:
return parts[0]
raise HTTPException(status_code=403, detail="Invalid authorization format") raise HTTPException(status_code=403, detail="Invalid authorization format")
def decode_token(token: str)-> str | None: def decode_token(token: str)-> str | None:

View file

@ -1,10 +1,6 @@
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=[

View file

@ -6,21 +6,25 @@
</head> </head>
<body> <body>
<div> <div id="card">
<h1>Neuer Artikel:</h1> <div class="center"">
<h3>{{data.title}}</h3> <img src=" https://blauwasser-mausis.de/BWM_512.webp">
<h4>{{data.subtitle}}</h4> </div>
<h4 class="accent">Neuer Artikel</h4>
<p>{{data.date}} | Autor: {{data.author}} | Lesezeit: {{data.time2read}} min</p>
<h1>{{data.title}}</h1>
<h2>{{data.subtitle}}</h2>
<p>{{data.description}}</p> <p>{{data.description}}</p>
<a href={{data.link}}> <a href={{data.link}}>
<button>Zum Artikel</button> <button>⚓︎ Zum Artikel</button>
</a> </a>
<hr>
<div class="center"><a id="hide" href="https://blauwasser-mausis.de/user">
<span>Abbestellen</span>
</a></p>
</div>
<a href="https://blauwasser-mausis.de/blog/bootsuche-england"> <a id="admin" href="https://backend.blauwasser-mausis.de/admin/newsletter/{{data.secret}}">Approve</a>
<span>Abbestellen</span>
</a>
<a id="admin" href="https://backend.blauwasser-mausis.de/?secret={{data.secret}}">Approve</a>
</div> </div>
</body> </body>
@ -35,18 +39,54 @@
} }
div { #card {
display: flex; background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
align-items: center; padding: 16px 32px;
flex-direction: column; border-radius: 8px;
background-color: lightgrey;
padding: 32px 64px;
border-radius: 3px;
} }
.center {
display: flex;
flex-direction: row;
justify-content: center;
}
img {
width: 88px;
padding: 0 0 16px 0;
}
h1,
h2,
h3, h3,
h4 { h4,
margin: 0; p {
color: white;
}
.accent {
color: #ffff00;
font-weight: 600;
}
#hide {
color: #bbbebf;
font-size: 12px;
font-weight: 700;
}
h1,
h2,
h3,
h4,
p,
hr {
margin: 16px 0 16px 0;
}
p {
line-height: 1.5;
font-size: 14px;
} }
button { button {
@ -54,6 +94,14 @@
background-color: azure; background-color: azure;
border-radius: 3px; border-radius: 3px;
border: none; border: none;
font-weight: 700;
color: #1d3238;
margin: 16px 0 24px 0;
width: 100%;
}
hr {
width: 100%;
} }
#admin { #admin {

View file

@ -6,19 +6,23 @@
</head> </head>
<body> <body>
<div> <div id="card">
<h1>Neuer Artikel:</h1> <div class="center"">
<h3>{{data.title}}</h3> <img src=" https://blauwasser-mausis.de/BWM_512.webp">
<h4>{{data.subtitle}}</h4> </div>
<p>{{data.description}}</p> <h4 class="accent">Neuer Artikel</h4>
<p>{{data.article.date}} | Autor: {{data.article.author}} | Lesezeit: {{data.article.time2read}} min</p>
<a href={{data.link}}> <h1>{{data.article.title}}</h1>
<button>Zum Artikel</button> <h2>{{data.article.subtitle}}</h2>
</a> <p>{{data.article.description}}</p>
<a href={{data.article.link}}>
<a href="https://blauwasser-mausis.de/blog/bootsuche-england"> <button>⚓︎ Zum Artikel</button>
<span>Abbestellen</span>
</a> </a>
<hr>
<div class="center"><a id="hide" href="https://blauwasser-mausis.de/user">
<span>Abbestellen</span>
</a></p>
</div>
</div> </div>
</body> </body>
@ -33,18 +37,54 @@
} }
div { #card {
display: flex; background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
align-items: center; padding: 16px 32px;
flex-direction: column; border-radius: 8px;
background-color: lightgrey;
padding: 32px 64px;
border-radius: 3px;
} }
.center {
display: flex;
flex-direction: row;
justify-content: center;
}
img {
width: 88px;
padding: 0 0 16px 0;
}
h1,
h2,
h3, h3,
h4 { h4,
margin: 0; p {
color: white;
}
.accent {
color: #ffff00;
font-weight: 600;
}
#hide {
color: #bbbebf;
font-size: 12px;
font-weight: 700;
}
h1,
h2,
h3,
h4,
p,
hr {
margin: 16px 0 16px 0;
}
p {
line-height: 1.5;
font-size: 14px;
} }
button { button {
@ -52,5 +92,13 @@
background-color: azure; background-color: azure;
border-radius: 3px; border-radius: 3px;
border: none; border: none;
font-weight: 700;
color: #1d3238;
margin: 16px 0 24px 0;
width: 100%;
}
hr {
width: 100%;
} }
</style> </style>

View file

@ -6,15 +6,30 @@
</head> </head>
<body> <body>
<div> <div id="card">
<h1>Willkommen, {{data.name}}</h1> <div class="center"">
<p>Du hast dich bei Blauwasser-Mausis.de angemeldet. Solltest du das nicht gewesen sein, dann lösche die Daten einfach über den untenstehenden Link.</p> <img src="https://blauwasser-mausis.de/BWM_512.webp">
</div>
<p>Dein persönlicher Code, um alle Funktionen nutzen zu können: {{data.user_code}}</p> <div>
<p id="welcome"><strong>⚓︎ Willkommen {{data.name}},</strong> du hast dich erfolgreich registriert.</p>
<a href="https://blauwasser-mausis.de/"> <p id="code-text">Dein persönlicher Code zum Anmelden: </p>
<span>Daten löschen</span> <p class="accent">{{data.user_code}}</p>
</a> <p id="info-text">Du erhälst nun eine Mail, wenn wir einen neuen Artikel veröffentlichen. Auch die
zukünftigen Features des Blogs (z.B. Kommentare) kannst du so nutzen.
<br />
Alle Einstellung kannst du jederzeit in deinem Profil anpassen.
</p>
<a href="https://blauwasser-mausis.de/login">
<button>⚓︎ Jetzt einloggen ⚓︎</button>
</a>
</div>
<hr>
<div class="center">
<p class="hide">Du hast dich nicht registriert? Einfach <a class="hide"
href="https://blauwasser-mausis.de/user">hier</a>
löschen. </p>
</div>
</div>
</div> </div>
</body> </body>
@ -29,12 +44,70 @@
} }
div { #card {
background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
padding: 16px 32px;
border-radius: 8px;
}
.center {
display: flex; display: flex;
align-items: center; flex-direction: row;
flex-direction: column; justify-content: center;
background-color: lightgrey; }
padding: 32px 64px;
img {
width: 88px;
padding: 0 0 16px 0;
}
p {
color: white;
}
#welcome {
padding-bottom: 8px;
font-size: 1.1rem;
}
#code-text {
margin: 0;
}
.accent {
color: #ffff00;
font-weight: 600;
padding: 0px;
margin: 0;
font-size: 1.4rem;
}
#info-text {
padding-top: 12px;
}
p {
line-height: 1.5;
font-size: 0.9rem;
}
button {
padding: 12px;
background-color: azure;
border-radius: 3px; border-radius: 3px;
border: none;
font-weight: 700;
color: #1d3238;
margin: 16px 0 24px 0;
width: 100%;
}
hr {
width: 100%;
color: white;
}
.hide {
color: #bbbebf;
} }
</style> </style>

View file

@ -1,3 +1,5 @@
from mailtrap import Address
from mailtrap import BatchMail
from pathlib import Path from pathlib import Path
from backend.config import MAILTRAP_API_TOKEN from backend.config import MAILTRAP_API_TOKEN
from mailtrap import BatchEmailRequest from mailtrap import BatchEmailRequest
@ -10,21 +12,27 @@ from jinja2 import Environment, FileSystemLoader
APP_ROOT = Path(__file__).resolve().parent.parent APP_ROOT = Path(__file__).resolve().parent.parent
class ArticleData(): class ArticleData():
def __init__(self, title, subtitle, description, link): def __init__(self, title, subtitle, description, link, date, author, time2read):
self.title=title self.title=title
self.subtitle=subtitle self.subtitle=subtitle
self.description=description self.description=description
self.link=link self.link=link
self.date=date
self.author=author
self.time2read = time2read
title: str title: str
subtitle: str subtitle: str
description: str description: str
link: str link: str
date: str
author: str
time2read: str
class AdminApprovalData(ArticleData): class AdminApprovalData(ArticleData):
def __init__(self,title, subtitle, description, link, secret): def __init__(self,title, subtitle, description, link, date, author, time2read, secret):
ArticleData.__init__(self, title, subtitle, description, link) ArticleData.__init__(self, title, subtitle, description, link, date, author, time2read)
self.secret = secret self.secret = secret
secret: str secret: str
@ -36,7 +44,7 @@ def create_html_from_template(template_name: str, data):
return template.render(data=data) return template.render(data=data)
def send_newsletter_admin_approval(data: ArticleData ): def send_newsletter_admin_approval(data: ArticleData):
html = create_html_from_template("approval", data) html = create_html_from_template("approval", data)
mail = mt.Mail( mail = mt.Mail(
@ -64,13 +72,11 @@ def send_batch_mail(mails: list[BatchEmailRequest]):
else: else:
client = mt.MailtrapClient(token=MAILTRAP_API_TOKEN) client = mt.MailtrapClient(token=MAILTRAP_API_TOKEN)
params = BatchSendEmailParams( params = BatchSendEmailParams(
base={ base=BatchMail(
"from": { sender=Address(
"name": "Blauwasser Mausis", email="newsletter@blauwasser-mausis.de",
"email": "newsletter@blauwasser-mausis.de" name="Blauwasser Mausis"),
}, subject="Flaschenpost | Blauwasser Mausis"),
"subject": "Flaschenpost | Blauwasser Mausis",
},
requests=mails requests=mails
) )
client.batch_send(params) client.batch_send(params)

View file

@ -1,4 +1,3 @@
from feedparser import FeedParserDict from feedparser import FeedParserDict
from backend.config import FRONTEND_URL from backend.config import FRONTEND_URL
from backend.internal.authentication import create_access_token from backend.internal.authentication import create_access_token
@ -13,15 +12,17 @@ def check_blog_rss_and_send_admin_mail():
for article in feed.entries: for article in feed.entries:
date_string = str(article["published"]) date_string = str(article["published"])
date_object = datetime.strptime(date_string, '%a, %d %b %Y %H:%M:%S %Z') date_object = datetime.strptime(date_string, '%a, %d %b %Y %H:%M:%S %Z')
if date_object > (datetime.now() - timedelta(days=1)):
if date_object > (datetime.now() - timedelta(days=16)):
title = str(article["title"]) title = str(article["title"])
description = str(article["summary"]) description = str(article["summary"])
subtitle = str(article["subtitle"]) subtitle = str(article["subtitle"])
link = str(article["link"]) link = str(article["link"])
author = str(article["author"])
time2read = str(article["time2read"])
date = date_object.strftime('%d.%m.%y')
secret = create_access_token({"sub": title}) secret = create_access_token({"sub": title})
data = AdminApprovalData(title, subtitle, description, link, secret) data = AdminApprovalData(title, subtitle, description, link, date, author, time2read, secret)
send_newsletter_admin_approval(data) send_newsletter_admin_approval(data)
def find_article_by_title(title: str) -> FeedParserDict | None: def find_article_by_title(title: str) -> FeedParserDict | None:

View file

@ -1,8 +1,7 @@
from dotenv.main import load_dotenv from dotenv.main import load_dotenv
load_dotenv() load_dotenv()
from .routers import users, comments, newsletters, health from .routers import users, comments, newsletters, health, reactions
from backend.internal.database import create_db_and_tables from backend.internal.database import create_db_and_tables
from fastapi import FastAPI from fastapi import FastAPI
from fastapi_crons import Crons from fastapi_crons import Crons
@ -11,7 +10,7 @@ from backend.internal.rss_reader import check_blog_rss_and_send_admin_mail
app = FastAPI() app = FastAPI()
crons = Crons(app) crons = Crons(app)
@crons.cron("0 14 * * *", name="RSS-Check") @crons.cron("0 13 * * *", name="RSS-Check")
async def check_for_new_article(): async def check_for_new_article():
check_blog_rss_and_send_admin_mail() check_blog_rss_and_send_admin_mail()
@ -23,5 +22,6 @@ def on_startup():
app.include_router(users.router) app.include_router(users.router)
app.include_router(comments.router) app.include_router(comments.router)
app.include_router(reactions.router)
app.include_router(newsletters.router) app.include_router(newsletters.router)
app.include_router(health.router) app.include_router(health.router)

View file

@ -3,3 +3,17 @@
#Reference: https://isaacfei.com/posts/simple-like-system/ #Reference: https://isaacfei.com/posts/simple-like-system/
from sqlmodel import UUID
import uuid
from sqlmodel import table
from dataclasses import dataclass
from sqlmodel import Field
from sqlmodel import SQLModel
class BaseReaction(SQLModel):
pass
@dataclass
class Reaction(BaseReaction, table=True):
slug: str = Field(primary_key=True)
browser_id: str = Field(primary_key=True)

View file

@ -1,12 +1,8 @@
from sqlmodel._compat import ConfigDict
from uuid import uuid7
from datetime import datetime from datetime import datetime
from backend.internal.user_code_gen import generate_user_code from backend.internal.user_code_gen import generate_user_code
import uuid import uuid
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from sqlmodel import Field from sqlmodel import Relationship, SQLModel, Field
from sqlmodel import Relationship
from sqlmodel import SQLModel
if TYPE_CHECKING: if TYPE_CHECKING:
from backend.models.comment import Comment from backend.models.comment import Comment
@ -18,7 +14,7 @@ class User(UserBase, table=True):
id: uuid.UUID = Field(default_factory=uuid.uuid7, primary_key=True) id: uuid.UUID = Field(default_factory=uuid.uuid7, primary_key=True)
email: str = Field(unique=True) email: str = Field(unique=True)
name: str = Field(unique=True) name: str = Field(unique=True)
user_code: str = Field(default_factory=generate_user_code,unique=True) user_code: str = Field(default_factory=generate_user_code, unique=True)
subscription: bool = Field() subscription: bool = Field()
created_at: datetime = Field(default_factory=datetime.now) created_at: datetime = Field(default_factory=datetime.now)

View file

@ -1,6 +1,6 @@
from fastapi import APIRouter from fastapi import APIRouter
router = APIRouter() router = APIRouter(tags=["health"])
@router.get("/health", include_in_schema=False) @router.get("/health", include_in_schema=False)

View file

@ -1,7 +1,7 @@
from datetime import datetime
from mailtrap import Address from mailtrap import Address
from backend.internal.mail_util import create_html_from_template from backend.internal.mail_util import create_html_from_template
from mailtrap import BatchEmailRequest from mailtrap import BatchEmailRequest
from mailtrap import BatchMail
from backend.internal.mail_util import send_batch_mail from backend.internal.mail_util import send_batch_mail
from starlette.status import HTTP_400_BAD_REQUEST from starlette.status import HTTP_400_BAD_REQUEST
from fastapi import HTTPException from fastapi import HTTPException
@ -22,7 +22,8 @@ router = APIRouter(
) )
@router.post( @router.post(
path="/approve", path="/approve",
tags=["newsletter"],
status_code=201 status_code=201
) )
def approve_newsletter(secret: str = Form(), session: Session = Depends(get_session)): def approve_newsletter(secret: str = Form(), session: Session = Depends(get_session)):
@ -30,11 +31,21 @@ def approve_newsletter(secret: str = Form(), session: Session = Depends(get_sess
if title is not None: if title is not None:
article = find_article_by_title(title) article = find_article_by_title(title)
if article is not None: if article is not None:
date_object = datetime.strptime(str(article["published"]), '%a, %d %b %Y %H:%M:%S %Z')
article_data = {
"title": article["title"],
"subtitle": article["subtitle"],
"description": article["summary"],
"link": article["link"],
"author": article["author"],
"time2read": article["time2read"],
"date": date_object.strftime('%d.%m.%y'),
}
subscribed_users = session.exec(select(User).where(User.subscription == True)) subscribed_users = session.exec(select(User).where(User.subscription == True))
mails: list[BatchEmailRequest] = [] mails: list[BatchEmailRequest] = []
for user in subscribed_users: for user in subscribed_users:
html = create_html_from_template("newsletter", user) html = create_html_from_template("newsletter", {"user": user, "article": article_data })
mail = BatchEmailRequest(to=[Address(email=user.email,name=user.name)],html=html) mail = BatchEmailRequest(to=[Address(email=user.email,name=user.name)], html=html)
mails.append(mail) mails.append(mail)
send_batch_mail(mails) send_batch_mail(mails)

View file

@ -1,5 +1,50 @@
from os import stat
from sqlmodel import select
from starlette.status import HTTP_400_BAD_REQUEST
from fastapi import HTTPException
from backend.models.reaction import Reaction
from backend.internal.database import get_session
from fastapi import Depends
from sqlmodel import Session
from fastapi import APIRouter
router = APIRouter(
prefix="/reactions",
tags=["reactions"]
)
@router.post("", status_code=201)
def create_reaction(reaction: Reaction, session: Session = Depends(get_session)):
print(reaction)
try:
session.add(reaction)
session.commit()
except Exception as e:
print(e)
session.rollback()
raise HTTPException(HTTP_400_BAD_REQUEST)
# addReaction @router.get("/{slug}", status_code=200)
# delete Reaction def get_reaction_count_for_post(slug: str, session: Session = Depends(get_session))-> int:
# get Reactions by slug reactions = session.exec(select(Reaction).where(Reaction.slug == slug)).all()
print(reactions)
return len(reactions)
@router.get("/", status_code=200)
def have_i_reacted(slug:str, browser_id: str, session: Session = Depends(get_session)) -> bool:
result = session.exec(select(Reaction).where(Reaction.slug == slug, Reaction.browser_id == browser_id)).one_or_none()
if (result): return True
else: return False
@router.delete("", status_code=200)
def delete_reaction(reaction: Reaction, session: Session = Depends(get_session)) :
db_reaction = session.exec(select(Reaction).where(Reaction.slug == reaction.slug, Reaction.browser_id == reaction.browser_id)).one_or_none()
try:
session.delete(db_reaction)
session.commit()
except Exception as e:
print(e)
session.rollback()
raise HTTPException(HTTP_400_BAD_REQUEST)

View file

@ -1,3 +1,6 @@
from starlette.status import HTTP_500_INTERNAL_SERVER_ERROR
import validators
from starlette.status import HTTP_406_NOT_ACCEPTABLE
from mailtrap import Address from mailtrap import Address
from backend.internal.mail_util import send_mail from backend.internal.mail_util import send_mail
from backend.internal.mail_util import create_html_from_template from backend.internal.mail_util import create_html_from_template
@ -23,7 +26,7 @@ from fastapi_limiter.depends import RateLimiter
router = APIRouter( router = APIRouter(
prefix="/users", prefix="/users",
dependencies=[], tags=["users"],
responses={404: {"description": "Not found"}}, responses={404: {"description": "Not found"}},
) )
@ -35,6 +38,12 @@ router = APIRouter(
def register_user(new_user: NewUser, session: Session = Depends(get_session)): def register_user(new_user: NewUser, session: Session = Depends(get_session)):
user = User.model_validate(new_user) user = User.model_validate(new_user)
if (user.name == ''):
raise HTTPException(HTTP_406_NOT_ACCEPTABLE, "Nutzername muss einen Wert enthalten")
elif(not validators.email(user.email)):
raise HTTPException(HTTP_406_NOT_ACCEPTABLE, "Email nicht valide")
try: try:
session.add(user) session.add(user)
session.commit() session.commit()
@ -50,14 +59,21 @@ def register_user(new_user: NewUser, session: Session = Depends(get_session)):
except IntegrityError as e: except IntegrityError as e:
session.rollback() session.rollback()
raise HTTPException(HTTP_400_BAD_REQUEST)
if ("UNIQUE" in str(e)):
if ("user.name" in str(e) or "user.email" in str(e)):
raise HTTPException(HTTP_406_NOT_ACCEPTABLE)
if ("user.user_code" in str(e)):
raise HTTPException(HTTP_500_INTERNAL_SERVER_ERROR)
else:
raise HTTPException(HTTP_400_BAD_REQUEST)
except Exception: except Exception:
session.rollback() session.rollback()
@router.post( @router.post(
path="/login", path="/login",
status_code=201, status_code=200,
dependencies=[Depends(RateLimiter(limiter=Limiter(Rate(3, Duration.SECOND * 30))))] dependencies=[Depends(RateLimiter(limiter=Limiter(Rate(3, Duration.SECOND * 30))))]
) )
def login(user_code: str = Form(), session: Session = Depends(get_session)) -> str: def login(user_code: str = Form(), session: Session = Depends(get_session)) -> str:
@ -78,26 +94,28 @@ def forgot_user_code(email: str = Form(), session: Session = Depends(get_session
pass # TODO: send Mail pass # TODO: send Mail
@router.get(path="/me", status_code=201) @router.get(path="/me", status_code=200)
def get_current_user_info(current_user: User = Depends(get_current_user)) -> UserInfo: def get_current_user_info(current_user: User = Depends(get_current_user)) -> UserInfo:
return UserInfo.model_validate(current_user) return UserInfo.model_validate(current_user)
@router.delete(path="/me", status_code=201) @router.delete(path="/me", status_code=200)
def delete(current_user: User = Depends(get_current_user), session: Session = Depends(get_session)) : def delete(current_user: User = Depends(get_current_user), session: Session = Depends(get_session)) :
session.delete(current_user) session.delete(current_user)
session.commit() session.commit()
@router.put(path="/me/subscribe", status_code=201) @router.put(path="/me/subscription", status_code=200)
def change_subscription( def change_subscription(
subscription: bool = Form(), subscription: bool = Form(),
current_user: User = Depends(get_current_user), current_user: User = Depends(get_current_user),
session: Session = Depends(get_session) session: Session = Depends(get_session)
): ):
current_user.subscription = subscription current_user.subscription = subscription
session.add(current_user) session.add(current_user)
session.commit() session.commit()
session.refresh(current_user)
# TODO: # TODO:

11
backend/uv.lock generated
View file

@ -202,6 +202,7 @@ dependencies = [
{ name = "pytest" }, { name = "pytest" },
{ name = "python-dotenv" }, { name = "python-dotenv" },
{ name = "sqlmodel" }, { name = "sqlmodel" },
{ name = "validators" },
] ]
[package.metadata] [package.metadata]
@ -216,6 +217,7 @@ requires-dist = [
{ name = "pytest", specifier = ">=9.1.1" }, { name = "pytest", specifier = ">=9.1.1" },
{ name = "python-dotenv", specifier = ">=1.0.0" }, { name = "python-dotenv", specifier = ">=1.0.0" },
{ name = "sqlmodel", specifier = ">=0.0.42" }, { name = "sqlmodel", specifier = ">=0.0.42" },
{ name = "validators", specifier = ">=0.35.0" },
] ]
[[package]] [[package]]
@ -1894,6 +1896,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/e4/16/c1fd27e9549f3c4baf1dc9c20c456cd2f822dbf8de9f463824b0c0357e06/uvloop-0.22.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:6cde23eeda1a25c75b2e07d39970f3374105d5eafbaab2a4482be82f272d5a5e", size = 4296730, upload-time = "2025-10-16T22:17:00.744Z" }, { url = "https://files.pythonhosted.org/packages/e4/16/c1fd27e9549f3c4baf1dc9c20c456cd2f822dbf8de9f463824b0c0357e06/uvloop-0.22.1-cp314-cp314t-musllinux_1_2_x86_64.whl", hash = "sha256:6cde23eeda1a25c75b2e07d39970f3374105d5eafbaab2a4482be82f272d5a5e", size = 4296730, upload-time = "2025-10-16T22:17:00.744Z" },
] ]
[[package]]
name = "validators"
version = "0.35.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/53/66/a435d9ae49850b2f071f7ebd8119dd4e84872b01630d6736761e6e7fd847/validators-0.35.0.tar.gz", hash = "sha256:992d6c48a4e77c81f1b4daba10d16c3a9bb0dbb79b3a19ea847ff0928e70497a", size = 73399, upload-time = "2025-05-01T05:42:06.7Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/fa/6e/3e955517e22cbdd565f2f8b2e73d52528b14b8bcfdb04f62466b071de847/validators-0.35.0-py3-none-any.whl", hash = "sha256:e8c947097eae7892cb3d26868d637f79f47b4a0554bc6b80065dfe5aac3705dd", size = 44712, upload-time = "2025-05-01T05:42:04.203Z" },
]
[[package]] [[package]]
name = "watchfiles" name = "watchfiles"
version = "1.2.0" version = "1.2.0"

1
blog/.env.production Normal file
View file

@ -0,0 +1 @@
PUBLIC_API_URL="https://api.blauwasser-mausis.de"

1
blog/.gitignore vendored
View file

@ -15,7 +15,6 @@ pnpm-debug.log*
# environment variables # environment variables
.env .env
.env.production
# macOS-specific files # macOS-specific files
.DS_Store .DS_Store

View file

@ -15,24 +15,32 @@ All commands are run from the root of the project, from a terminal:
## Bilder für Webuseage convertieren ## Bilder für Webuseage convertieren
`for file in *.{jpg,png}; magick "$file" -resize 50% "$file"; end` ```
for file in *.{jpg,png}; magick "$file" -resize 50% "$file"; end
```
`magick mogrify -format webp -quality 80 *.{jpg,png}` ```
magick mogrify -format webp -quality 80 *.{jpg,png}
```
`for file in *.{jpg,png}; magick "$file" -auto-orient "$file"; end` ```
for file in *.{jpg,png}; magick "$file" -auto-orient "$file"; end
```
## Vorlage für MDX-Artikel ## Vorlage für MDX-Artikel
```
--- ---
title: title:
subtitle: subtitle:
description: description:
introduction:
image: image:
path: titelbild_artikelordner.webp path: titelbild_artikelordner.webp
alt: alt:
author: Bernd das Brot author: Bernd das Brot
date: 2026-08-29 date: 2026-11-10
slug: Wie-soll-die-URL-aussehen? slug: Wie-soll-die-URL-aussehen?
time2read: 0 time2read: 0
--- ---
@ -40,14 +48,17 @@ import BlogLink from '../../components/blog/BlogLink.astro'
import SingleImage from '../../components/blog/SingleImage.astro' import SingleImage from '../../components/blog/SingleImage.astro'
import DoubleImage from '../../components/blog/DoubleImage.astro' import DoubleImage from '../../components/blog/DoubleImage.astro'
Hier kann man in den Artikel einleiten.<br />
Evtl. ist es das gleiche wie die Beschreibung. <br />
## Große Überschrift für einen Abschnitt
Textus schreibus.
--- ---
<br /> <br />
## Große Überschrift für einen Abschnitt ## Große Überschrift für einen Abschnitt
Textus schreibus . Textus schreibus.
@ -77,4 +88,5 @@ Lorem Ipsum
alt2="" alt2=""
description="" description=""
/> />
<BlogLink text="Lorem Ipsum" url="https://www.loremipsum.com/" /> <BlogLink url="https://www.loremipsum.com/">Text</BlogLink>
```

View file

@ -1,6 +1,7 @@
// @ts-check // @ts-check
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx'; import mdx from '@astrojs/mdx';
import preact from '@astrojs/preact';
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
@ -9,5 +10,5 @@ export default defineConfig({
build: { build: {
assets: '_assets', assets: '_assets',
}, },
integrations: [mdx()] integrations: [mdx(), preact()]
}); });

1960
blog/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -13,9 +13,15 @@
}, },
"dependencies": { "dependencies": {
"@astrojs/mdx": "^7.0.8", "@astrojs/mdx": "^7.0.8",
"@astrojs/preact": "^6.0.2", "@astrojs/preact": "^6.0.5",
"@astrojs/rss": "^4.0.19", "@astrojs/rss": "^4.0.19",
"@types/uuid": "^10.0.0",
"astro": "^7.2.2", "astro": "^7.2.2",
"preact": "^10.29.0" "jwt-decode": "^4.0.0",
"preact": "^10.29.8",
"uuid": "^14.0.2"
},
"devDependencies": {
"@types/jsonwebtoken": "^9.0.10"
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 328 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 381 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 412 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 456 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 462 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 687 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 322 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 289 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

After

Width:  |  Height:  |  Size: 703 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 MiB

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 350 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 750 KiB

After

Width:  |  Height:  |  Size: 268 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 KiB

After

Width:  |  Height:  |  Size: 103 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 MiB

After

Width:  |  Height:  |  Size: 747 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 451 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 MiB

After

Width:  |  Height:  |  Size: 718 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 745 KiB

After

Width:  |  Height:  |  Size: 227 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 668 KiB

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Some files were not shown because too many files have changed in this diff Show more