songs2slides

A tool that automatically finds song lyrics and creates lyric slideshows
git clone https://git.ashermorgan.net/songs2slides/
Log | Files | Refs | README

commit 1bba3c4a3aedd95e07a4c3f871642d8c279b16b2
parent 3163645c5df48cbb55eedd78e6180a2c924bc399
Author: Asher Morgan <59518073+ashermorgan@users.noreply.github.com>
Date:   Thu, 28 Mar 2024 19:45:39 -0700

Create post-download page

Diffstat:
Msongs2slides/routes.py | 4++++
Msongs2slides/static/create.js | 16+++++++++++-----
Asongs2slides/static/post-download.css | 3+++
Msongs2slides/templates/create-step-2.html | 12+++---------
Asongs2slides/templates/post-download.html | 14++++++++++++++
5 files changed, 35 insertions(+), 14 deletions(-)

diff --git a/songs2slides/routes.py b/songs2slides/routes.py @@ -73,6 +73,10 @@ def create_step_2(): # Return song data return render_template('create-step-2.html', songs=songs, missing=missing) +@bp.get('/post-download/') +def post_download(): + return render_template('post-download.html') + @bp.get('/slides/') def slides_get(): # GET requests not allowed, redirect to home page diff --git a/songs2slides/static/create.js b/songs2slides/static/create.js @@ -3,16 +3,22 @@ addEventListener('submit', () => { // Show step 1 spinner document.getElementById('post-submit').hidden = false } else if (document.querySelector('input[value=pptx]').checked) { - // Show step 2 downloading message and hide step 2 form - document.getElementById('post-submit').hidden = false - document.getElementById('step-2').hidden = true + // Redirect to post download message + // (REDIRECT_URL set in create-step-2.html template) + setTimeout(() => { + // On Chrome, redirecting after a form submission doesn't work + // unless setTimeout is used + window.location.href = REDIRECT_URL + }, 100) } }) addEventListener('pageshow', () => { // Correct page state after returning via browser back button - document.getElementById('post-submit').hidden = true - document.getElementsByTagName('form')[0].hidden = false + if (document.getElementById('step-1')) { + document.getElementById('post-submit').hidden = true + document.getElementById('step-1').hidden = false + } }) /* step 1 functions */ diff --git a/songs2slides/static/post-download.css b/songs2slides/static/post-download.css @@ -0,0 +1,3 @@ +main { + text-align: center; +} diff --git a/songs2slides/templates/create-step-2.html b/songs2slides/templates/create-step-2.html @@ -93,13 +93,7 @@ </div> </form> -<div id="post-submit" hidden> - <p> - Your slide show is being downloaded, - thank you for using Songs2Slides. - </p> - <p> - <a href="{{ url_for('.create_step_1') }}">Create another slide show</a> - </p> -</div> +<script> + const REDIRECT_URL = "{{ url_for('.post_download') }}" +</script> {% endblock main %} diff --git a/songs2slides/templates/post-download.html b/songs2slides/templates/post-download.html @@ -0,0 +1,14 @@ +{% extends "layout.html" %} + +{% block head %} +<link rel="stylesheet" href="{{ url_for('static', filename='post-download.css') }}"/> +{% endblock head %} + +{% block main %} +<p> + Thank you for using Songs2Slides +</p> +<p> + <a href="{{ url_for('.create_step_1') }}">Create another slide show</a> +</p> +{% endblock main %}