fix: remove AppCache (due to deprecation)

This commit is contained in:
relikd
2022-07-14 01:22:28 +02:00
parent 31bf5f443a
commit ff1dc6af43
10 changed files with 7 additions and 110 deletions

View File

@@ -1,5 +1,4 @@
(function(){// main entry
handleAppCache();
updateViewport();
})();
function updateViewport() {// show at least 2 columns on mobile devices
@@ -12,22 +11,6 @@ function updateViewport() {// show at least 2 columns on mobile devices
document.head.appendChild(x);
}
}
function handleAppCache() {// update cache status icon
var cache = window.applicationCache;
if (cache) {
cache.addEventListener('updateready', update);
cache.addEventListener('cached', ready); // initial
cache.addEventListener('noupdate', ready); // consecutive
cache.addEventListener('downloading', busy);
cache.addEventListener('obsolete', failed);
if(cache.status===cache.UPDATEREADY){update()}
if(cache.status===cache.IDLE){window.onload=(event)=>{ready()};}
function update(){ready(); cache.swapCache(); window.location.reload()}
function busy(){document.getElementById('cache-status').style='background:darkorange'}
function ready(){document.getElementById('cache-status').style='background:forestgreen'}
function failed(){document.getElementById('cache-status').style='background:red'}
}
}
/*! lozad.js - v1.9.0 - 2019-02-09
* https://github.com/ApoorvSaxena/lozad.js
* Copyright (c) 2019 Apoorv Saxena; Licensed MIT */

View File

@@ -47,10 +47,6 @@ body {
background: var(--cBg3); color: var(--cTxt);
}
#logo { font-size: 42px; display: block; margin-bottom: 15px }
#cache-status {
position: absolute; right: 10px; top: 10px;
border-radius: 50%; width: 10px; height: 10px;
}
header { position: relative }
header a { color: var(--cTxt) }
header, h1 { text-align: center }

View File

@@ -1,2 +0,0 @@
enabled = yes
endswith = .appcache

View File

@@ -1,3 +0,0 @@
_template: cache.manifest
---
_model: none

View File

@@ -166,15 +166,8 @@ class HelperPlugin(Plugin):
# Event hooks
# -----------
def processCLI(self, extra_flags):
useCache = bool(extra_flags.get('ENABLE_APPCACHE'))
plugin = get_plugin('force-update', self.env)
if plugin.enabled and not useCache:
plugin.enabled = False
print('AppCache: ' + ('ENABLED' if useCache else 'DISABLED'))
self.env.jinja_env.globals['ENABLE_APPCACHE'] = useCache
def processSettings(self):
def on_before_build_all(self, builder, **extra):
# update project settings once per build
bag = Databags(self.env)
pad = self.env.new_pad()
for alt in self.env.load_config().iter_alternatives():
@@ -185,14 +178,6 @@ class HelperPlugin(Plugin):
'replFrac': set['replace_frac']
}
def on_before_build_all(self, builder, **extra):
build_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
print('Build time: ' + build_time)
self.env.jinja_env.globals['DATE_NOW'] = build_time
# update project settings once per build
self.processCLI(getattr(builder, 'extra_flags'))
self.processSettings()
# def on_process_template_context(self, context, **extra):
# pass

View File

@@ -1,54 +0,0 @@
CACHE MANIFEST
# Date build: {{ DATE_NOW }}
{%- macro _print_(items) -%}
{%- for item in items if not item.endswith('tex') -%}
{{ item }}
{% endfor -%}
{%- endmacro -%}
{%- macro _add_(list, item) -%}
{{- list.append(item|url) or pass -}}
{%- endmacro -%}
{%- set root = site.get('/', this.alt) -%}
{%- set assetList = [] -%}
{%- for asset in root.pad.asset_root.children recursive -%}
{%- if asset.__class__.__name__ != 'Directory' -%}
{{- _add_(assetList, asset) -}}
{%- endif -%}
{{- loop(asset.children) -}}
{%- endfor -%}
{%- set cacheList = [] -%}
{{- _add_(cacheList, root) -}}
{%- for x in root.children if x != this recursive -%}
{{- _add_(cacheList, x) -}}
{%- set pg = x.datamodel.pagination_config -%}
{%- if pg.enabled -%}
{%- for page in range(2, pg.count_pages(x) + 1) -%}
{{- _add_(cacheList, pg.get_record_for_page(x, page)) -}}
{%- endfor -%}
{%- endif -%}
{#{% set img = x | title_image(small=True) -%}
{%- if img -%}
{{- _add_(cacheList, img) -}}
{%- endif -%}#}
{%- if x.datamodel.has_own_children -%}
{{- loop(x.children) -}}
{%- endif -%}
{%- endfor -%}
{#- Generate cache file index #}
# static
{{ _print_(assetList) -}}
# index
{{ _print_(cacheList) -}}
{#- All other requests are forwarded #}
NETWORK:
*

View File

@@ -1,7 +1,4 @@
<!doctype html>
{%- if ENABLE_APPCACHE %}
<html manifest="{{ site.get('app.appcache', alt=this.alt)|url }}">
{% endif -%}
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.75">
@@ -16,9 +13,6 @@
<body> {#- ontouchstart="" #}
<header>
<a id="logo" href="{{ site.get('/', alt=this.alt)|url }}">recipe lekture</a>
{%- if ENABLE_APPCACHE %}
<i id="cache-status" title="cache status"></i>
{%- endif %}
<nav>
<ul>
{%- set allRecipes = site.get('recipes', this.alt) %}