Split templates for edit page

This commit is contained in:
Martin Müller 2017-07-18 13:41:34 +02:00
parent 1e40ad6661
commit e2687550f5
4 changed files with 76 additions and 24 deletions

View File

@ -55,3 +55,11 @@ def index(sound=None, text=None, video=None):
edit = False edit = False
return render_template("index.html", sounds=sounds, edit=edit) return render_template("index.html", sounds=sounds, edit=edit)
@app.route("/edit/<sound>", methods=["GET", "POST"])
def edit(sound):
if request.method == "POST":
# TODO: Store changes
return redirect("/edit")
return render_template("edit.html")

56
templates/base.html Normal file
View File

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>WIAI Soundboard</title>
<link rel="stylesheet" href="/static/main.css" />
</head>
<body>
{% block navigation %}
<nav>
<a href="#sounds">Sounds</a>
<a href="#youtube">YouTube</a>
<a href="#voice">Voice</a>
{% if not edit %}
<div class="extra"><a href="/edit">Edit</a></div>
{% else %}
<div class="extra"><a href="/">Done</a></div>
{% endif %}
</nav>
{% endblock %}
<content>
{% block content %}
<section id="sounds">
<div><input type="text" id="search" /><span id="reset"></span></div>
{% for sound in sounds %}
<div class="sound{{ ' edit' if edit }}"><a href="{{ '/' + ('edit' if edit else 'play') + '/' + sound | urlencode }}">{{ sound.split('.', 1)[0] }}</a></div>
{% endfor %}
</section>
<section id="youtube">
<form action="/" method="GET">
<label for="video">YouTube URL</label>
<input type="text" name="video" />
<input type="submit" value="Play" />
</form>
<form action="/" method="GET">
<input type="hidden" name="killvideo" value="yes" />
<input type="submit" name="submit" value="Terminate videos" />
</form>
</section>
<section id="voice">
<form action="/say/" method="POST">
<input type="text" name="text" />
<input type="text" name="voice" placeholder="DE" />
<label for="speed">Speed</label>
<input type="range" name="speed" min="80" max="450" step="10" value="160" id="speed" />
<label for="pitch">Pitch</label>
<input type="range" name="pitch" min="0" max="99" step="1" value="50" id="pitch" />
<input type="submit" value="Voice" />
</form>
</section>
{% endblock %}
</content>
<script src="/static/main.js"></script>
</body>
</html>

9
templates/edit.html Normal file
View File

@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block navigation %}
{% endblock %}
{% block content %}
<form action="{{ request.path }}" method="POST">
<input type="button" value="Cancel" />
<input type="submit" value="Submit" />
</form>
{% endblock %}

View File

@ -1,23 +1,5 @@
<!DOCTYPE html> {% extends "base.html" %}
<html> {% block content %}
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>WIAI Soundboard</title>
<link rel="stylesheet" href="/static/main.css" />
</head>
<body>
<nav>
<a href="#sounds">Sounds</a>
<a href="#youtube">YouTube</a>
<a href="#voice">Voice</a>
{% if not edit %}
<div class="extra"><a href="/edit">Edit</a></div>
{% else %}
<div class="extra"><a href="/">Done</a></div>
{% endif %}
</nav>
<content>
<section id="sounds"> <section id="sounds">
<div><input type="text" id="search" /><span id="reset"></span></div> <div><input type="text" id="search" /><span id="reset"></span></div>
{% for sound in sounds %} {% for sound in sounds %}
@ -46,7 +28,4 @@
<input type="submit" value="Voice" /> <input type="submit" value="Voice" />
</form> </form>
</section> </section>
</content> {% endblock %}
<script src="/static/main.js"></script>
</body>
</html>