highlight them with:
syntax region zkLink start="\[\S" end="\S]"
highlight link zkLink String
+* Link to the directory's index can be made with [Dir/]
* Use Vim's filename completion (:help compl-filename) to
complete directories and filenames in them
* fzf (https://github.com/junegunn/fzf) related tools can be
pages[$p]=${mtime[1]}
sizes[$p]=${size[1]}
}
-typeset -a cats
-for p (**(/)) cats=($p $cats)
+typeset -A cats
+for p (**(/)) cats[$p]=1
zmodload zsh/mapfile
zmodload -F zsh/files b:zf_mkdir
for w (${=mapfile[$p]}) {
[[ $w =~ "\[([^] ]+)\]" ]] || continue
w=${match[1]}
+ [[ ( $w =~ "/$" ) && ( ${cats[$w[1,-2]]} ) ]] && {
+ ws=($ws $w)
+ continue
+ }
[[ ${pages[$w]} ]] || {
[[ $ZK_SHOW_MISSING ]] && print "missing $w"
continue
data=${data//>/>}
for p ($_links) {
getrel $page $p
+ [[ -d $p ]] && REPLY=$REPLY/index
data="${data//\[${p}\]/<a href=\"${REPLY}.html\">[$p]</a>}"
}
data="<!DOCTYPE html>
local p
local entries=()
local _links=()
- typeset -aU cats=()
+ typeset -aU _cats=()
local curdepth=${#${(s:/:)1}}
(( curdepth = curdepth + 1 ))
for p (${(k)pages[(I)$1*]}) {
case ${#${(As:/:)p}} in
($curdepth) _links=($p $_links) ;;
- ( $(( $curdepth + 1 )) ) cats=(${1}${${p#$1}%%/*} $cats) ;;
+ ( $(( $curdepth + 1 )) ) _cats=(${1}${${p#$1}%%/*} $_cats) ;;
(*) continue ;;
esac
}
print "<li><a href=\"${REPLY}.html\">$p</a> <sup>${pages[$p]}</sup> (${sizes[$p]} bytes)</li>"
}
print "</ul>"
- if [[ $cats ]]; then
+ if [[ $_cats ]]; then
print "<hr/>Subdirectories:<ul>"
- for p (${(oi)cats}) {
+ for p (${(oi)_cats}) {
getrel $page $p/index
print "<li><a href=\"${REPLY}.html\">$p</a></li>"
}
print "</ul>"
fi
+ local bs=(${(oi)=${backs[$1]}})
+ if [[ $bs ]]; then
+ print "<hr/>Backlinks:<ul>"
+ for p ($bs) {
+ getrel $page $p
+ print "<li><a href=\"${REPLY}.html\">$p</a> <sup>${pages[$p]}</sup></li>"
+ }
+ print "</ul>"
+ fi
print "</body></html>"
}
genHTML $p > $2/$p.html
touch -r $p $2/$p.html
}
- for p ($cats) genIndex $p/ > $2/$p/index.html
+ for p (${(k)cats}) genIndex $p/ > $2/$p/index.html
genIndex "" > $2/index.html
- for p ("" $cats) touch -d ${now/ /T} $2/$p/index.html
+ for p ("" ${(k)cats}) touch -d ${now/ /T} $2/$p/index.html
;;
(*) usage ;;
esac