commit ed9a91e93ded0d0c042148debc34c83d0a707f87 parent 2318cfbab37c52a16f25869b389393be8596ea9b Author: ugrnm <ultrageranium@bleu255.com> Date: Mon, 13 Jun 2022 14:56:10 +0200 fix_local_href.sh Diffstat:
| A | _tools/fix_local_href.sh | | | 28 | ++++++++++++++++++++++++++++ |
1 file changed, 28 insertions(+), 0 deletions(-)
diff --git a/_tools/fix_local_href.sh b/_tools/fix_local_href.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# +# if you call ikiwiki directly to generate HTML files to browse locally +# you will be disapointed as ikiwiki links points to folder in which an +# index.html will be found. This is fine for an HTTP server as most will +# default sending the index.html to the browser upon folder URL request. +# However, if you browse locally, the web browser will display the content +# of the folder instead. Making navigation super annoying. This script to +# be run everytime a new static version is built will fix all the href to +# actually point to the index.html instead of pointing to the folder. + + +# I don't trust you +if [ -z "${1}" -o ! -e "${1}/ikiwiki" ] +then + echo "[!] please point to ikiwiki HTML folder" + echo "[.] usage ./fix_local_href.sh some/path/to/html_wiki" + exit 1 +else + INDEXES="$(find ${1} -iname index.html)" # inb4 -exec jaja nope + for INDEX in ${INDEXES} + do + echo ${INDEX} + sed -i 's/href="\(\(\|\/\|.\/\|..\/\)[[:alnum:]_-]*\(\|\/\)\)">/href="\1index.html">/g' ${INDEX} + done +fi + +