{{ p[4] }}
+{{ p[4] | content | safe}}
diff --git a/entry.py b/entry.py
index 809d139..43252f6 100644
--- a/entry.py
+++ b/entry.py
@@ -72,6 +72,7 @@ def newentry():
return render_template('entry/create.html')
content = str(request.form["content"])
+ content = content.strip()
content = content[:1000]
fileattached = False
diff --git a/main.py b/main.py
index 9c935ee..d20d16e 100644
--- a/main.py
+++ b/main.py
@@ -20,6 +20,29 @@ def timestamp_filter(value):
except:
return value
+import html, re
+
+@app.template_filter('content')
+def content_filter(value):
+ value = value.strip()
+ value = html.escape(value)
+ # Regulärer Ausdruck, um URLs zu finden
+ url_pattern = re.compile(
+ r'https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)'
+ )
+
+ # Ersetze jede gefundene URL durch einen -Tag
+ def replace_url(match):
+ url = match.group(0)
+ if not url.startswith(('http://', 'https://')):
+ url = 'http://' + url
+ return f'{match.group(0)}'
+
+ value = url_pattern.sub(replace_url, value)
+ value = value.replace('\n', '
')
+
+ return value
+
import auth
import entry
import user
diff --git a/static/css/main.css b/static/css/main.css
index 244c60f..34c99da 100644
--- a/static/css/main.css
+++ b/static/css/main.css
@@ -51,7 +51,8 @@ hr {
justify-content: center;
align-items: center;
gap: 10pt; }
- #contentnotice h1, #contentnotice h3 {
+ #contentnotice h1,
+ #contentnotice h3 {
margin: 6pt; }
#contentnotice div {
width: 100%;
@@ -64,7 +65,10 @@ hr {
.entry .content {
margin: 10pt;
- font-size: 14pt; }
+ font-size: 14pt;
+ word-wrap: break-word;
+ max-height: 500px;
+ overflow: hidden; }
.entry img {
max-width: 100%; }
diff --git a/static/css/main.scss b/static/css/main.scss
index bf51f33..ebfe408 100644
--- a/static/css/main.scss
+++ b/static/css/main.scss
@@ -66,7 +66,8 @@ hr {
align-items: center;
gap: 10pt;
- h1, h3 {
+ h1,
+ h3 {
margin: 6pt;
}
@@ -86,6 +87,10 @@ hr {
.content {
margin: 10pt;
font-size: 14pt;
+ word-wrap: break-word;
+
+ max-height: 500px;
+ overflow: hidden;
}
img {
diff --git a/templates/entry/feed.html b/templates/entry/feed.html
index 1a7dfba..93e6e59 100644
--- a/templates/entry/feed.html
+++ b/templates/entry/feed.html
@@ -2,9 +2,11 @@
{{ p[4] }}
+{{ p[4] | content | safe}}