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

@@ -49,7 +49,7 @@ server:
build: dist build: dist
@cd '$(PROJDIR)' && \ @cd '$(PROJDIR)' && \
lektor build --output-path ../bin --buildstate-path ../build-state -f ENABLE_PDF_EXPORT # -f ENABLE_APPCACHE lektor build --output-path ../bin --buildstate-path ../build-state -f ENABLE_PDF_EXPORT
@echo @echo
@echo 'Checking dead links ...' @echo 'Checking dead links ...'
@python3 extras/find-dead-links.py @python3 extras/find-dead-links.py

View File

@@ -10,11 +10,11 @@ Features
------- -------
- Responsive design (desktop, mobile, print) - Responsive design (desktop, mobile, print)
- Mobile application (AppCache & app manifest) - Mobile Web-Application
- Offline cache (local storage [150 recipes ~ 3mb])
- Multi-language (DE & EN, more can be added) - Multi-language (DE & EN, more can be added)
- Blazing fast (due to cache and minimal data usage) - Blazing fast due to minimal data usage
- Indexed (group by time, ingredients, or tags) - Indexed (group by time, ingredients, or tags)
- PDF export (if LuaLaTex is installed)
- ~~static search~~ (**not yet**, but coming soon…) - ~~static search~~ (**not yet**, but coming soon…)
@@ -27,7 +27,7 @@ Install
3. Run `make dev server` to run a local server and preview the page. 3. Run `make dev server` to run a local server and preview the page.
4. For distribution run `make dist build` and add an [official deploy](https://www.getlektor.com/docs/deployment/). 4. For distribution run `make build pdf deploy` and add an [official deploy](https://www.getlektor.com/docs/deployment/).
### Modify ### Modify
@@ -41,7 +41,6 @@ A few things to note:
3. The preferred __image size__ is `800x600`. Please scale all images down to save bandwidth. Try to keep an aspect ratio of 4:3 for the first image, or it will be cropped on the recipe overview page! All other images will be shown unmodified in whatever aspect ratio is provided (individual recipe page) 3. The preferred __image size__ is `800x600`. Please scale all images down to save bandwidth. Try to keep an aspect ratio of 4:3 for the first image, or it will be cropped on the recipe overview page! All other images will be shown unmodified in whatever aspect ratio is provided (individual recipe page)
4. __AppCache__ is disabled during development. However, you can pass `-f ENABLE_APPCACHE` to any `lektor` command to enable it. The makefile does this by default for the `build` target.
Also, see [Lektor docs](https://www.getlektor.com/docs/) and [jinja2 template](https://jinja.palletsprojects.com/en/2.10.x/templates/) documentation. Also, see [Lektor docs](https://www.getlektor.com/docs/) and [jinja2 template](https://jinja.palletsprojects.com/en/2.10.x/templates/) documentation.

View File

@@ -1,5 +1,4 @@
(function(){// main entry (function(){// main entry
handleAppCache();
updateViewport(); updateViewport();
})(); })();
function updateViewport() {// show at least 2 columns on mobile devices 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); 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 /*! lozad.js - v1.9.0 - 2019-02-09
* https://github.com/ApoorvSaxena/lozad.js * https://github.com/ApoorvSaxena/lozad.js
* Copyright (c) 2019 Apoorv Saxena; Licensed MIT */ * Copyright (c) 2019 Apoorv Saxena; Licensed MIT */

View File

@@ -47,10 +47,6 @@ body {
background: var(--cBg3); color: var(--cTxt); background: var(--cBg3); color: var(--cTxt);
} }
#logo { font-size: 42px; display: block; margin-bottom: 15px } #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 { position: relative }
header a { color: var(--cTxt) } header a { color: var(--cTxt) }
header, h1 { text-align: center } 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 # Event hooks
# ----------- # -----------
def processCLI(self, extra_flags): def on_before_build_all(self, builder, **extra):
useCache = bool(extra_flags.get('ENABLE_APPCACHE')) # update project settings once per build
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):
bag = Databags(self.env) bag = Databags(self.env)
pad = self.env.new_pad() pad = self.env.new_pad()
for alt in self.env.load_config().iter_alternatives(): for alt in self.env.load_config().iter_alternatives():
@@ -185,14 +178,6 @@ class HelperPlugin(Plugin):
'replFrac': set['replace_frac'] '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): # def on_process_template_context(self, context, **extra):
# pass # 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> <!doctype html>
{%- if ENABLE_APPCACHE %}
<html manifest="{{ site.get('app.appcache', alt=this.alt)|url }}">
{% endif -%}
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=0.75"> <meta name="viewport" content="width=device-width, initial-scale=0.75">
@@ -16,9 +13,6 @@
<body> {#- ontouchstart="" #} <body> {#- ontouchstart="" #}
<header> <header>
<a id="logo" href="{{ site.get('/', alt=this.alt)|url }}">recipe lekture</a> <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> <nav>
<ul> <ul>
{%- set allRecipes = site.get('recipes', this.alt) %} {%- set allRecipes = site.get('recipes', this.alt) %}