turbolinks: Reload page using JavaScript

Using the existing meta tag for refresh as a noscript fallback.

Fixes #1350

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Joseph Nuthalapati 2018-08-10 18:02:06 +05:30 committed by James Valleroy
parent 8f88f0f6b4
commit 36774c9f41
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
7 changed files with 92 additions and 8 deletions

View File

@ -19,11 +19,14 @@
{% endcomment %}
{% load i18n %}
{% load static %}
{% block page_head %}
{% if is_running %}
<meta http-equiv="refresh" content="3" />
<noscript>
<meta http-equiv="refresh" content="3" />
</noscript>
{% endif %}
{% endblock %}
@ -73,3 +76,11 @@
{% endif %}
{% endblock %}
{% block page_js %}
{% if is_running %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
{% endif %}
{% endblock %}

View File

@ -20,11 +20,14 @@
{% load bootstrap %}
{% load i18n %}
{% load static %}
{% block page_head %}
{% if running %}
<meta http-equiv="refresh" content="3"/>
<noscript>
<meta http-equiv="refresh" content="3" />
</noscript>
{% endif %}
<style type="text/css">
@ -157,3 +160,10 @@
</table>
{% endblock %}
{% block page_js %}
{% if running %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
{% endif %}
{% endblock %}

View File

@ -20,11 +20,14 @@
{% load bootstrap %}
{% load i18n %}
{% load static %}
{% block page_head %}
{% if status.setup_running %}
<meta http-equiv="refresh" content="3" />
<noscript>
<meta http-equiv="refresh" content="3" />
</noscript>
{% endif %}
{% endblock %}
@ -126,3 +129,9 @@
{% endif %}
{% endblock %}
{% block page_js %}
{% if status.setup_running %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
{% endif %}
{% endblock %}

View File

@ -20,11 +20,14 @@
{% load bootstrap %}
{% load i18n %}
{% load static %}
{% block page_head %}
{% if config_running %}
<meta http-equiv="refresh" content="3" />
<noscript>
<meta http-equiv="refresh" content="3" />
</noscript>
{% endif %}
{% endblock %}
@ -168,4 +171,9 @@
// @license-end
</script>
{% if config_running %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
{% endif %}
{% endblock %}

View File

@ -19,11 +19,14 @@
{% endcomment %}
{% load i18n %}
{% load static %}
{% block page_head %}
{% if is_busy %}
<meta http-equiv="refresh" content="3"/>
<noscript>
<meta http-equiv="refresh" content="3" />
</noscript>
{% endif %}
{% endblock %}
@ -72,4 +75,9 @@
$('.details').toggle("slow");
});
</script>
{% if is_busy %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
{% endif %}
{% endblock %}

View File

@ -23,11 +23,11 @@
{% load static %}
{% block page_head %}
{% if setup_helper.current_operation %}
<meta http-equiv="refresh" content="3" />
<noscript>
<meta http-equiv="refresh" content="3" />
</noscript>
{% endif %}
{% endblock %}
{% block content %}
@ -131,3 +131,12 @@
{% endif %}
{% endblock %}
{% block page_js %}
{% if setup_helper.current_operation %}
<script type="text/javascript" src="{% static 'theme/js/refresh.js' %}"></script>
{% endif %}
{% endblock %}

View File

@ -0,0 +1,29 @@
/*
This file is part of FreedomBox.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
// Refresh the page once in n seconds
async function refresh(ms) {
await sleep(ms);
window.location.reload();
}
refresh(3000);