commit 262572a56deda8cd172af7ed94c3d358f07972a4 parent 6f28f25b0bbda721c6df32f90fcdf23e3603df1c Author: JayVii <jayvii[AT]posteo[DOT]de> Date: Thu, 12 Dec 2024 11:00:02 +0100 feat: use fallback favicon Diffstat:
A | assets/fallback-site-icon.png | | | 0 | |
M | fetch_favicon.sh | | | 22 | +++++++++++++++++++--- |
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/assets/fallback-site-icon.png b/assets/fallback-site-icon.png Binary files differ. diff --git a/fetch_favicon.sh b/fetch_favicon.sh @@ -24,6 +24,17 @@ for DOMAIN in $DOMAINS; do # User output printf "Fetching favicon for ${DOMAIN}...\n" + # Only refresh favicons every 24hours + if [ -f "./assets/site-icons/${DOMAIN}" ]; then + NOW=`date +%s` + TST=`date -r "assets/site-icons/${DOMAIN}" +%s` + DIF=`echo "$NOW - $TST" | bc` + if [ $DIF -lt 86400 ]; then + printf "Skipping!\n" + continue; # skip for-loop item + fi + fi + # read HTML of webpage HTML=`curl --silent --location "$DOMAIN"` @@ -45,9 +56,14 @@ for DOMAIN in $DOMAINS; do ` # Download Favicon to assets folder - curl --silent --location \ - --output "./assets/site-icons/${DOMAIN}" \ - "$ICN_URL" + # If no favicon URL could be found, link a fallback icon + if [ ! -z $ICN_URL ]; then + curl --silent --location \ + --output "./assets/site-icons/${DOMAIN}" \ + "$ICN_URL" + else + cp ./assets/fallback-site-icon.png ./assets/site-icons/${DOMAIN} + fi done