[[ $# -eq 2 ]] || usage
-# Collect all pages
setopt GLOB_STAR_SHORT
zmodload -F zsh/stat b:zstat
typeset -A pages
typeset -a cats
for p (**(/)) cats=($p $cats)
-# Determine the links between them
+zmodload zsh/mapfile
typeset -A links
typeset -A backs
typeset -aU words
for p (${(k)pages}) {
words=()
- for w (`< $p`) {
+ for w (${=mapfile[$p]}) {
[[ $w =~ "\[(.*)\]" ]] || continue
w=${match[1]}
[[ ${pages[$w]} ]] || {
genHTML() {
local page=$1
local data p
- [[ $# -eq 1 ]] && data=`< $page` || data=$2
+ [[ $# -eq 1 ]] && data=${mapfile[$page]} || data=$2
data=${data//&/&}
data=${data//</<}
data=${data//>/>}
}
zmodload -F zsh/datetime b:strftime
-now=$(strftime "%F %T")
+strftime -s now "%F %T"
genIndex() {
local p
}
for p (${(oi)_links}) entries=($entries "[$p] (${pages[$p]})")
if [[ $cats ]]; then
- entries=($entries "\nBacklinks:\n")
+ entries=($entries "\nSubdirectories:\n")
for p (${(oi)cats}) {
entries=($entries "[$p/Index]")
_links=($p/Index $_links)