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
62 [[ $# -eq 1 ]] && data="`cat $page`" || data=$2
64 data="${data//&/&}"
65 data="${data//</<}"
66 data="${data//>/>}"
68 [[ $p = ALL ]] && continue
69 [[ $p = index ]] && continue
71 data="${data//${p}/<a href=\"${tgt}.html\">$p</a>}"
73 print "<\!DOCTYPE html>
74 <html><head><title>$page</title></head><body><pre>
77 for p (${(oi)=${backs[$page]}}) {
78 [[ $p = ALL ]] && continue
80 print "<li><a href=\"${tgt}.html\">$p</a></li>"
82 print "</ul></body></html>"
86 (links) for w (${(oi)=${links[$2]}}) print $w ;;
87 (backs) for w (${(oi)=${backs[$2]}}) print $w ;;
93 genhtml $p > $2/$p.html
96 for p (${(oi)${(k)pages}}) all="$p\n$all"
97 genhtml ALL $all > $2/ALL.html