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): async def search(domain, term):
amount, results = peertube.search(domain, term) amount, results = peertube.search(domain, term)
return await render_template( 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> {% extends "base.html" %}
<html>
<body> {% block title %}{{ domain }}{% endblock %}
<b>{{ instance_name }}</b>
<form action="/{{ domain }}/search" method="POST"> {% block content %}
<input type="text" name="query" id="query"/> <b>{{ instance_name }}</b>
<button type="submit">Search</button> {% endblock %}
</form>
</body>
</html>

View File

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

View File

@ -1,64 +1,65 @@
<!doctype html> {% extends "base.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 %}
{% for resolution in video.resolutions %} {% block title %}{{ video.name }} - {{ domain }}{% endblock %}
<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> {% block content %}
<br> <h3>{{ video.name }}</h3>
{{ video.description }} By:
<br> <b>{{ video.channel.displayName }}</b> ({{ video.channel.name }}@{{ video.channel.host }})
<br> <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> {% for resolution in video.resolutions %}
<tr> <a href="?quality={{ resolution.id }}">{{ resolution.label }}</a>
<td><b>Category</b></td> {% endfor %}
<td>{{ video.category.label }}</td> <a href="?embed=1">Embedded</a>
</tr>
<tr> <br>
<td><b>License</b></td> Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{ video.dislikes }}</b>
<td>{{ video.licence.label }}</td>
</tr> <br>
<tr> <br>
<td><b>Language</b></td> {{ video.description }}
<td>{{ video.language.label }}</td> <br>
</tr> <br>
<tr>
<td><b>Privacy</b></td> <table>
<td>{{ video.privacy.label }}</td> <tr>
</tr> <td><b>Category</b></td>
<tr> <td>{{ video.category.label }}</td>
<td><b>Tags</b></td> </tr>
<td> <tr>
{% for tag in video.tags %} <td><b>License</b></td>
{{ tag }} <td>{{ video.licence.label }}</td>
{% endfor %} </tr>
</td> <tr>
</tr> <td><b>Language</b></td>
</table> <td>{{ video.language.label }}</td>
</body> </tr>
</html> <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 %}