Compare commits
94 commits
artikel/pr
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ff5dc80b1 | ||
|
|
88cfc2ad28 | ||
|
|
8a8628480f | ||
|
|
9174d26959 | ||
|
|
868539cfad | ||
|
|
1bdc48f5c9 | ||
|
|
3178ccac2f | ||
|
|
bf5e594ed1 | ||
|
|
9ca26d6980 | ||
|
|
ea6e2a8382 | ||
|
|
36c983d0b2 | ||
|
|
c4babe243f | ||
|
|
7a2a68a03a | ||
| f6b382e04d | |||
| c1400a2876 | |||
|
|
e43a68a0ae | ||
|
|
c0d8d9ca41 | ||
|
|
44f5ad13f6 | ||
|
|
d82ed055c1 | ||
|
|
e10c4e2655 | ||
|
|
103adb9857 | ||
|
|
143b8cdae3 | ||
|
|
ad9afdd41d | ||
|
|
e0aee2f227 | ||
|
|
7c97382134 | ||
|
|
b05c55dab7 | ||
|
|
58d575f4e9 | ||
| 16a1705d4c | |||
| c414e4ba77 | |||
| 2956093239 | |||
| 11cba5caf0 | |||
| 8c5962cf73 | |||
| 2ef941994e | |||
| 48a6dbe8a8 | |||
|
|
2af4401d8f | ||
| 70d1f786d9 | |||
| ba7bdd2726 | |||
| 44a3e20199 | |||
| f6900a7837 | |||
| 0a18da80c2 | |||
| bb6c8ad993 | |||
| 61cfc1bedc | |||
|
|
0ea283435e | ||
| 7d256c9f3f | |||
| 1381f3fdbd | |||
| f59b78bdea | |||
|
|
c30f6313bc | ||
|
|
350fe68bf7 | ||
| 5abed41dd6 | |||
| cb7a6fa891 | |||
| af6decdc5f | |||
| 5c26f7e8da | |||
| 8098a90d6a | |||
| 300c6b3ff9 | |||
| 155d22a9f3 | |||
| dc24968674 | |||
| a037a19abd | |||
| 64a0499911 | |||
| bc34802cd8 | |||
| 58b8d8e18e | |||
| 38f1e1ca41 | |||
| 8529176fb9 | |||
| b6c839d99f | |||
| 778bcfd6bd | |||
| a6a0b7ab26 | |||
| b1349a7892 | |||
| fd081f1c6f | |||
| 1db2fbca86 | |||
| 440f0c40e5 | |||
| 525116eb78 | |||
| c36c7179cf | |||
| c69bd172c4 | |||
| 6e0e4ab636 | |||
| f44012353d | |||
| 8d9cdc92d5 | |||
| 572a62eda2 | |||
| 1c7d906dba | |||
| a8f6b6560f | |||
| f8738c5bef | |||
| b8abc47097 | |||
| c15c671bf7 | |||
| 6a658ef747 | |||
| dd61486b13 | |||
| f6346f8165 | |||
| acd020ed3b | |||
| f929cb0cd8 | |||
| 47a71ff40b | |||
| f3da08619e | |||
| 0d069deb34 | |||
| 34ed6f3144 | |||
| badfcfc43b | |||
| 89e2b480a2 | |||
| 6f666984c8 | |||
| e3f91514ed |
4
.vscode/rundebug.json
vendored
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"version": 1,
|
||||
"configurations": []
|
||||
}
|
||||
11
.vscode/settings.json
vendored
|
|
@ -1,15 +1,24 @@
|
|||
{
|
||||
"cSpell.language": "en,de-DE",
|
||||
"cSpell.words": [
|
||||
"Bilgenpumpe",
|
||||
"Bugstrahlruder",
|
||||
"Chiara",
|
||||
"Folierung",
|
||||
"dotenv",
|
||||
"Elli",
|
||||
"Folierung",
|
||||
"Hobbithöhle",
|
||||
"Klampen",
|
||||
"mailtrap",
|
||||
"Masala",
|
||||
"mausis",
|
||||
"Pomorie",
|
||||
"Reinke",
|
||||
"rundgelutschte",
|
||||
"Törnplanung",
|
||||
"Trintella",
|
||||
"uuidv",
|
||||
"Uvendeli",
|
||||
"vergenusswurzeln"
|
||||
],
|
||||
"python.testing.pytestArgs": [
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ dependencies = [
|
|||
"feedparser==6.0.14",
|
||||
"PyJWT==2.15.0",
|
||||
"python-dotenv>=1.0.0",
|
||||
"validators>=0.35.0",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
BACKEND_URL="http://localhost:8000"
|
||||
FRONTEND_URL="http://localhost:4321"
|
||||
FRONTEND_URL="http://localhost:4322"
|
||||
JWT_SECRET="IamALocalSecretAndMustBeReplacedInProduction"
|
||||
ENVIRONMENT="local"
|
||||
MAILTRAP_API_TOKEN="FakedyFake"
|
||||
|
|
|
|||
|
|
@ -30,8 +30,10 @@ security = HTTPBearer()
|
|||
|
||||
def get_token(credentials = Security(security)) -> str:
|
||||
parts = credentials.credentials.split()
|
||||
if len(parts) == 2 and parts[0].lower() == "bearer":
|
||||
if parts[0].lower() == "bearer":
|
||||
return parts[1]
|
||||
else:
|
||||
return parts[0]
|
||||
raise HTTPException(status_code=403, detail="Invalid authorization format")
|
||||
|
||||
def decode_token(token: str)-> str | None:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
from backend.main import app
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
origins = [
|
||||
"http://localhost",
|
||||
]
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=[
|
||||
|
|
|
|||
|
|
@ -6,21 +6,25 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<h1>Neuer Artikel:</h1>
|
||||
<h3>{{data.title}}</h3>
|
||||
<h4>{{data.subtitle}}</h4>
|
||||
<div id="card">
|
||||
<div class="center"">
|
||||
<img src=" https://blauwasser-mausis.de/BWM_512.webp">
|
||||
</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>
|
||||
|
||||
<a href={{data.link}}>
|
||||
<button>Zum Artikel</button>
|
||||
<button>⚓︎ Zum Artikel</button>
|
||||
</a>
|
||||
|
||||
<a href="https://blauwasser-mausis.de/blog/bootsuche-england">
|
||||
<hr>
|
||||
<div class="center"><a id="hide" href="https://blauwasser-mausis.de/user">
|
||||
<span>Abbestellen</span>
|
||||
</a>
|
||||
</a></p>
|
||||
</div>
|
||||
|
||||
<a id="admin" href="https://backend.blauwasser-mausis.de/?secret={{data.secret}}">Approve</a>
|
||||
<a id="admin" href="https://backend.blauwasser-mausis.de/admin/newsletter/{{data.secret}}">Approve</a>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
|
@ -35,18 +39,54 @@
|
|||
|
||||
}
|
||||
|
||||
div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
background-color: lightgrey;
|
||||
padding: 32px 64px;
|
||||
border-radius: 3px;
|
||||
#card {
|
||||
background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
|
||||
padding: 16px 32px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 88px;
|
||||
padding: 0 0 16px 0;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4 {
|
||||
margin: 0;
|
||||
h4,
|
||||
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 {
|
||||
|
|
@ -54,6 +94,14 @@
|
|||
background-color: azure;
|
||||
border-radius: 3px;
|
||||
border: none;
|
||||
font-weight: 700;
|
||||
color: #1d3238;
|
||||
margin: 16px 0 24px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
hr {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#admin {
|
||||
|
|
|
|||
|
|
@ -6,19 +6,23 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<h1>Neuer Artikel:</h1>
|
||||
<h3>{{data.title}}</h3>
|
||||
<h4>{{data.subtitle}}</h4>
|
||||
<p>{{data.description}}</p>
|
||||
|
||||
<a href={{data.link}}>
|
||||
<button>Zum Artikel</button>
|
||||
<div id="card">
|
||||
<div class="center"">
|
||||
<img src=" https://blauwasser-mausis.de/BWM_512.webp">
|
||||
</div>
|
||||
<h4 class="accent">Neuer Artikel</h4>
|
||||
<p>{{data.article.date}} | Autor: {{data.article.author}} | Lesezeit: {{data.article.time2read}} min</p>
|
||||
<h1>{{data.article.title}}</h1>
|
||||
<h2>{{data.article.subtitle}}</h2>
|
||||
<p>{{data.article.description}}</p>
|
||||
<a href={{data.article.link}}>
|
||||
<button>⚓︎ Zum Artikel</button>
|
||||
</a>
|
||||
|
||||
<a href="https://blauwasser-mausis.de/blog/bootsuche-england">
|
||||
<hr>
|
||||
<div class="center"><a id="hide" href="https://blauwasser-mausis.de/user">
|
||||
<span>Abbestellen</span>
|
||||
</a>
|
||||
</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
|
@ -33,18 +37,54 @@
|
|||
|
||||
}
|
||||
|
||||
div {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
background-color: lightgrey;
|
||||
padding: 32px 64px;
|
||||
border-radius: 3px;
|
||||
#card {
|
||||
background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
|
||||
padding: 16px 32px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
img {
|
||||
width: 88px;
|
||||
padding: 0 0 16px 0;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4 {
|
||||
margin: 0;
|
||||
h4,
|
||||
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 {
|
||||
|
|
@ -52,5 +92,13 @@
|
|||
background-color: azure;
|
||||
border-radius: 3px;
|
||||
border: none;
|
||||
font-weight: 700;
|
||||
color: #1d3238;
|
||||
margin: 16px 0 24px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
hr {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -6,16 +6,31 @@
|
|||
</head>
|
||||
|
||||
<body>
|
||||
<div id="card">
|
||||
<div class="center"">
|
||||
<img src="https://blauwasser-mausis.de/BWM_512.webp">
|
||||
</div>
|
||||
<div>
|
||||
<h1>Willkommen, {{data.name}}</h1>
|
||||
<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>
|
||||
|
||||
<p>Dein persönlicher Code, um alle Funktionen nutzen zu können: {{data.user_code}}</p>
|
||||
|
||||
<a href="https://blauwasser-mausis.de/">
|
||||
<span>Daten löschen</span>
|
||||
<p id="welcome"><strong>⚓︎ Willkommen {{data.name}},</strong> du hast dich erfolgreich registriert.</p>
|
||||
<p id="code-text">Dein persönlicher Code zum Anmelden: </p>
|
||||
<p class="accent">{{data.user_code}}</p>
|
||||
<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>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
@ -29,12 +44,70 @@
|
|||
|
||||
}
|
||||
|
||||
div {
|
||||
#card {
|
||||
background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
|
||||
padding: 16px 32px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
background-color: lightgrey;
|
||||
padding: 32px 64px;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
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: none;
|
||||
font-weight: 700;
|
||||
color: #1d3238;
|
||||
margin: 16px 0 24px 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
hr {
|
||||
width: 100%;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.hide {
|
||||
color: #bbbebf;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
from mailtrap import Address
|
||||
from mailtrap import BatchMail
|
||||
from pathlib import Path
|
||||
from backend.config import MAILTRAP_API_TOKEN
|
||||
from mailtrap import BatchEmailRequest
|
||||
|
|
@ -10,21 +12,27 @@ from jinja2 import Environment, FileSystemLoader
|
|||
APP_ROOT = Path(__file__).resolve().parent.parent
|
||||
|
||||
class ArticleData():
|
||||
def __init__(self, title, subtitle, description, link):
|
||||
def __init__(self, title, subtitle, description, link, date, author, time2read):
|
||||
self.title=title
|
||||
self.subtitle=subtitle
|
||||
self.description=description
|
||||
self.link=link
|
||||
self.date=date
|
||||
self.author=author
|
||||
self.time2read = time2read
|
||||
|
||||
title: str
|
||||
subtitle: str
|
||||
description: str
|
||||
link: str
|
||||
date: str
|
||||
author: str
|
||||
time2read: str
|
||||
|
||||
|
||||
class AdminApprovalData(ArticleData):
|
||||
def __init__(self,title, subtitle, description, link, secret):
|
||||
ArticleData.__init__(self, title, subtitle, description, link)
|
||||
def __init__(self,title, subtitle, description, link, date, author, time2read, secret):
|
||||
ArticleData.__init__(self, title, subtitle, description, link, date, author, time2read)
|
||||
self.secret = secret
|
||||
|
||||
secret: str
|
||||
|
|
@ -36,7 +44,7 @@ def create_html_from_template(template_name: str, 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)
|
||||
|
||||
mail = mt.Mail(
|
||||
|
|
@ -64,13 +72,11 @@ def send_batch_mail(mails: list[BatchEmailRequest]):
|
|||
else:
|
||||
client = mt.MailtrapClient(token=MAILTRAP_API_TOKEN)
|
||||
params = BatchSendEmailParams(
|
||||
base={
|
||||
"from": {
|
||||
"name": "Blauwasser Mausis",
|
||||
"email": "newsletter@blauwasser-mausis.de"
|
||||
},
|
||||
"subject": "Flaschenpost | Blauwasser Mausis",
|
||||
},
|
||||
base=BatchMail(
|
||||
sender=Address(
|
||||
email="newsletter@blauwasser-mausis.de",
|
||||
name="Blauwasser Mausis"),
|
||||
subject="Flaschenpost | Blauwasser Mausis"),
|
||||
requests=mails
|
||||
)
|
||||
client.batch_send(params)
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
from feedparser import FeedParserDict
|
||||
from backend.config import FRONTEND_URL
|
||||
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:
|
||||
date_string = str(article["published"])
|
||||
date_object = datetime.strptime(date_string, '%a, %d %b %Y %H:%M:%S %Z')
|
||||
|
||||
if date_object > (datetime.now() - timedelta(days=16)):
|
||||
if date_object > (datetime.now() - timedelta(days=1)):
|
||||
title = str(article["title"])
|
||||
description = str(article["summary"])
|
||||
subtitle = str(article["subtitle"])
|
||||
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})
|
||||
|
||||
data = AdminApprovalData(title, subtitle, description, link, secret)
|
||||
data = AdminApprovalData(title, subtitle, description, link, date, author, time2read, secret)
|
||||
send_newsletter_admin_approval(data)
|
||||
|
||||
def find_article_by_title(title: str) -> FeedParserDict | None:
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
|
||||
from dotenv.main import 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 fastapi import FastAPI
|
||||
from fastapi_crons import Crons
|
||||
|
|
@ -11,7 +10,7 @@ from backend.internal.rss_reader import check_blog_rss_and_send_admin_mail
|
|||
app = FastAPI()
|
||||
crons = Crons(app)
|
||||
|
||||
@crons.cron("0 14 * * *", name="RSS-Check")
|
||||
@crons.cron("0 13 * * *", name="RSS-Check")
|
||||
async def check_for_new_article():
|
||||
check_blog_rss_and_send_admin_mail()
|
||||
|
||||
|
|
@ -23,5 +22,6 @@ def on_startup():
|
|||
|
||||
app.include_router(users.router)
|
||||
app.include_router(comments.router)
|
||||
app.include_router(reactions.router)
|
||||
app.include_router(newsletters.router)
|
||||
app.include_router(health.router)
|
||||
|
|
@ -3,3 +3,17 @@
|
|||
|
||||
#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)
|
||||
|
|
@ -1,12 +1,8 @@
|
|||
from sqlmodel._compat import ConfigDict
|
||||
from uuid import uuid7
|
||||
from datetime import datetime
|
||||
from backend.internal.user_code_gen import generate_user_code
|
||||
import uuid
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlmodel import Field
|
||||
from sqlmodel import Relationship
|
||||
from sqlmodel import SQLModel
|
||||
from sqlmodel import Relationship, SQLModel, Field
|
||||
|
||||
if TYPE_CHECKING:
|
||||
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)
|
||||
email: 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()
|
||||
created_at: datetime = Field(default_factory=datetime.now)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter()
|
||||
router = APIRouter(tags=["health"])
|
||||
|
||||
|
||||
@router.get("/health", include_in_schema=False)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime
|
||||
from mailtrap import Address
|
||||
from backend.internal.mail_util import create_html_from_template
|
||||
from mailtrap import BatchEmailRequest
|
||||
from mailtrap import BatchMail
|
||||
from backend.internal.mail_util import send_batch_mail
|
||||
from starlette.status import HTTP_400_BAD_REQUEST
|
||||
from fastapi import HTTPException
|
||||
|
|
@ -23,6 +23,7 @@ router = APIRouter(
|
|||
|
||||
@router.post(
|
||||
path="/approve",
|
||||
tags=["newsletter"],
|
||||
status_code=201
|
||||
)
|
||||
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:
|
||||
article = find_article_by_title(title)
|
||||
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))
|
||||
mails: list[BatchEmailRequest] = []
|
||||
for user in subscribed_users:
|
||||
html = create_html_from_template("newsletter", user)
|
||||
mail = BatchEmailRequest(to=[Address(email=user.email,name=user.name)],html=html)
|
||||
html = create_html_from_template("newsletter", {"user": user, "article": article_data })
|
||||
mail = BatchEmailRequest(to=[Address(email=user.email,name=user.name)], html=html)
|
||||
mails.append(mail)
|
||||
send_batch_mail(mails)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
# delete Reaction
|
||||
# get Reactions by slug
|
||||
@router.get("/{slug}", status_code=200)
|
||||
def get_reaction_count_for_post(slug: str, session: Session = Depends(get_session))-> int:
|
||||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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 backend.internal.mail_util import send_mail
|
||||
from backend.internal.mail_util import create_html_from_template
|
||||
|
|
@ -23,7 +26,7 @@ from fastapi_limiter.depends import RateLimiter
|
|||
|
||||
router = APIRouter(
|
||||
prefix="/users",
|
||||
dependencies=[],
|
||||
tags=["users"],
|
||||
responses={404: {"description": "Not found"}},
|
||||
)
|
||||
|
||||
|
|
@ -35,6 +38,12 @@ router = APIRouter(
|
|||
def register_user(new_user: NewUser, session: Session = Depends(get_session)):
|
||||
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:
|
||||
session.add(user)
|
||||
session.commit()
|
||||
|
|
@ -50,6 +59,13 @@ def register_user(new_user: NewUser, session: Session = Depends(get_session)):
|
|||
|
||||
except IntegrityError as e:
|
||||
session.rollback()
|
||||
|
||||
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:
|
||||
session.rollback()
|
||||
|
|
@ -57,7 +73,7 @@ def register_user(new_user: NewUser, session: Session = Depends(get_session)):
|
|||
|
||||
@router.post(
|
||||
path="/login",
|
||||
status_code=201,
|
||||
status_code=200,
|
||||
dependencies=[Depends(RateLimiter(limiter=Limiter(Rate(3, Duration.SECOND * 30))))]
|
||||
)
|
||||
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
|
||||
|
||||
|
||||
@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:
|
||||
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)) :
|
||||
session.delete(current_user)
|
||||
session.commit()
|
||||
|
||||
|
||||
@router.put(path="/me/subscribe", status_code=201)
|
||||
@router.put(path="/me/subscription", status_code=200)
|
||||
def change_subscription(
|
||||
subscription: bool = Form(),
|
||||
current_user: User = Depends(get_current_user),
|
||||
session: Session = Depends(get_session)
|
||||
):
|
||||
|
||||
current_user.subscription = subscription
|
||||
session.add(current_user)
|
||||
session.commit()
|
||||
session.refresh(current_user)
|
||||
|
||||
|
||||
# TODO:
|
||||
|
|
|
|||
11
backend/uv.lock
generated
|
|
@ -202,6 +202,7 @@ dependencies = [
|
|||
{ name = "pytest" },
|
||||
{ name = "python-dotenv" },
|
||||
{ name = "sqlmodel" },
|
||||
{ name = "validators" },
|
||||
]
|
||||
|
||||
[package.metadata]
|
||||
|
|
@ -216,6 +217,7 @@ requires-dist = [
|
|||
{ name = "pytest", specifier = ">=9.1.1" },
|
||||
{ name = "python-dotenv", specifier = ">=1.0.0" },
|
||||
{ name = "sqlmodel", specifier = ">=0.0.42" },
|
||||
{ name = "validators", specifier = ">=0.35.0" },
|
||||
]
|
||||
|
||||
[[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" },
|
||||
]
|
||||
|
||||
[[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]]
|
||||
name = "watchfiles"
|
||||
version = "1.2.0"
|
||||
|
|
|
|||
1
blog/.env.production
Normal file
|
|
@ -0,0 +1 @@
|
|||
PUBLIC_API_URL="https://api.blauwasser-mausis.de"
|
||||
1
blog/.gitignore
vendored
|
|
@ -15,7 +15,6 @@ pnpm-debug.log*
|
|||
|
||||
# environment variables
|
||||
.env
|
||||
.env.production
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
||||
|
|
|
|||
|
|
@ -15,24 +15,32 @@ All commands are run from the root of the project, from a terminal:
|
|||
|
||||
## 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
|
||||
|
||||
```
|
||||
---
|
||||
title:
|
||||
subtitle:
|
||||
description:
|
||||
introduction:
|
||||
image:
|
||||
path: titelbild_artikelordner.webp
|
||||
alt:
|
||||
author: Bernd das Brot
|
||||
date: 2026-08-29
|
||||
date: 2026-11-10
|
||||
slug: Wie-soll-die-URL-aussehen?
|
||||
time2read: 0
|
||||
---
|
||||
|
|
@ -40,14 +48,17 @@ import BlogLink from '../../components/blog/BlogLink.astro'
|
|||
import SingleImage from '../../components/blog/SingleImage.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 />
|
||||
## Große Überschrift für einen Abschnitt
|
||||
|
||||
Textus schreibus .
|
||||
Textus schreibus.
|
||||
|
||||
|
||||
|
||||
|
|
@ -77,4 +88,5 @@ Lorem Ipsum
|
|||
alt2=""
|
||||
description=""
|
||||
/>
|
||||
<BlogLink text="Lorem Ipsum" url="https://www.loremipsum.com/" />
|
||||
<BlogLink url="https://www.loremipsum.com/">Text</BlogLink>
|
||||
```
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
// @ts-check
|
||||
import { defineConfig } from 'astro/config';
|
||||
import mdx from '@astrojs/mdx';
|
||||
import preact from '@astrojs/preact';
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
|
|
@ -9,5 +10,5 @@ export default defineConfig({
|
|||
build: {
|
||||
assets: '_assets',
|
||||
},
|
||||
integrations: [mdx()]
|
||||
integrations: [mdx(), preact()]
|
||||
});
|
||||
|
|
|
|||
1960
blog/package-lock.json
generated
|
|
@ -13,9 +13,15 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@astrojs/mdx": "^7.0.8",
|
||||
"@astrojs/preact": "^6.0.2",
|
||||
"@astrojs/preact": "^6.0.5",
|
||||
"@astrojs/rss": "^4.0.19",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"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"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
BIN
blog/public/blog_img/der_start/Chiara_Backskiste.webp
Normal file
|
After Width: | Height: | Size: 269 KiB |
BIN
blog/public/blog_img/der_start/Deutschlandflagge_hissen.webp
Normal file
|
After Width: | Height: | Size: 282 KiB |
BIN
blog/public/blog_img/der_start/Donnerstag.webp
Normal file
|
After Width: | Height: | Size: 74 KiB |
BIN
blog/public/blog_img/der_start/Elli_Lagerbox.webp
Normal file
|
After Width: | Height: | Size: 253 KiB |
BIN
blog/public/blog_img/der_start/Elli_Lagerraum.webp
Normal file
|
After Width: | Height: | Size: 326 KiB |
BIN
blog/public/blog_img/der_start/Gate_Anzeige.webp
Normal file
|
After Width: | Height: | Size: 315 KiB |
BIN
blog/public/blog_img/der_start/Kochen.webp
Normal file
|
After Width: | Height: | Size: 169 KiB |
BIN
blog/public/blog_img/der_start/Mittwoch.webp
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
blog/public/blog_img/der_start/Neue_Batterien.webp
Normal file
|
After Width: | Height: | Size: 301 KiB |
BIN
blog/public/blog_img/der_start/Raspberry.webp
Normal file
|
After Width: | Height: | Size: 194 KiB |
BIN
blog/public/blog_img/der_start/Schlafzimmer.webp
Normal file
|
After Width: | Height: | Size: 173 KiB |
BIN
blog/public/blog_img/der_start/Sturm_freitag.webp
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
blog/public/blog_img/der_start/Such_Trintella.webp
Normal file
|
After Width: | Height: | Size: 349 KiB |
BIN
blog/public/blog_img/der_start/Tim_Toilette_reparieren.webp
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
blog/public/blog_img/der_start/Tim_Umbauarbeiten.webp
Normal file
|
After Width: | Height: | Size: 281 KiB |
BIN
blog/public/blog_img/der_start/Tim_im_Dingy.webp
Normal file
|
After Width: | Height: | Size: 302 KiB |
|
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 94 KiB |
BIN
blog/public/blog_img/der_start/Trintella_hinten.webp
Normal file
|
After Width: | Height: | Size: 328 KiB |
BIN
blog/public/blog_img/der_start/Trintella_mit_Segeln.webp
Normal file
|
After Width: | Height: | Size: 302 KiB |
BIN
blog/public/blog_img/der_start/Trintella_ohne_Segel.webp
Normal file
|
After Width: | Height: | Size: 251 KiB |
BIN
blog/public/blog_img/der_start/Trintella_seite.webp
Normal file
|
After Width: | Height: | Size: 381 KiB |
BIN
blog/public/blog_img/der_start/Verpflegung_Raynair.webp
Normal file
|
After Width: | Height: | Size: 469 KiB |
BIN
blog/public/blog_img/der_start/tim_kochen.webp
Normal file
|
After Width: | Height: | Size: 235 KiB |
BIN
blog/public/blog_img/der_start/titelbild_der_start.webp
Normal file
|
After Width: | Height: | Size: 381 KiB |
BIN
blog/public/blog_img/der_start/trintella.webp
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
blog/public/blog_img/erste_fahrt/Abend_Bradwell.webp
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
blog/public/blog_img/erste_fahrt/Backboard_Winch.webp
Normal file
|
After Width: | Height: | Size: 272 KiB |
BIN
blog/public/blog_img/erste_fahrt/Bilgenpumpe.webp
Normal file
|
After Width: | Height: | Size: 157 KiB |
BIN
blog/public/blog_img/erste_fahrt/Blockier_Winch.webp
Normal file
|
After Width: | Height: | Size: 198 KiB |
BIN
blog/public/blog_img/erste_fahrt/Chiara_Bilgenpumpe.webp
Normal file
|
After Width: | Height: | Size: 187 KiB |
BIN
blog/public/blog_img/erste_fahrt/Chiara_Fahren.webp
Normal file
|
After Width: | Height: | Size: 291 KiB |
BIN
blog/public/blog_img/erste_fahrt/Choas_Überfahrt.webp
Normal file
|
After Width: | Height: | Size: 199 KiB |
BIN
blog/public/blog_img/erste_fahrt/Fender.webp
Normal file
|
After Width: | Height: | Size: 412 KiB |
BIN
blog/public/blog_img/erste_fahrt/Fenster_1.webp
Normal file
|
After Width: | Height: | Size: 188 KiB |
BIN
blog/public/blog_img/erste_fahrt/Fenster_2.webp
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
blog/public/blog_img/erste_fahrt/Fenster_3.webp
Normal file
|
After Width: | Height: | Size: 120 KiB |
BIN
blog/public/blog_img/erste_fahrt/Fenster_4.webp
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
blog/public/blog_img/erste_fahrt/Fenster_5.webp
Normal file
|
After Width: | Height: | Size: 123 KiB |
BIN
blog/public/blog_img/erste_fahrt/Frühstück_Chiara.webp
Normal file
|
After Width: | Height: | Size: 203 KiB |
BIN
blog/public/blog_img/erste_fahrt/Früstück.webp
Normal file
|
After Width: | Height: | Size: 103 KiB |
BIN
blog/public/blog_img/erste_fahrt/Hafen_Spaziergang.webp
Normal file
|
After Width: | Height: | Size: 358 KiB |
BIN
blog/public/blog_img/erste_fahrt/Im_Hafen.webp
Normal file
|
After Width: | Height: | Size: 350 KiB |
BIN
blog/public/blog_img/erste_fahrt/Keine_Winch.webp
Normal file
|
After Width: | Height: | Size: 398 KiB |
BIN
blog/public/blog_img/erste_fahrt/Leinen_1.webp
Normal file
|
After Width: | Height: | Size: 345 KiB |
BIN
blog/public/blog_img/erste_fahrt/Leinen_2.webp
Normal file
|
After Width: | Height: | Size: 456 KiB |
BIN
blog/public/blog_img/erste_fahrt/Mit_Rost.webp
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
blog/public/blog_img/erste_fahrt/Notizen.webp
Normal file
|
After Width: | Height: | Size: 315 KiB |
BIN
blog/public/blog_img/erste_fahrt/Ohne_Rost.webp
Normal file
|
After Width: | Height: | Size: 80 KiB |
BIN
blog/public/blog_img/erste_fahrt/Ramsgate_Spaziergang.webp
Normal file
|
After Width: | Height: | Size: 234 KiB |
BIN
blog/public/blog_img/erste_fahrt/Ramsgate_Stadt.webp
Normal file
|
After Width: | Height: | Size: 462 KiB |
BIN
blog/public/blog_img/erste_fahrt/Route2.webp
Normal file
|
After Width: | Height: | Size: 564 KiB |
BIN
blog/public/blog_img/erste_fahrt/Route_1.webp
Normal file
|
After Width: | Height: | Size: 687 KiB |
BIN
blog/public/blog_img/erste_fahrt/Spaziergang.webp
Normal file
|
After Width: | Height: | Size: 340 KiB |
BIN
blog/public/blog_img/erste_fahrt/Tim_Fahren.webp
Normal file
|
After Width: | Height: | Size: 142 KiB |
BIN
blog/public/blog_img/erste_fahrt/Undichte_Stelle.webp
Normal file
|
After Width: | Height: | Size: 165 KiB |
BIN
blog/public/blog_img/erste_fahrt/Uvendeli_Hafen.webp
Normal file
|
After Width: | Height: | Size: 322 KiB |
BIN
blog/public/blog_img/erste_fahrt/Vorsegel_Hafeneinfahrt.webp
Normal file
|
After Width: | Height: | Size: 316 KiB |
BIN
blog/public/blog_img/erste_fahrt/Vögel_Chiara.webp
Normal file
|
After Width: | Height: | Size: 243 KiB |
BIN
blog/public/blog_img/erste_fahrt/Wasser_Bilge.webp
Normal file
|
After Width: | Height: | Size: 256 KiB |
BIN
blog/public/blog_img/erste_fahrt/Wasser_füllen.webp
Normal file
|
After Width: | Height: | Size: 289 KiB |
BIN
blog/public/blog_img/erste_fahrt/titelbild_erste_fahrt.webp
Normal file
|
After Width: | Height: | Size: 162 KiB |
|
Before Width: | Height: | Size: 302 KiB |
|
Before Width: | Height: | Size: 319 KiB |
|
Before Width: | Height: | Size: 628 KiB |
|
Before Width: | Height: | Size: 372 KiB |
|
Before Width: | Height: | Size: 66 KiB |
|
Before Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 2.2 MiB |
|
Before Width: | Height: | Size: 281 KiB |
|
Before Width: | Height: | Size: 160 KiB |
|
Before Width: | Height: | Size: 315 KiB |
|
Before Width: | Height: | Size: 457 KiB |
|
Before Width: | Height: | Size: 618 KiB |