diff options
Diffstat (limited to 'fetch-images.sh')
-rwxr-xr-x | fetch-images.sh | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/fetch-images.sh b/fetch-images.sh new file mode 100755 index 0000000..4f4884b --- /dev/null +++ b/fetch-images.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# startdate 2020-05-29 20:04 +# After running this, be sure to do the sed. +# sed -i -f fix-images-in-html.sed /mnt/public/www/issues/*.html +# Improve: +# It is probably an artifact of the weird way the asset svgs are embedded, but I cannot get them to display at all even though they are downloaded successfully. I have seen this before, the little embedded images you cannot easily download and simply display. + +INDIR=/mnt/public/www/issues +INGLOB=*.html + +SEDSCRIPT=/mnt/public/work/devuan/fix-images-in-html.sed + +INSERVER=https://git.devuan.org + +cd "${INDIR}" + +# could use this line to get all the assets, but they do not display regardless due to html weirdness +#orig_src="$( grep -oE '(\<src|xlink:href)="?\/[^"]*"' ${INGLOB} | grep -vE '\.js' | awk -F'"' '!x[$0]++{print $2}' )" +orig_src="$( grep -oE '\<src="?\/[^"]*"' ${INGLOB} | grep -vE '\.js' | awk -F'"' '!x[$2]++{print $2}' )" + +cat /dev/null > "${SEDSCRIPT}" + +echo "${orig_src}" | while read line ; do + #echo "${line}" | awk -F'"' '{print $2}' + getpath="${INSERVER}${line}" + outdir="$( echo "${line}" | awk -F'/' '{print $2}' )" + test ! -d "${outdir}" && mkdir -p "${outdir}" + targetfile="${outdir}/$( basename "${line}" )" + test -n "${DEBUG}" && echo "process ${getpath} and save to ${targetfile}" 1>&2 + test -z "${DRYRUN}" && wget --quiet --content-disposition -O "${targetfile}" "${getpath}" + # dynamically build a sed script + echo "s:${line}:${targetfile##/}:g;" | tee -a "${SEDSCRIPT}" +done |