Merge pull request 'add bottom bar with information about the running burgercat server and fix links not being wrapped inside of <a> in chat' (#10) from ffqq/burgercat-commithash:main into main
Reviewed-on: https://codeberg.org/burger-software/burgercat/pulls/10
This commit is contained in:
commit
2bee72cca7
7
main
7
main
|
@ -7,6 +7,7 @@ import json
|
||||||
import secrets
|
import secrets
|
||||||
import datetime
|
import datetime
|
||||||
import socket
|
import socket
|
||||||
|
import subprocess
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
from waitress import serve
|
from waitress import serve
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
@ -126,6 +127,8 @@ def get_session(id):
|
||||||
return "error"
|
return "error"
|
||||||
return post
|
return post
|
||||||
|
|
||||||
|
full_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode().strip()
|
||||||
|
short_hash = subprocess.check_output(["git", "rev-parse", "--short=8", "HEAD"]).decode().strip()
|
||||||
|
|
||||||
ALLOWED_EXTENSIONS = {"png", "apng", "jpg", "jpeg", "gif", "svg", "webp"}
|
ALLOWED_EXTENSIONS = {"png", "apng", "jpg", "jpeg", "gif", "svg", "webp"}
|
||||||
|
|
||||||
|
@ -144,9 +147,9 @@ def main():
|
||||||
if usersession:
|
if usersession:
|
||||||
userCookie = get_session(usersession)
|
userCookie = get_session(usersession)
|
||||||
user = get_user(userCookie["id"])
|
user = get_user(userCookie["id"])
|
||||||
return render_template("main.html", userdata=user, posts=posts)
|
return render_template("main.html", userdata=user, posts=posts, full_hash=full_hash, short_hash=short_hash)
|
||||||
else:
|
else:
|
||||||
return render_template("main.html", posts=posts)
|
return render_template("main.html", posts=posts, full_hash=full_hash, short_hash=short_hash)
|
||||||
|
|
||||||
@app.route("/chat", methods=("GET", "POST"))
|
@app.route("/chat", methods=("GET", "POST"))
|
||||||
def chat():
|
def chat():
|
||||||
|
|
|
@ -19,6 +19,20 @@ body {
|
||||||
z-index: 2;
|
z-index: 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bottom {
|
||||||
|
margin: 0;
|
||||||
|
border: solid;
|
||||||
|
border-color: grey;
|
||||||
|
border-width: 0;
|
||||||
|
border-bottom-width: 1px;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom a {
|
||||||
|
color: lightgrey;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
.navbar .selected {
|
.navbar .selected {
|
||||||
border: solid;
|
border: solid;
|
||||||
border-color: #f1b739;
|
border-color: #f1b739;
|
||||||
|
@ -332,6 +346,14 @@ body {
|
||||||
background-color: var(--gray-800);
|
background-color: var(--gray-800);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.bottom {
|
||||||
|
background-color: var(--gray-900);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bottom a {
|
||||||
|
color: var(--gray-700)
|
||||||
|
}
|
||||||
|
|
||||||
.navbar a, a {
|
.navbar a, a {
|
||||||
color: white;
|
color: white;
|
||||||
border-size: 0px;
|
border-size: 0px;
|
||||||
|
|
|
@ -20,7 +20,11 @@ async function updateMessages(id) {
|
||||||
const timeParagraph = document.createElement("p");
|
const timeParagraph = document.createElement("p");
|
||||||
const { creator, content, id, created } = message;
|
const { creator, content, id, created } = message;
|
||||||
|
|
||||||
messageParagraph.appendChild(document.createTextNode(`${creator.username}: ${content}`));
|
// Check if the message content contains any links that are not image links and hide image links
|
||||||
|
const linkRegex = /(https?:\/\/[^\s]+(?<!\.(?:png|apng|webp|svg|jpg|jpeg|gif)))(?=\s|$)|(?<=\s|^)(https?:\/\/(?:cdn\.discordapp\.com|media\.discordapp\.net|media\.tenor\.com|i\.imgur\.com|burger\.ctaposter\.xyz)\/.+?\.(?:png|apng|webp|svg|jpg|jpeg|gif))(?=$|\s)/gi;
|
||||||
|
let messageContent = content.replace(linkRegex, "<a href='$1' target='_blank'>$1</a>");
|
||||||
|
|
||||||
|
messageParagraph.innerHTML = `${creator.username}: ${messageContent}`;
|
||||||
messageParagraph.classList.add("messageParagraph");
|
messageParagraph.classList.add("messageParagraph");
|
||||||
messageParagraph.id = `messageParagraph${id}`;
|
messageParagraph.id = `messageParagraph${id}`;
|
||||||
messageParagraph.appendChild(timeParagraph);
|
messageParagraph.appendChild(timeParagraph);
|
||||||
|
|
|
@ -113,7 +113,12 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="bottom">
|
||||||
|
<span>
|
||||||
|
<a href="https://codeberg.org/burger-software/burgercat">burgercat</a>
|
||||||
|
<a href="https://codeberg.org/burger-software/burgercat/commit/{{ full_hash }}" style="float: right;">commit hash: {{ short_hash }}</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<script src="/static/js/main.js"></script>
|
<script src="/static/js/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
Reference in New Issue