fix_local_href.sh (1016B)
1 #!/bin/sh 2 # 3 # if you call ikiwiki directly to generate HTML files to browse locally 4 # you will be disapointed as ikiwiki links points to folder in which an 5 # index.html will be found. This is fine for an HTTP server as most will 6 # default sending the index.html to the browser upon folder URL request. 7 # However, if you browse locally, the web browser will display the content 8 # of the folder instead. Making navigation super annoying. This script to 9 # be run everytime a new static version is built will fix all the href to 10 # actually point to the index.html instead of pointing to the folder. 11 12 13 # I don't trust you 14 if [ -z "${1}" -o ! -e "${1}/ikiwiki" ] 15 then 16 echo "[!] please point to ikiwiki HTML folder" 17 echo "[.] usage ./fix_local_href.sh some/path/to/html_wiki" 18 exit 1 19 else 20 INDEXES="$(find ${1} -iname index.html)" # inb4 -exec jaja nope 21 for INDEX in ${INDEXES} 22 do 23 echo ${INDEX} 24 sed -i 's/href="\(\(\|\/\|.\/\|..\/\)[[:alnum:]_-]*\(\|\/\)\)">/href="\1index.html">/g' ${INDEX} 25 done 26 fi 27 28