mirror of
https://codeberg.org/SimpleWeb/SimpleerTube.git
synced 2024-11-25 10:01:30 +00:00
Update, improved style and fix comments showing raw HTML
This commit is contained in:
parent
21df015a3a
commit
3692b57942
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
__pycache__/
|
15
main.py
15
main.py
|
@ -2,6 +2,10 @@ from quart import Quart, request, render_template, redirect
|
|||
from datetime import datetime
|
||||
from math import ceil
|
||||
import peertube
|
||||
import html2text
|
||||
|
||||
h2t = html2text.HTML2Text()
|
||||
h2t.ignore_links = True
|
||||
|
||||
commit = "not found"
|
||||
with open(".git/refs/heads/main") as file:
|
||||
|
@ -241,7 +245,6 @@ async def search(domain, term, page):
|
|||
pages_total=(results["total"] / 10)
|
||||
)
|
||||
|
||||
|
||||
@app.route("/<string:domain>/videos/watch/<string:id>/")
|
||||
async def video(domain, id):
|
||||
data = peertube.video(domain, id)
|
||||
|
@ -256,6 +259,16 @@ async def video(domain, id):
|
|||
if data["commentsEnabled"]:
|
||||
comments = peertube.get_comments(domain, id)
|
||||
|
||||
# Strip the HTML from the comments and convert them to plain text
|
||||
new_comments = {"total": comments["total"], "data": []}
|
||||
for comment in comments["data"]:
|
||||
text = h2t.handle(comment["text"]).strip().strip("\n")
|
||||
comment["text"] = text
|
||||
new_comments["data"].append(comment)
|
||||
comments = new_comments
|
||||
|
||||
|
||||
|
||||
return await render_template(
|
||||
"video.html",
|
||||
domain=domain,
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
{% endblock %}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- I know that inline CSS is not .. the best, but I'll move it to an external file for sure! definitely! -->
|
||||
<body style="max-width: 800px; margin: 10px auto; padding-left: 5px; padding-right: 5px">
|
||||
<form action="/{{ domain }}/search" method="POST">
|
||||
<label for="query"><b>{{ instance_name }}</b></label>
|
||||
<input type="text" name="query" id="query" placeholder="Search" value="{{ search_term }}"/>
|
||||
|
|
|
@ -22,7 +22,7 @@ By:
|
|||
<b>Resolutions:</b>
|
||||
{% else %}
|
||||
<video height="300" controls>
|
||||
<source src="{{ video.video }}">
|
||||
<source src="{{ video.video }}">
|
||||
</video>
|
||||
<br>
|
||||
<b>Resolutions:</b>
|
||||
|
|
Loading…
Reference in a new issue