11 Print who backlinks to the PAGE
18 [[ $# -eq 2 ]] || usage
21 setopt GLOB_STAR_SHORT
23 for f (**(.)) pages[$f]=1
25 # Determine the links between them
30 [[ $w =~ "^\(.*\)$" ]] && w=${MATCH[2,-2]}
31 [[ ${pages[$w]} ]] || continue
32 links[$p]="$w ${links[$p]}"
36 # Deduplicate all references
40 for w (${=${links[$p]}}) {
42 backs[$w]="$p ${backs[$w]}"
48 for w (${=${backs[$p]}}) ws[$w]=1
60 [[ $# -eq 1 ]] && data="`cat $page`" || data=$2
62 data="${data//&/&}"
63 data="${data//</<}"
64 data="${data//>/>}"
66 [[ $p = ALL ]] && continue
67 [[ $p = index ]] && continue
69 data="${data//${p}/<a href=\"${tgt}.html\">$p</a>}"
71 print "<\!DOCTYPE html>
72 <html><head><title>$page</title></head><body><pre>
75 for p (${(oi)=${backs[$page]}}) {
76 [[ $p = ALL ]] && continue
78 print "<li><a href=\"${tgt}.html\">$p</a></li>"
80 print "</ul></body></html>"
84 (links) for w (${(oi)=${links[$2]}}) print $w ;;
85 (backs) for w (${(oi)=${backs[$2]}}) print $w ;;
91 genhtml $p > $2/$p.html
94 for p (${(oi)${(k)pages}}) all="$p\n$all"
95 genhtml ALL $all > $2/ALL.html