Compare commits
No commits in common. "0ea283435e856341d8166a27d2f77b0268c959bd" and "350fe68bf72516ea4f07a89799728e16c154afae" have entirely different histories.
0ea283435e
...
350fe68bf7
18 changed files with 93 additions and 277 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -2,12 +2,11 @@
|
||||||
"cSpell.language": "en,de-DE",
|
"cSpell.language": "en,de-DE",
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"Chiara",
|
"Chiara",
|
||||||
"dotenv",
|
|
||||||
"Folierung",
|
"Folierung",
|
||||||
|
"dotenv",
|
||||||
"Hobbithöhle",
|
"Hobbithöhle",
|
||||||
"mailtrap",
|
"mailtrap",
|
||||||
"Masala",
|
"Masala",
|
||||||
"mausis",
|
|
||||||
"Pomorie",
|
"Pomorie",
|
||||||
"Reinke",
|
"Reinke",
|
||||||
"rundgelutschte",
|
"rundgelutschte",
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
BACKEND_URL="http://localhost:8000"
|
BACKEND_URL="http://localhost:8000"
|
||||||
FRONTEND_URL="http://localhost:4322"
|
FRONTEND_URL="http://localhost:4321"
|
||||||
JWT_SECRET="IamALocalSecretAndMustBeReplacedInProduction"
|
JWT_SECRET="IamALocalSecretAndMustBeReplacedInProduction"
|
||||||
ENVIRONMENT="local"
|
ENVIRONMENT="local"
|
||||||
MAILTRAP_API_TOKEN="FakedyFake"
|
MAILTRAP_API_TOKEN="FakedyFake"
|
||||||
|
|
|
||||||
|
|
@ -6,25 +6,21 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="card">
|
<div>
|
||||||
<div class="center"">
|
<h1>Neuer Artikel:</h1>
|
||||||
<img src=" https://blauwasser-mausis.de/BWM_512.webp">
|
<h3>{{data.title}}</h3>
|
||||||
</div>
|
<h4>{{data.subtitle}}</h4>
|
||||||
<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}}>
|
|
||||||
<button>⚓︎ Zum Artikel</button>
|
|
||||||
</a>
|
|
||||||
<hr>
|
|
||||||
<div class="center"><a id="hide" href="https://blauwasser-mausis.de/user">
|
|
||||||
<span>Abbestellen</span>
|
|
||||||
</a></p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a id="admin" href="https://backend.blauwasser-mausis.de/admin/newsletter/{{data.secret}}">Approve</a>
|
<a href={{data.link}}>
|
||||||
|
<button>Zum Artikel</button>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="https://blauwasser-mausis.de/blog/bootsuche-england">
|
||||||
|
<span>Abbestellen</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a id="admin" href="https://backend.blauwasser-mausis.de/?secret={{data.secret}}">Approve</a>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
@ -39,54 +35,18 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#card {
|
div {
|
||||||
background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
|
|
||||||
padding: 16px 32px;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.center {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
align-items: center;
|
||||||
justify-content: center;
|
flex-direction: column;
|
||||||
|
background-color: lightgrey;
|
||||||
|
padding: 32px 64px;
|
||||||
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
|
||||||
width: 88px;
|
|
||||||
padding: 0 0 16px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
h3,
|
||||||
h4,
|
h4 {
|
||||||
p {
|
margin: 0;
|
||||||
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 {
|
||||||
|
|
@ -94,14 +54,6 @@
|
||||||
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 {
|
||||||
|
|
|
||||||
|
|
@ -6,23 +6,19 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="card">
|
<div>
|
||||||
<div class="center"">
|
<h1>Hey {{data.user.name}}, es gibt einen neuen Artikel:</h1>
|
||||||
<img src=" https://blauwasser-mausis.de/BWM_512.webp">
|
<h3>{{data.article.title}}</h3>
|
||||||
</div>
|
<h4>{{data.article.subtitle}}</h4>
|
||||||
<h4 class="accent">Neuer Artikel</h4>
|
<p>{{data.article.description}}</p>
|
||||||
<p>{{data.date}} | Autor: {{data.author}} | Lesezeit: {{data.time2read}} min</p>
|
|
||||||
<h1>{{data.title}}</h1>
|
<a href={{data.article.link}}>
|
||||||
<h2>{{data.subtitle}}</h2>
|
<button>Zum Artikel</button>
|
||||||
<p>{{data.description}}</p>
|
|
||||||
<a href={{data.link}}>
|
|
||||||
<button>⚓︎ Zum Artikel</button>
|
|
||||||
</a>
|
</a>
|
||||||
<hr>
|
|
||||||
<div class="center"><a id="hide" href="https://blauwasser-mausis.de/user">
|
<a href="https://blauwasser-mausis.de/">
|
||||||
<span>Abbestellen</span>
|
<span>Abbestellen</span>
|
||||||
</a></p>
|
</a>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
@ -37,54 +33,18 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#card {
|
div {
|
||||||
background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
|
|
||||||
padding: 16px 32px;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.center {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
align-items: center;
|
||||||
justify-content: center;
|
flex-direction: column;
|
||||||
|
background-color: lightgrey;
|
||||||
|
padding: 32px 64px;
|
||||||
|
border-radius: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
|
||||||
width: 88px;
|
|
||||||
padding: 0 0 16px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
h3,
|
||||||
h4,
|
h4 {
|
||||||
p {
|
margin: 0;
|
||||||
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 {
|
||||||
|
|
@ -92,13 +52,5 @@
|
||||||
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>
|
||||||
|
|
@ -6,31 +6,16 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="card">
|
|
||||||
<div class="center"">
|
|
||||||
<img src="https://blauwasser-mausis.de/BWM_512.webp">
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<p id="welcome"><strong>⚓︎ Willkommen {{data.name}},</strong> du hast dich erfolgreich registriert.</p>
|
<h1>Willkommen, {{data.name}}</h1>
|
||||||
<p id="code-text">Dein persönlicher Code zum Anmelden: </p>
|
<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 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
|
<p>Dein persönlicher Code, um alle Funktionen nutzen zu können: {{data.user_code}}</p>
|
||||||
zukünftigen Features des Blogs (z.B. Kommentare) kannst du so nutzen.
|
|
||||||
<br />
|
<a href="https://blauwasser-mausis.de/">
|
||||||
Alle Einstellung kannst du jederzeit in deinem Profil anpassen.
|
<span>Daten löschen</span>
|
||||||
</p>
|
|
||||||
<a href="https://blauwasser-mausis.de/login">
|
|
||||||
<button>⚓︎ Jetzt einloggen ⚓︎</button>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</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>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -44,70 +29,12 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#card {
|
div {
|
||||||
background-image: linear-gradient(to bottom, #1d3238, #3c6a7b);
|
|
||||||
padding: 16px 32px;
|
|
||||||
border-radius: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.center {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
align-items: center;
|
||||||
justify-content: center;
|
flex-direction: column;
|
||||||
}
|
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>
|
||||||
|
|
@ -12,27 +12,21 @@ 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, date, author, time2read):
|
def __init__(self, title, subtitle, description, link):
|
||||||
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, date, author, time2read, secret):
|
def __init__(self,title, subtitle, description, link, secret):
|
||||||
ArticleData.__init__(self, title, subtitle, description, link, date, author, time2read)
|
ArticleData.__init__(self, title, subtitle, description, link)
|
||||||
self.secret = secret
|
self.secret = secret
|
||||||
|
|
||||||
secret: str
|
secret: str
|
||||||
|
|
@ -44,7 +38,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(
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
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
|
||||||
|
|
@ -12,17 +13,15 @@ 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=1)):
|
||||||
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, date, author, time2read, secret)
|
data = AdminApprovalData(title, subtitle, description, link, 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:
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
from dotenv.main import load_dotenv
|
from dotenv.main import load_dotenv
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
|
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 Relationship, SQLModel, Field
|
from sqlmodel import 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
|
||||||
|
|
@ -14,7 +18,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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
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
|
||||||
|
|
@ -30,21 +29,17 @@ 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["pubDate"]), '%a, %d %b %Y %H:%M:%S %Z')
|
|
||||||
article_data = {
|
article_data = {
|
||||||
"title": article["title"],
|
"title": article["title"],
|
||||||
"subtitle": article["subtitle"],
|
"subtitle": article["subtitle"],
|
||||||
"description": article["summary"],
|
"description": article["summary"],
|
||||||
"link": article["link"],
|
"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": user, "article": article_data })
|
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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { useState } from "preact/hooks";
|
import { useState } from "preact/hooks";
|
||||||
import { api } from "../lib/api";
|
import { api } from "../lib/api";
|
||||||
import { navigateBackAndReload, logout } from "./Util";
|
import { handleBackAndReload, logout } from "./Util";
|
||||||
import type { JSX } from "preact/jsx-runtime";
|
import type { JSX } from "preact/jsx-runtime";
|
||||||
|
|
||||||
export default function DeleteUser() {
|
export default function DeleteUser() {
|
||||||
|
|
@ -20,7 +20,7 @@ export default function DeleteUser() {
|
||||||
} finally {
|
} finally {
|
||||||
if (!hasError) {
|
if (!hasError) {
|
||||||
logout()
|
logout()
|
||||||
navigateBackAndReload()
|
handleBackAndReload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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 } from '../lib/api';
|
||||||
import { getUser, navigateBackAndReload, navigatePathAndReload, saveUser } from './Util';
|
import { handleBackAndReload, 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) navigateBackAndReload()
|
if (!hasError) handleBackAndReload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { navigateBackAndReload } from "./Util";
|
import { handleBackAndReload } from "./Util";
|
||||||
|
|
||||||
export default function NavBack() {
|
export default function NavBack() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button class="back-btn" onClick={navigateBackAndReload}>Zurück</button>
|
<button class="back-btn" onClick={handleBackAndReload}>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 { navigateBackAndReload, isEmailValid } from './Util';
|
import { handleBackAndReload, 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) navigateBackAndReload()
|
if (!hasError) handleBackAndReload()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 { getUser, navigatePathAndReload, saveUser } from './Util';
|
import { getUser, saveUser } from './Util';
|
||||||
|
|
||||||
export default function ToggleSubscription() {
|
export default function ToggleSubscription() {
|
||||||
const [subscription, setSubscription] = React.useState<boolean>(false);
|
const [subscription, setSubscription] = React.useState<boolean>(false);
|
||||||
|
|
@ -10,7 +10,7 @@ export default function ToggleSubscription() {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
user = getUser()
|
user = getUser()
|
||||||
if (!user) navigatePathAndReload("/login")
|
if (!user) navigation.back()
|
||||||
else setSubscription(user.subscription)
|
else setSubscription(user.subscription)
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
@ -23,6 +23,7 @@ export default function ToggleSubscription() {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setError(err instanceof Error ? err.message : 'Update fehlgeschlagen');
|
setError(err instanceof Error ? err.message : 'Update fehlgeschlagen');
|
||||||
hasError = true
|
hasError = true
|
||||||
|
console.log(hasError);
|
||||||
} finally {
|
} finally {
|
||||||
if (!hasError) {
|
if (!hasError) {
|
||||||
if (user) {
|
if (user) {
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ export function isTokenExpired(token: string): boolean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const navigateBackAndReload = () => {
|
export const handleBackAndReload = () => {
|
||||||
if (document.referrer) {
|
if (document.referrer) {
|
||||||
navigate(document.referrer, { history: 'replace' });
|
navigate(document.referrer, { history: 'replace' });
|
||||||
setTimeout(() => window.location.reload(), 50);
|
setTimeout(() => window.location.reload(), 50);
|
||||||
|
|
@ -50,8 +50,3 @@ export const navigateBackAndReload = () => {
|
||||||
navigate('/');
|
navigate('/');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const navigatePathAndReload = (path: string) => {
|
|
||||||
navigate(path, { history: 'replace' });
|
|
||||||
setTimeout(() => window.location.reload(), 50);
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import rss from '@astrojs/rss';
|
import rss, { pagesGlobToRssItems } from '@astrojs/rss';
|
||||||
import { formatLocalizedDateString } from '../lib/formatDate';
|
|
||||||
|
|
||||||
export async function GET(context) {
|
export async function GET(context) {
|
||||||
|
|
||||||
|
|
@ -13,18 +12,16 @@ export async function GET(context) {
|
||||||
site: context.site,
|
site: context.site,
|
||||||
items: posts.map(post => ({
|
items: posts.map(post => ({
|
||||||
title: post.frontmatter.title,
|
title: post.frontmatter.title,
|
||||||
pubDate: post.frontmatter.date,
|
pubDate: Date.parse(post.frontmatter.date),
|
||||||
description: post.frontmatter.description,
|
description: post.frontmatter.description,
|
||||||
link: `/blog/${post.frontmatter.slug}`,
|
link: `/blog/${post.frontmatter.slug}`,
|
||||||
author: post.frontmatter.author,
|
|
||||||
|
|
||||||
customData: `
|
customData: `
|
||||||
<subtitle>
|
<subtitle>
|
||||||
<![CDATA[${post.frontmatter.subtitle}]]>
|
<![CDATA[${post.frontmatter.subtitle}]]>
|
||||||
</subtitle>
|
</subtitle>
|
||||||
<time2read>
|
|
||||||
<![CDATA[${post.frontmatter.time2read}]]>
|
|
||||||
</time2read>
|
|
||||||
`,
|
`,
|
||||||
})),
|
})),
|
||||||
customData: `<language>de-de</language>`,
|
customData: `<language>de-de</language>`,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue