Added some api functions, an express server for the API and nunjucks

Added nunjucks templates for frontend pages.
This commit is contained in:
knotteye
2019-09-28 21:43:25 -05:00
parent 085dd02148
commit b0533f973b
16 changed files with 1954 additions and 5 deletions

1
templates/about.html Normal file
View File

@ -0,0 +1 @@
<p>Add a description of your instance here!</p>

4
templates/about.njk Normal file
View File

@ -0,0 +1,4 @@
{% extends "base.njk" %}
{% block content %}
{% include "about.html" %}
{% endblock %}

33
templates/base.njk Normal file
View File

@ -0,0 +1,33 @@
<!DOCTYPE html>
<head>
<link rel="stylesheet" type="text/css" href="/styles.css">
<title>{{ sitename }}</title>
</head>
<body>
<div id="wrapper">
<div id="header">
<span style="float:left;"><h4><a href="/">{{ sitename }}</a> | <a href="/users/live">Live</a> <a href="/users">Users</a> <a href="/about">About</a></h4></span><span style="float:right;"><h4>| <a href="/login">Login</a></h4></span>
</div>
<div id="content">
{% block content %}
{% endblock %}
</div>
<div id="footer">
<div>
<div>
<b>Satyr</b></br>
<a href="https://gitlab.com/knotteye/satyr">About</a></br>
<a href="">v0.1.0</a>
</div>
<div>
<img src="/satyr.png" height="50" />
</div>
<div>
<b>{{ sitename }}</b></br>
<a href="/about">About</a></br>
<a href="mailto:{{ email }}">Contact</a>
</div>
</div>
</div>
</div>
</body>

4
templates/index.njk Normal file
View File

@ -0,0 +1,4 @@
{% extends "base.njk" %}
{% block content %}
What to put on index?
{% endblock %}

0
templates/login.njk Normal file
View File

0
templates/profile.njk Normal file
View File

View File

@ -0,0 +1,16 @@
{% extends "base.njk" %}
{% block content %}
<div id="jscontainer" style="height: 100%;">
<div id="jschild" style="width: 50%;height: 100%;text-align: left;margin: 20px;">
<form action="/api/register" method="POST" target="_self">
Username: </br><input type="text" name="username" style="min-width: 300px" placeholder="e.g. lain"/></br>
Password: </br><input type="password" name="password" style="min-width: 300px"/></br>
Request Stream Key: <input type="checkbox" name="streamer" value="true" style="min-heigh: 50px;"> </br>
<input type="submit" value="Submit">
</form>
</div>
<div id="jschild" style="width: 50%;height: 100%;text-align: left;margin: 20px;">
{% include "tos.html" %}
</div>
</div>
{% endblock %}

2
templates/tos.html Normal file
View File

@ -0,0 +1,2 @@
This is example terms of service!</br>
You should change it by editing templates/tos.html

31
templates/user.njk Normal file
View File

@ -0,0 +1,31 @@
{% extends "base.njk" %}
{% block content %}
<span style="float: left;font-size: large;"><b>{{ user | capitalize }}'s Stream</b></span><span style="float: right;font-size: large;">Direct Links: <a href="rtmp://{{ domain }}/live/{{ user }}">RTMP</a> <a href="/live/{{ user }}/index.m3u8">HLS</a></span>
<div id="jscontainer">
<div id="jschild" style="width: 70%;height: 100%;">
<video controls poster="/thumbnail.jpg" class="video-js vjs-default-skin" id="live-video" style="width:100%;height:100%;"></video>
</div>
<div id="jschild" style="width: 30%;height: 100%;">
<img src="/chat.jpg" style="width: 100%;height: 100%" />
</div>
</div>
<script>window.HELP_IMPROVE_VIDEOJS = false;</script>
<script src="/videojs/video.min.js"></script>
<link rel="stylesheet" type="text/css" href="/videojs/video-js.min.css">
<script>
var player = videojs('live-video', {
html: {
nativeCaptions: false,
},
});
player.ready(function() {
player.on("error", () => {
document.querySelector(".vjs-modal-dialog-content").textContent = "The stream is currently offline.";
});
player.src({
src: '/live/{{ user }}/index.m3u8',
type: 'application/x-mpegURL'
});
})
</script></br>
{% endblock %}