mirror of
https://git.sr.ht/~metalune/simpleweb_peertube
synced 2024-12-22 13:43:57 +01:00
Add start page
This commit is contained in:
parent
da472ed5f9
commit
109da9e9a4
45
main.py
45
main.py
@ -109,12 +109,53 @@ async def main():
|
||||
|
||||
|
||||
@app.route("/<string:domain>/")
|
||||
async def domain_main(domain):
|
||||
async def instance(domain):
|
||||
return redirect("/" + domain + "/videos/trending")
|
||||
|
||||
@app.route("/<string:domain>/videos/local")
|
||||
async def instance_videos_local(domain):
|
||||
return await render_template(
|
||||
"domain_index.html",
|
||||
"instance/local.html",
|
||||
domain=domain,
|
||||
instance_name=get_instance_name(domain),
|
||||
commit=commit,
|
||||
|
||||
videos = peertube.get_videos_local(domain),
|
||||
)
|
||||
|
||||
@app.route("/<string:domain>/videos/trending")
|
||||
async def instance_videos_trending(domain):
|
||||
return await render_template(
|
||||
"instance/trending.html",
|
||||
domain=domain,
|
||||
instance_name=get_instance_name(domain),
|
||||
commit=commit,
|
||||
|
||||
videos = peertube.get_videos_trending(domain),
|
||||
)
|
||||
|
||||
|
||||
@app.route("/<string:domain>/videos/most-liked")
|
||||
async def instance_videos_most_liked(domain):
|
||||
return await render_template(
|
||||
"instance/most-liked.html",
|
||||
domain=domain,
|
||||
instance_name=get_instance_name(domain),
|
||||
commit=commit,
|
||||
|
||||
videos = peertube.get_videos_most_liked(domain),
|
||||
)
|
||||
|
||||
|
||||
@app.route("/<string:domain>/videos/recently-added")
|
||||
async def instance_videos_recently_added(domain):
|
||||
return await render_template(
|
||||
"instance/recently-added.html",
|
||||
domain=domain,
|
||||
instance_name=get_instance_name(domain),
|
||||
commit=commit,
|
||||
|
||||
videos = peertube.get_videos_recently_added(domain),
|
||||
)
|
||||
|
||||
|
||||
|
16
peertube.py
16
peertube.py
@ -28,6 +28,22 @@ def get_comments(domain, id):
|
||||
url = "https://" + domain + "/api/v1/videos/" + id + "/comment-threads"
|
||||
return json.loads(requests.get(url).text)
|
||||
|
||||
def get_videos_trending(domain):
|
||||
url = "https://" + domain + "/api/v1/videos?sort=-trending"
|
||||
return json.loads(requests.get(url).text)
|
||||
|
||||
def get_videos_most_liked(domain):
|
||||
url = "https://" + domain + "/api/v1/videos?sort=-likes"
|
||||
return json.loads(requests.get(url).text)
|
||||
|
||||
def get_videos_recently_added(domain):
|
||||
url = "https://" + domain + "/api/v1/videos?sort=-publishedAt"
|
||||
return json.loads(requests.get(url).text)
|
||||
|
||||
def get_videos_local(domain):
|
||||
url = "https://" + domain + "/api/v1/videos?sort=-publishedAt&filter=local"
|
||||
return json.loads(requests.get(url).text)
|
||||
|
||||
# --- Accounts ---
|
||||
|
||||
def account_video_channels(domain, name):
|
||||
|
@ -1,7 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ domain }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<table>
|
||||
<tr>
|
||||
|
@ -15,7 +15,16 @@
|
||||
</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>
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
<footer>
|
||||
|
@ -1,7 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ domain }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<b>{{ instance_name }}</b>
|
||||
{% endblock %}
|
30
templates/instance/local.html
Normal file
30
templates/instance/local.html
Normal file
@ -0,0 +1,30 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block full_title %}{{ instance_name }} - Local{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<table>
|
||||
{% for video in videos.data %}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="https://{{ domain }}/{{ video.thumbnailPath }}" height="150"/>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
|
||||
<br>
|
||||
{{ video.views }} Views
|
||||
<br>
|
||||
<a href="/{{ domain }}/accounts/{{ video.channel.name }}@{{ video.channel.host }}">
|
||||
<b>{{ video.channel.displayName }}</b>
|
||||
</a>
|
||||
<br>
|
||||
<a href="/{{ domain }}/accounts/{{ video.account.name }}@{{ video.account.host }}">
|
||||
{{ video.account.name }}@{{ video.account.host }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
30
templates/instance/most-liked.html
Normal file
30
templates/instance/most-liked.html
Normal file
@ -0,0 +1,30 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block full_title %}{{ instance_name }} - Most Liked{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<table>
|
||||
{% for video in videos.data %}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="https://{{ domain }}/{{ video.thumbnailPath }}" height="150"/>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
|
||||
<br>
|
||||
{{ video.views }} Views
|
||||
<br>
|
||||
<a href="/{{ domain }}/accounts/{{ video.channel.name }}@{{ video.channel.host }}">
|
||||
<b>{{ video.channel.displayName }}</b>
|
||||
</a>
|
||||
<br>
|
||||
<a href="/{{ domain }}/accounts/{{ video.account.name }}@{{ video.account.host }}">
|
||||
{{ video.account.name }}@{{ video.account.host }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
30
templates/instance/recently-added.html
Normal file
30
templates/instance/recently-added.html
Normal file
@ -0,0 +1,30 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block full_title %}{{ instance_name }} - Recently Added{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<table>
|
||||
{% for video in videos.data %}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="https://{{ domain }}/{{ video.thumbnailPath }}" height="150"/>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
|
||||
<br>
|
||||
{{ video.views }} Views
|
||||
<br>
|
||||
<a href="/{{ domain }}/accounts/{{ video.channel.name }}@{{ video.channel.host }}">
|
||||
<b>{{ video.channel.displayName }}</b>
|
||||
</a>
|
||||
<br>
|
||||
<a href="/{{ domain }}/accounts/{{ video.account.name }}@{{ video.account.host }}">
|
||||
{{ video.account.name }}@{{ video.account.host }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
30
templates/instance/trending.html
Normal file
30
templates/instance/trending.html
Normal file
@ -0,0 +1,30 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block full_title %}{{ instance_name }} - Trending{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<table>
|
||||
{% for video in videos.data %}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="https://{{ domain }}/{{ video.thumbnailPath }}" height="150"/>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/{{ domain }}/videos/watch/{{ video.uuid }}">{{ video.name }}</a>
|
||||
<br>
|
||||
{{ video.views }} Views
|
||||
<br>
|
||||
<a href="/{{ domain }}/accounts/{{ video.channel.name }}@{{ video.channel.host }}">
|
||||
<b>{{ video.channel.displayName }}</b>
|
||||
</a>
|
||||
<br>
|
||||
<a href="/{{ domain }}/accounts/{{ video.account.name }}@{{ video.account.host }}">
|
||||
{{ video.account.name }}@{{ video.account.host }}
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
@ -1,7 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ domain }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<table>
|
||||
<tr>
|
||||
|
Loading…
Reference in New Issue
Block a user