Create base template and use it everywhere

Also added a nice and shiny search field in the template.
This commit is contained in:
fattalion 2021-01-19 18:13:08 +03:00
parent 88394abd42
commit 20a2d43b74
5 changed files with 117 additions and 96 deletions

View File

@ -66,7 +66,7 @@ async def search_redirect(domain):
async def search(domain, term):
amount, results = peertube.search(domain, term)
return await render_template(
"search_results.html", domain=domain, amount=amount, results=results
"search_results.html", domain=domain, amount=amount, results=results, search_term=term
)

21
templates/base.html Normal file
View File

@ -0,0 +1,21 @@
<!doctype html>
<html>
<head>
{% block head %}
<title>{% block full_title %}{% block title %}{% endblock %} - SimpleerTube{% endblock %}</title>
{% endblock %}
</head>
<body>
<form action="/{{ domain }}/search" method="POST">
<input type="text" name="query" id="query" value="{{ search_term }}"/>
<button type="submit">Search</button>
</form>
<br>
<br>
{% block content %}{% endblock %}
</body>
</html>

View File

@ -1,10 +1,7 @@
<!doctype html>
<html>
<body>
<b>{{ instance_name }}</b>
<form action="/{{ domain }}/search" method="POST">
<input type="text" name="query" id="query"/>
<button type="submit">Search</button>
</form>
</body>
</html>
{% extends "base.html" %}
{% block title %}{{ domain }}{% endblock %}
{% block content %}
<b>{{ instance_name }}</b>
{% endblock %}

View File

@ -1,24 +1,26 @@
<!doctype html>
<html>
<body>
<p>{{ amount }} results</p>
<table>
{% for result in results %}
<tr>
<td>
<a href="/{{ domain}}/watch/{{ result.uuid }}">
<img src="https://{{ domain }}/{{ result.thumbnailPath }}" height="150"/>
</a>
</td>
<td>
<a href="/{{ domain }}/watch/{{ result.uuid }}">{{ result.name }}</a>
<br>
{{ result.views }} Views
<br>
<b>{{ result.channel.displayName }}</b>
</td>
</tr>
{% endfor %}
</table>
</body>
</html>
{% extends "base.html" %}
{% block title %}{{ search_term }} - {{ domain }}{% endblock %}
{% block content %}
<p>{{ amount }} results</p>
<table>
{% for result in results %}
<tr>
<td>
<a href="/{{ domain }}/watch/{{ result.uuid }}">
<img src="https://{{ domain }}/{{ result.thumbnailPath }}" height="150"/>
</a>
</td>
<td>
<a href="/{{ domain }}/watch/{{ result.uuid }}">{{ result.name }}</a>
<br>
{{ result.views }} Views
<br>
<b>{{ result.channel.displayName }}</b>
</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View File

@ -1,64 +1,65 @@
<!doctype html>
<html>
<body>
<h3>{{ video.name }}</h3>
By:
<b>{{ video.channel.displayName }}</b> ({{ video.channel.name }}@{{ video.channel.host }})
<br>
{% if video.no_quality_selected and not embed %}
<img height="300" src="https://{{ video.channel.host }}{{ video.thumbnailPath }}">
<p style="color: red">Please select a resolution:</p>
{% elif embed %}
<embed height="300" src="https://{{ video.channel.host }}{{ video.embedPath }}">
<br>
<b>Resolutions:</b>
{% else %}
<video height="300" controls>
<source src="{{ video.video }}">
</video>
<br>
<b>Resolutions:</b>
{% endif %}
{% extends "base.html" %}
{% for resolution in video.resolutions %}
<a href="?quality={{ resolution.id }}">{{ resolution.label }}</a>
{% endfor %}
<a href="?embed=1">Embedded</a>
<br>
Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{ video.dislikes }}</b>
{% block title %}{{ video.name }} - {{ domain }}{% endblock %}
<br>
<br>
{{ video.description }}
<br>
<br>
{% block content %}
<h3>{{ video.name }}</h3>
By:
<b>{{ video.channel.displayName }}</b> ({{ video.channel.name }}@{{ video.channel.host }})
<br>
{% if video.no_quality_selected and not embed %}
<img height="300" src="https://{{ video.channel.host }}{{ video.thumbnailPath }}">
<p style="color: red">Please select a resolution:</p>
{% elif embed %}
<embed height="300" src="https://{{ video.channel.host }}{{ video.embedPath }}">
<br>
<b>Resolutions:</b>
{% else %}
<video height="300" controls>
<source src="{{ video.video }}">
</video>
<br>
<b>Resolutions:</b>
{% endif %}
<table>
<tr>
<td><b>Category</b></td>
<td>{{ video.category.label }}</td>
</tr>
<tr>
<td><b>License</b></td>
<td>{{ video.licence.label }}</td>
</tr>
<tr>
<td><b>Language</b></td>
<td>{{ video.language.label }}</td>
</tr>
<tr>
<td><b>Privacy</b></td>
<td>{{ video.privacy.label }}</td>
</tr>
<tr>
<td><b>Tags</b></td>
<td>
{% for tag in video.tags %}
{{ tag }}
{% endfor %}
</td>
</tr>
</table>
</body>
</html>
{% for resolution in video.resolutions %}
<a href="?quality={{ resolution.id }}">{{ resolution.label }}</a>
{% endfor %}
<a href="?embed=1">Embedded</a>
<br>
Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{ video.dislikes }}</b>
<br>
<br>
{{ video.description }}
<br>
<br>
<table>
<tr>
<td><b>Category</b></td>
<td>{{ video.category.label }}</td>
</tr>
<tr>
<td><b>License</b></td>
<td>{{ video.licence.label }}</td>
</tr>
<tr>
<td><b>Language</b></td>
<td>{{ video.language.label }}</td>
</tr>
<tr>
<td><b>Privacy</b></td>
<td>{{ video.privacy.label }}</td>
</tr>
<tr>
<td><b>Tags</b></td>
<td>
{% for tag in video.tags %}
{{ tag }}
{% endfor %}
</td>
</tr>
</table>
{% endblock %}