stuff
This commit is contained in:
parent
c30f6313bc
commit
f59b78bdea
15 changed files with 43 additions and 34 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -2,11 +2,12 @@
|
|||
"cSpell.language": "en,de-DE",
|
||||
"cSpell.words": [
|
||||
"Chiara",
|
||||
"Folierung",
|
||||
"dotenv",
|
||||
"Folierung",
|
||||
"Hobbithöhle",
|
||||
"mailtrap",
|
||||
"Masala",
|
||||
"mausis",
|
||||
"Pomorie",
|
||||
"Reinke",
|
||||
"rundgelutschte",
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ class ArticleData():
|
|||
self.subtitle=subtitle
|
||||
self.description=description
|
||||
self.link=link
|
||||
self.data=date
|
||||
self.date=date
|
||||
self.author=author
|
||||
self.time2read = time2read
|
||||
|
||||
|
|
|
|||
|
|
@ -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=1)):
|
||||
if date_object > (datetime.now() - timedelta(days=16)):
|
||||
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,4 +1,3 @@
|
|||
|
||||
from dotenv.main import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
from datetime import datetime
|
||||
from mailtrap import Address
|
||||
from backend.internal.mail_util import create_html_from_template
|
||||
from mailtrap import BatchEmailRequest
|
||||
|
|
@ -29,11 +30,15 @@ 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["pubDate"]), '%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] = []
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useState } from "preact/hooks";
|
||||
import { api } from "../lib/api";
|
||||
import { handleBackAndReload, logout } from "./Util";
|
||||
import { navigateBackAndReload, logout } from "./Util";
|
||||
import type { JSX } from "preact/jsx-runtime";
|
||||
|
||||
export default function DeleteUser() {
|
||||
|
|
@ -20,7 +20,7 @@ export default function DeleteUser() {
|
|||
} finally {
|
||||
if (!hasError) {
|
||||
logout()
|
||||
handleBackAndReload()
|
||||
navigateBackAndReload()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { useEffect, useState } from 'preact/hooks';
|
||||
import { api, AUTH_TOKEN_KEY } from '../lib/api';
|
||||
import { handleBackAndReload, saveUser } from './Util';
|
||||
import { getUser, navigateBackAndReload, navigatePathAndReload, saveUser } from './Util';
|
||||
|
||||
export default function LoginForm() {
|
||||
const [userCode, setUserCode] = useState('');
|
||||
|
|
@ -33,7 +33,7 @@ export default function LoginForm() {
|
|||
}
|
||||
hasError = true
|
||||
} finally {
|
||||
if (!hasError) handleBackAndReload()
|
||||
if (!hasError) navigateBackAndReload()
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { handleBackAndReload } from "./Util";
|
||||
import { navigateBackAndReload } from "./Util";
|
||||
|
||||
export default function NavBack() {
|
||||
|
||||
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 { api, type User } from '../lib/api';
|
||||
import React from 'preact/compat';
|
||||
import { handleBackAndReload, isEmailValid } from './Util';
|
||||
import { navigateBackAndReload, isEmailValid } from './Util';
|
||||
|
||||
export default function RegisterForm() {
|
||||
const [user, setUser] = React.useState<User>({ 'email': '', 'name': '', 'subscription': true });
|
||||
|
|
@ -31,7 +31,7 @@ export default function RegisterForm() {
|
|||
}
|
||||
hasError = true
|
||||
} finally {
|
||||
if (!hasError) handleBackAndReload()
|
||||
if (!hasError) navigateBackAndReload()
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { useEffect, useState } from 'preact/hooks';
|
||||
import { api, type User } from '../lib/api';
|
||||
import React from 'preact/compat';
|
||||
import { getUser, saveUser } from './Util';
|
||||
import { getUser, navigatePathAndReload, saveUser } from './Util';
|
||||
|
||||
export default function ToggleSubscription() {
|
||||
const [subscription, setSubscription] = React.useState<boolean>(false);
|
||||
|
|
@ -10,7 +10,7 @@ export default function ToggleSubscription() {
|
|||
|
||||
useEffect(() => {
|
||||
user = getUser()
|
||||
if (!user) navigation.back()
|
||||
if (!user) navigatePathAndReload("/login")
|
||||
else setSubscription(user.subscription)
|
||||
}, []);
|
||||
|
||||
|
|
@ -23,7 +23,6 @@ export default function ToggleSubscription() {
|
|||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Update fehlgeschlagen');
|
||||
hasError = true
|
||||
console.log(hasError);
|
||||
} finally {
|
||||
if (!hasError) {
|
||||
if (user) {
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ export function isTokenExpired(token: string): boolean {
|
|||
}
|
||||
}
|
||||
|
||||
export const handleBackAndReload = () => {
|
||||
export const navigateBackAndReload = () => {
|
||||
if (document.referrer) {
|
||||
navigate(document.referrer, { history: 'replace' });
|
||||
setTimeout(() => window.location.reload(), 50);
|
||||
|
|
@ -50,3 +50,8 @@ export const handleBackAndReload = () => {
|
|||
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) {
|
||||
|
||||
|
|
@ -12,16 +13,18 @@ export async function GET(context) {
|
|||
site: context.site,
|
||||
items: posts.map(post => ({
|
||||
title: post.frontmatter.title,
|
||||
pubDate: Date.parse(post.frontmatter.date),
|
||||
pubDate: post.frontmatter.date,
|
||||
description: post.frontmatter.description,
|
||||
link: `/blog/${post.frontmatter.slug}`,
|
||||
|
||||
author: post.frontmatter.author,
|
||||
|
||||
customData: `
|
||||
<subtitle>
|
||||
<![CDATA[${post.frontmatter.subtitle}]]>
|
||||
</subtitle>
|
||||
|
||||
<time2read>
|
||||
<![CDATA[${post.frontmatter.time2read}]]>
|
||||
</time2read>
|
||||
`,
|
||||
})),
|
||||
customData: `<language>de-de</language>`,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue