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,12 +1,15 @@
<!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>
<table>
{% for result in results %}
<tr>
<td> <td>
<a href="/{{ domain}}/watch/{{ result.uuid }}"> <a href="/{{ domain }}/watch/{{ result.uuid }}">
<img src="https://{{ domain }}/{{ result.thumbnailPath }}" height="150"/> <img src="https://{{ domain }}/{{ result.thumbnailPath }}" height="150"/>
</a> </a>
</td> </td>
@ -17,8 +20,7 @@
<br> <br>
<b>{{ result.channel.displayName }}</b> <b>{{ result.channel.displayName }}</b>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</body> {% endblock %}
</html>

View file

@ -1,40 +1,42 @@
<!doctype html> {% extends "base.html" %}
<html>
<body> {% block title %}{{ video.name }} - {{ domain }}{% endblock %}
<h3>{{ video.name }}</h3>
By: {% block content %}
<b>{{ video.channel.displayName }}</b> ({{ video.channel.name }}@{{ video.channel.host }}) <h3>{{ video.name }}</h3>
<br> By:
{% if video.no_quality_selected and not embed %} <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 }}"> <img height="300" src="https://{{ video.channel.host }}{{ video.thumbnailPath }}">
<p style="color: red">Please select a resolution:</p> <p style="color: red">Please select a resolution:</p>
{% elif embed %} {% elif embed %}
<embed height="300" src="https://{{ video.channel.host }}{{ video.embedPath }}"> <embed height="300" src="https://{{ video.channel.host }}{{ video.embedPath }}">
<br> <br>
<b>Resolutions:</b> <b>Resolutions:</b>
{% else %} {% else %}
<video height="300" controls> <video height="300" controls>
<source src="{{ video.video }}"> <source src="{{ video.video }}">
</video> </video>
<br> <br>
<b>Resolutions:</b> <b>Resolutions:</b>
{% endif %} {% endif %}
{% for resolution in video.resolutions %} {% for resolution in video.resolutions %}
<a href="?quality={{ resolution.id }}">{{ resolution.label }}</a> <a href="?quality={{ resolution.id }}">{{ resolution.label }}</a>
{% endfor %} {% endfor %}
<a href="?embed=1">Embedded</a> <a href="?embed=1">Embedded</a>
<br> <br>
Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{ video.dislikes }}</b> Views: <b>{{ video.views }}</b> Likes: <b>{{ video.likes }}</b> Dislikes: <b>{{ video.dislikes }}</b>
<br> <br>
<br> <br>
{{ video.description }} {{ video.description }}
<br> <br>
<br> <br>
<table> <table>
<tr> <tr>
<td><b>Category</b></td> <td><b>Category</b></td>
<td>{{ video.category.label }}</td> <td>{{ video.category.label }}</td>
@ -59,6 +61,5 @@
{% endfor %} {% endfor %}
</td> </td>
</tr> </tr>
</table> </table>
</body> {% endblock %}
</html>