Skip to content

Commit

Permalink
Create post-download page
Browse files Browse the repository at this point in the history
  • Loading branch information
ashermorgan committed Mar 29, 2024
1 parent 3163645 commit 1bba3c4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
4 changes: 4 additions & 0 deletions songs2slides/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 11 additions & 5 deletions songs2slides/static/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 3 additions & 0 deletions songs2slides/static/post-download.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
main {
text-align: center;
}
12 changes: 3 additions & 9 deletions songs2slides/templates/create-step-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,7 @@ <h1>Step 2: Preview Slides</h1>
</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 %}
14 changes: 14 additions & 0 deletions songs2slides/templates/post-download.html
Original file line number Diff line number Diff line change
@@ -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 %}

0 comments on commit 1bba3c4

Please sign in to comment.