mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-06-01 07:18:27 -04:00
add new timezone autosetting and cache header setting middlewares
This commit is contained in:
parent
1977ae8962
commit
cf7d7e4990
4 changed files with 76 additions and 6 deletions
|
@ -1,5 +1,4 @@
|
|||
{% load admin_urls %}
|
||||
{% load static %}
|
||||
{% load static tz admin_urls %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
@ -66,6 +65,35 @@
|
|||
</footer>
|
||||
{% endblock %}
|
||||
</div>
|
||||
<script>
|
||||
// hide images that fail to load
|
||||
document.querySelector('body').addEventListener('error', function (e) {
|
||||
e.target.style.opacity = 0;
|
||||
}, true)
|
||||
|
||||
// setup timezone
|
||||
{% get_current_timezone as TIME_ZONE %}
|
||||
window.TIME_ZONE = '{{TIME_ZONE}}'
|
||||
|
||||
window.setCookie = function(name, value, days) {
|
||||
let expires = ""
|
||||
if (days) {
|
||||
const date = new Date()
|
||||
date.setTime(date.getTime() + (days*24*60*60*1000))
|
||||
expires = "; expires=" + date.toUTCString()
|
||||
}
|
||||
document.cookie = name + "=" + (value || "") + expires + "; path=/"
|
||||
}
|
||||
|
||||
function setTimeOffset() {
|
||||
if (window.GMT_OFFSET) return
|
||||
window.GMT_OFFSET = -(new Date).getTimezoneOffset()
|
||||
window.setCookie('GMT_OFFSET', window.GMT_OFFSET, 365)
|
||||
}
|
||||
|
||||
jQuery(document).ready(function () {
|
||||
setTimeOffset();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue