Compare commits
5 commits
350fe68bf7
...
0ea283435e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ea283435e | ||
| 7d256c9f3f | |||
| 1381f3fdbd | |||
| f59b78bdea | |||
|
|
c30f6313bc |
18 changed files with 277 additions and 93 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -2,11 +2,12 @@
|
||||||
"cSpell.language": "en,de-DE",
|
"cSpell.language": "en,de-DE",
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
"Chiara",
|
"Chiara",
|
||||||
"Folierung",
|
|
||||||
"dotenv",
|
"dotenv",
|
||||||
|
"Folierung",
|
||||||
"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:4321"
|
FRONTEND_URL="http://localhost:4322"
|
||||||
JWT_SECRET="IamALocalSecretAndMustBeReplacedInProduction"
|
JWT_SECRET="IamALocalSecretAndMustBeReplacedInProduction"
|
||||||
ENVIRONMENT="local"
|
ENVIRONMENT="local"
|
||||||
MAILTRAP_API_TOKEN="FakedyFake"
|
MAILTRAP_API_TOKEN="FakedyFake"
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
<a href="https://blauwasser-mausis.de/blog/bootsuche-england">
|
<div class="center"><a id="hide" href="https://blauwasser-mausis.de/user">
|
||||||
<span>Abbestellen</span>
|
<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>
|
</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 {
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,23 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div>
|
<div id="card">
|
||||||
<h1>Hey {{data.user.name}}, es gibt einen neuen Artikel:</h1>
|
<div class="center"">
|
||||||
<h3>{{data.article.title}}</h3>
|
<img src=" https://blauwasser-mausis.de/BWM_512.webp">
|
||||||
<h4>{{data.article.subtitle}}</h4>
|
</div>
|
||||||
<p>{{data.article.description}}</p>
|
<h4 class="accent">Neuer Artikel</h4>
|
||||||
|
<p>{{data.date}} | Autor: {{data.author}} | Lesezeit: {{data.time2read}} min</p>
|
||||||
<a href={{data.article.link}}>
|
<h1>{{data.title}}</h1>
|
||||||
<button>Zum Artikel</button>
|
<h2>{{data.subtitle}}</h2>
|
||||||
|
<p>{{data.description}}</p>
|
||||||
|
<a href={{data.link}}>
|
||||||
|
<button>⚓︎ Zum Artikel</button>
|
||||||
</a>
|
</a>
|
||||||
|
<hr>
|
||||||
<a href="https://blauwasser-mausis.de/">
|
<div class="center"><a id="hide" href="https://blauwasser-mausis.de/user">
|
||||||
<span>Abbestellen</span>
|
<span>Abbestellen</span>
|
||||||
</a>
|
</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>
|
||||||
|
|
@ -6,16 +6,31 @@
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
<div id="card">
|
||||||
|
<div class="center"">
|
||||||
|
<img src="https://blauwasser-mausis.de/BWM_512.webp">
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h1>Willkommen, {{data.name}}</h1>
|
<p id="welcome"><strong>⚓︎ Willkommen {{data.name}},</strong> du hast dich erfolgreich registriert.</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 id="code-text">Dein persönlicher Code zum Anmelden: </p>
|
||||||
|
<p class="accent">{{data.user_code}}</p>
|
||||||
<p>Dein persönlicher Code, um alle Funktionen nutzen zu können: {{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.
|
||||||
<a href="https://blauwasser-mausis.de/">
|
<br />
|
||||||
<span>Daten löschen</span>
|
Alle Einstellung kannst du jederzeit in deinem Profil anpassen.
|
||||||
|
</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>
|
||||||
|
|
@ -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>
|
||||||
|
|
@ -12,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
|
||||||
|
|
@ -38,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(
|
||||||
|
|
|
||||||
|
|
@ -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=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, 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:
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
from dotenv.main import load_dotenv
|
from dotenv.main import load_dotenv
|
||||||
load_dotenv()
|
load_dotenv()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
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
|
||||||
|
|
@ -29,17 +30,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["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 { handleBackAndReload, logout } from "./Util";
|
import { navigateBackAndReload, 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()
|
||||||
handleBackAndReload()
|
navigateBackAndReload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -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 { handleBackAndReload, saveUser } from './Util';
|
import { getUser, navigateBackAndReload, navigatePathAndReload, saveUser } from './Util';
|
||||||
|
|
||||||
export default function LoginForm() {
|
export default function LoginForm() {
|
||||||
const [userCode, setUserCode] = useState('');
|
const [userCode, setUserCode] = useState('');
|
||||||
|
|
@ -33,7 +33,7 @@ export default function LoginForm() {
|
||||||
}
|
}
|
||||||
hasError = true
|
hasError = true
|
||||||
} finally {
|
} finally {
|
||||||
if (!hasError) handleBackAndReload()
|
if (!hasError) navigateBackAndReload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
import { handleBackAndReload } from "./Util";
|
import { navigateBackAndReload } from "./Util";
|
||||||
|
|
||||||
export default function NavBack() {
|
export default function NavBack() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button class="back-btn" onClick={handleBackAndReload}>Zurück</button>
|
<button class="back-btn" onClick={navigateBackAndReload}>Zurück</button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { useEffect, useState } from 'preact/hooks';
|
import { useEffect, useState } from 'preact/hooks';
|
||||||
import { api, type User } from '../lib/api';
|
import { api, type User } from '../lib/api';
|
||||||
import React from 'preact/compat';
|
import React from 'preact/compat';
|
||||||
import { handleBackAndReload, isEmailValid } from './Util';
|
import { navigateBackAndReload, isEmailValid } from './Util';
|
||||||
|
|
||||||
export default function RegisterForm() {
|
export default function RegisterForm() {
|
||||||
const [user, setUser] = React.useState<User>({ 'email': '', 'name': '', 'subscription': true });
|
const [user, setUser] = React.useState<User>({ 'email': '', 'name': '', 'subscription': true });
|
||||||
|
|
@ -31,7 +31,7 @@ export default function RegisterForm() {
|
||||||
}
|
}
|
||||||
hasError = true
|
hasError = true
|
||||||
} finally {
|
} finally {
|
||||||
if (!hasError) handleBackAndReload()
|
if (!hasError) navigateBackAndReload()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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, saveUser } from './Util';
|
import { getUser, navigatePathAndReload, 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) navigation.back()
|
if (!user) navigatePathAndReload("/login")
|
||||||
else setSubscription(user.subscription)
|
else setSubscription(user.subscription)
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
@ -23,7 +23,6 @@ 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 handleBackAndReload = () => {
|
export const navigateBackAndReload = () => {
|
||||||
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,3 +50,8 @@ export const handleBackAndReload = () => {
|
||||||
navigate('/');
|
navigate('/');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const navigatePathAndReload = (path: string) => {
|
||||||
|
navigate(path, { history: 'replace' });
|
||||||
|
setTimeout(() => window.location.reload(), 50);
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import rss, { pagesGlobToRssItems } from '@astrojs/rss';
|
import rss from '@astrojs/rss';
|
||||||
|
import { formatLocalizedDateString } from '../lib/formatDate';
|
||||||
|
|
||||||
export async function GET(context) {
|
export async function GET(context) {
|
||||||
|
|
||||||
|
|
@ -12,16 +13,18 @@ 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: Date.parse(post.frontmatter.date),
|
pubDate: 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