Compare commits

...

8 Commits

Author SHA1 Message Date
metalune a71691854e Improve style for tags 2021-03-24 20:32:27 +01:00
metalune dda3b3dbec Add style for Tags 2021-03-24 20:27:22 +01:00
metalune 8ed26b7b87 Add more information to main page 2021-03-24 19:10:04 +01:00
metalune 9ea537820a Redesign search in search results for simpleertube 2021-03-24 19:02:49 +01:00
metalune ce98f4408d Redesign search of isntances 2021-03-24 18:58:55 +01:00
metalune 7d7b89b8ca Improve startpage 2021-03-24 18:56:02 +01:00
metalune 5a84312706 Use external style file 2021-03-24 18:52:46 +01:00
metalune 3692b57942 Update, improved style and fix comments showing raw HTML 2021-03-24 18:43:50 +01:00
7 changed files with 95 additions and 55 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
__pycache__/

15
main.py
View File

@ -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,

13
static/style.css Normal file
View File

@ -0,0 +1,13 @@
body {
background-color: lightyellow;
max-width: 800px;
margin: 10px auto;
padding-left: 5px;
padding-right: 5px;
}
.tag {
background-color: lightgrey;
padding: 3px 7px;
display: inline;
}

View File

@ -2,64 +2,67 @@
<html>
<head>
<link rel="stylesheet" href="/static/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
{% block head %}
<title>{% block full_title %}{% block title %}{% endblock %} - SimpleerTube{% endblock %}</title>
{% endblock %}
</head>
<!-- I know that inline CSS is not .. the best, but I'll move it to an external file for sure! definitely! -->
<body>
<h2>{{ instance_name }}</h2>
<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 }}"/>
<input size="45" type="text" name="query" id="query" placeholder="Search" value="{{ search_term }}"/>
<button type="submit">Search</button>
</form>
<br>
<br>
<a href="/{{ domain }}/videos/local">Local</a>
<b> | </b>
<a href="/{{ domain }}/videos/trending">Trending</a>
<b> | </b>
<a href="/{{ domain }}/videos/most-liked">Most Liked</a>
<b> | </b>
<a href="/{{ domain }}/videos/recently-added">Recently Added</a>
<br>
<br>
<a href="/{{ domain }}/videos/local">Local</a>
<b> | </b>
<a href="/{{ domain }}/videos/trending">Trending</a>
<b> | </b>
<a href="/{{ domain }}/videos/most-liked">Most Liked</a>
<b> | </b>
<a href="/{{ domain }}/videos/recently-added">Recently Added</a>
<br>
<br>
{% block head_content %}{% endblock %}
{% block head_content %}{% endblock %}
{% if pagination_url %}
{% if pages_total > 1 %}
{% if page > 1 %}
<a href="{{ pagination_url }}{{ page - 1 }}">Previous</a>
<b> | </b>
{% if pagination_url %}
{% if pages_total > 1 %}
{% if page > 1 %}
<a href="{{ pagination_url }}{{ page - 1 }}">Previous</a>
<b> | </b>
{% endif %}
Page {{ page }} of {{ pages_total }}
{% if page < pages_total %}
<b> | </b>
<a href="{{ pagination_url }}{{ page + 1}}">Next</a>
{% endif %}
{% endif %}
Page {{ page }} of {{ pages_total }}
{% if page < pages_total %}
<b> | </b>
<a href="{{ pagination_url }}{{ page + 1}}">Next</a>
{% endif %}
{% endif %}
{% endif %}
<br>
<br>
{% block content %}{% endblock %}
{% block content %}{% endblock %}
{% if pagination_url %}
{% if pages_total > 1 %}
{% if page > 1 %}
<a href="{{ pagination_url }}{{ page - 1 }}">Previous</a>
<b> | </b>
{% if pagination_url %}
{% if pages_total > 1 %}
{% if page > 1 %}
<a href="{{ pagination_url }}{{ page - 1 }}">Previous</a>
<b> | </b>
{% endif %}
Page {{ page }} of {{ pages_total }}
{% if page < pages_total %}
<b> | </b>
<a href="{{ pagination_url }}{{ page + 1}}">Next</a>
{% endif %}
{% endif %}
Page {{ page }} of {{ pages_total }}
{% if page < pages_total %}
<b> | </b>
<a href="{{ pagination_url }}{{ page + 1}}">Next</a>
{% endif %}
{% endif %}
{% endif %}
<footer>
<a href="https://git.sr.ht/~metalune/peertube/tree/{{ commit }}">Commit: {{ commit }}</a>
</footer>
<footer>
<a href="https://git.sr.ht/~metalune/peertube/tree/{{ commit }}">Commit: {{ commit }}</a>
</footer>
</body>
</html>

View File

@ -2,15 +2,23 @@
<html>
<head>
<title>SimpleerTube - Search</title>
<link rel="stylesheet" href="/static/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<form action="/search" method="POST">
<label for="query"><b>SimpleerTube</b></label>
<input type="text" name="query" id="query" placeholder="Search"/>
<button type="submit">Search</button>
</form>
<footer>
<a href="https://codeberg.org/simple-web/peertube/src/commit/{{ commit }}">Commit: {{ commit }}</a>
</footer>
<center>
<h2>SimpleerTube</h2>
<h5>A simple frontend for PeerTube</h5>
<form action="/search" method="POST">
<input size="45" type="text" name="query" id="query" placeholder="SepiaSearch"/>
<button type="submit">Search</button>
</form>
<br>
<br>
<footer>
<a href="https://codeberg.org/simple-web/peertube/src/commit/{{ commit }}">Commit: {{ commit }}</a>
</footer>
</center>
</body>
</html>

View File

@ -2,11 +2,13 @@
<html>
<head>
<title>SimpleerTube - Search Results</title>
<link rel="stylesheet" href="/static/style.css">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<h2>SimpleerTube</h2>
<form action="/search" method="POST">
<label for="query"><b>SimpleerTube</b></label>
<input type="text" name="query" id="query" placeholder="Search" value="{{ query }}"/>
<input size="45" type="text" name="query" id="query" placeholder="Search" value="{{ query }}"/>
<button type="submit">Search</button>
</form>
<br>

View File

@ -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>
@ -62,9 +62,9 @@ Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{
<tr>
<td><b>Tags</b></td>
<td>
{% for tag in video.tags %}
{{ tag }}
{% endfor %}
{% for tag in video.tags %}
<span class="tag">{{ tag }}</span>
{% endfor %}
</td>
</tr>
</table>