You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
8.8 KiB

  1. {{ $currentNode := . }}
  2. {{ $_ := newScratch }}
  3. {{ $debug := (slice) }}
  4. {{ $sandnameSingular := (slice) }}
  5. {{ $sandnamePlural := (slice) }}
  6. {{ range $k, $v := $.Site.Data.sandpointsnamegraph }}
  7. {{ $sandnameSingular = $sandnameSingular | append $k }}
  8. {{ $sandnamePlural = $sandnamePlural | append $v }}
  9. {{ end }}
  10. {{ $pPath := "" }}
  11. {{ range $p := .Site.RegularPages }}
  12. {{ $pPath = printf "/%s" $p.File }}
  13. {{ $pageDir := "" }}
  14. {{ with $p.File }}
  15. {{ $pageDir = (substr .Dir 0 -1)}}
  16. {{ end }}
  17. {{ $content := $p.Content }}
  18. {{ with $links := $p.Scratch.Get "links" }}
  19. {{ range $link := $links }}
  20. {{ $linkPath := printf "/%s" $link.File}}
  21. {{ with ($_.Get $linkPath) }}
  22. {{ $_.SetInMap $linkPath "backlinks" (uniq ((index ($_.Get $linkPath) "backlinks") | append $p)) }}
  23. {{ else }}
  24. {{ $_.SetInMap $linkPath "backlinks" (slice $p) }}
  25. {{ end }}
  26. {{ end }}
  27. {{ end }}
  28. {{ $paramsKeys := (slice) }}
  29. {{ range $k, $v := $p.Params }}
  30. {{ $paramsKeys = $paramsKeys | append $k }}
  31. {{ end }}
  32. {{ $mentions := intersect $paramsKeys $sandnamePlural }}
  33. {{ range $mention := $mentions }}
  34. {{ range $m := index $p.Params $mention }}
  35. {{ $mentionLink := printf "/%s/%s" (substr $mention 0 -1) $m }}
  36. {{ with ($_.Get $mentionLink) }}
  37. {{ $p.Scratch.Add "links" (uniq (($p.Scratch.Get "links")| append ($.GetPage $mentionLink))) }}
  38. {{ $_.SetInMap $mentionLink "backlinks" (uniq ((index ($_.Get $mentionLink) "backlinks") | append $p)) }}
  39. {{ else }}
  40. {{ $p.Scratch.Add "links" (uniq (($p.Scratch.Get "links")| append ($.GetPage $mentionLink))) }}
  41. {{ $_.SetInMap $mentionLink "backlinks" (slice $p) }}
  42. {{ end }}
  43. {{ end }}
  44. {{ end }}
  45. {{ $gp := $.GetPage $pPath }}
  46. {{ $gpPath := printf "/%s" $gp.File }}
  47. {{ range $k, $v := $gp.Params }}
  48. {{ with in $k "has_" }}
  49. {{ $s := index (split $k "has_") 1 }}
  50. {{ range $sin,$plur := $currentNode.Site.Data.sandpointsnamegraph }}
  51. {{ if eq $s $plur }}
  52. {{ range index $gp.Params $k }}
  53. {{ $cp := $.GetPage (printf "/%s/%s" $sin .) }}
  54. {{ $cpPath := printf "/%s" $cp.File }}
  55. {{ range $kcp, $vcp := $cp.Params }}
  56. {{ with in $kcp "has_" }}
  57. {{ $scp := index (split $kcp "has_") 1 }}
  58. {{ range $sincp,$plurcp := $currentNode.Site.Data.sandpointsnamegraph }}
  59. {{ if eq $scp $plurcp }}
  60. {{ $_.SetInMap $gpPath "depth" "core" }}
  61. {{ $_.SetInMap $gpPath "child_depth" "mantle" }}
  62. {{ $_.SetInMap $gpPath "has" $s }}
  63. {{ with $gp.File }}
  64. {{ $core := substr .Dir 0 -1 }}
  65. {{ with index ($_.Get $gpPath) "core" }}
  66. {{ $_.SetInMap $gpPath "core" (uniq ((index ($_.Get $gpPath) "core") | append $core)) }}
  67. {{ else }}
  68. {{ $_.SetInMap $gpPath "core" (slice $core) }}
  69. {{ end }}
  70. {{ $cor := $_.Get $cpPath }}
  71. {{ with $cor.core }}
  72. {{ $_.SetInMap $cpPath "core" (uniq ((index ($_.Get $cpPath) "core") | append $core)) }}
  73. {{ else }}
  74. {{ $_.SetInMap $cpPath "core" (slice $core) }}
  75. {{ end }}
  76. {{ end }}
  77. {{ with $cp.File }}
  78. {{ $mantle := substr .Dir 0 -1 }}
  79. {{ with index ($_.Get $gpPath) "mantle" }}
  80. {{ $_.SetInMap $gpPath "mantle" (uniq ((index ($_.Get $gpPath) "mantle") | append $mantle)) }}
  81. {{ else }}
  82. {{ $_.SetInMap $gpPath "mantle" (slice $mantle) }}
  83. {{ end }}
  84. {{ with index ($_.Get $cpPath) "mantle" }}
  85. {{ $_.SetInMap $cpPath "mantle" (uniq ((index ($_.Get $cpPath) "mantle") | append $mantle)) }}
  86. {{ else }}
  87. {{ $_.SetInMap $cpPath "mantle" (slice $mantle) }}
  88. {{ end }}
  89. {{ end }}
  90. {{ with $_.Get $gpPath }}
  91. {{ if .has_children }}
  92. {{ $hasChildren := index . "has_children" | append $cp }}
  93. {{ $_.SetInMap $gpPath "has_children" (uniq $hasChildren) }}
  94. {{ else }}
  95. {{ $_.SetInMap $gpPath "has_children" (slice $cp) }}
  96. {{ end }}
  97. {{ end }}
  98. {{ $_.SetInMap $cpPath "depth" "mantle" }}
  99. {{ $_.SetInMap $cpPath "child_depth" "crust" }}
  100. {{ $_.SetInMap $cpPath "plural" $plur }}
  101. {{ $_.SetInMap $cpPath "has" $scp }}
  102. {{ if isset $cp.Params $kcp }}
  103. {{ $_.SetInMap $cpPath "has_children" (slice) }}
  104. {{ with index ($_.Get $cpPath) "is_in" }}
  105. {{ $isincore := index ($_.Get $cpPath) "is_in" | append $gp}}
  106. {{ $_.SetInMap $cpPath "is_in" (uniq $isincore) }}
  107. {{ else }}
  108. {{ $_.SetInMap $cpPath "is_in" (slice $gp) }}
  109. {{ end }}
  110. {{ end }}
  111. {{ range index $cp.Params $kcp }}
  112. {{ $gcp := $.GetPage (printf "/%s/%s" $sincp .) }}
  113. {{ $gcpPath := printf "/%s" $gcp.File }}
  114. {{ with $_.Get $cpPath }}
  115. {{ if .has_children }}
  116. {{ $hasGChildren := index . "has_children" | append $gcp }}
  117. {{ $_.SetInMap $cpPath "has_children" (uniq $hasGChildren) }}
  118. {{ else }}
  119. {{ $_.SetInMap $cpPath "has_children" (slice $gcp) }}
  120. {{ end }}
  121. {{ end }}
  122. {{ $_.SetInMap $gcpPath "depth" "crust" }}
  123. {{ $_.SetInMap $gcpPath "plural" $plurcp }}
  124. {{ $_.SetInMap $gcpPath "in" (slice $sin $plur) }}
  125. {{ with $gp.File }}
  126. {{ $core := substr .Dir 0 -1 }}
  127. {{ with index ($_.Get $gcpPath) "core" }}
  128. {{ $_.SetInMap $gcpPath "core" (uniq ((index ($_.Get $gcpPath) "core") | append $core)) }}
  129. {{ else }}
  130. {{ $_.SetInMap $gcpPath "core" (slice $core) }}
  131. {{ end }}
  132. {{ end }}
  133. {{ with $cp.File }}
  134. {{ $mantle := substr .Dir 0 -1 }}
  135. {{ with index ($_.Get $gcpPath) "mantle" }}
  136. {{ $_.SetInMap $gcpPath "mantle" (uniq ((index ($_.Get $gcpPath) "mantle") | append $mantle)) }}
  137. {{ else }}
  138. {{ $_.SetInMap $gcpPath "mantle" (slice $mantle) }}
  139. {{ end }}
  140. {{ end }}
  141. {{ with $gcp.File }}
  142. {{ $crust := substr .Dir 0 -1 }}
  143. {{ with index ($_.Get $gpPath) "crust" }}
  144. {{ $_.SetInMap $gpPath "crust" (uniq ((index ($_.Get $gpPath) "crust") | append $crust)) }}
  145. {{ else }}
  146. {{ $_.SetInMap $gpPath "crust" (slice $crust) }}
  147. {{ end }}
  148. {{ with index ($_.Get $cpPath) "crust" }}
  149. {{ $_.SetInMap $cpPath "crust" (uniq ((index ($_.Get $cpPath) "crust") | append $crust)) }}
  150. {{ else }}
  151. {{ $_.SetInMap $cpPath "crust" (slice $crust) }}
  152. {{ end }}
  153. {{ with index ($_.Get $gcpPath) "crust" }}
  154. {{ $_.SetInMap $gcpPath "crust" (uniq ((index ($_.Get $gcpPath) "crust") | append $crust)) }}
  155. {{ else }}
  156. {{ $_.SetInMap $gcpPath "crust" (slice $crust) }}
  157. {{ end }}
  158. {{ end }}
  159. {{ with $_.Get $gcpPath }}
  160. {{ if .is_in }}
  161. {{ $isinmantle := index . "is_in" | append $cp}}
  162. {{ $_.SetInMap $gcpPath "is_in" (uniq $isinmantle) }}
  163. {{ else }}
  164. {{ $_.SetInMap $gcpPath "is_in" (slice $cp) }}
  165. {{ end }}
  166. {{ end }}
  167. {{ end }}
  168. {{ end }}
  169. {{ end }}
  170. {{ end }}
  171. {{ end }}
  172. {{ end }}
  173. {{ end }}
  174. {{ end }}
  175. {{ end }}
  176. {{ end }}
  177. {{ $_.SetInMap $pPath "debug" (printf "%#v" $debug) }}
  178. {{ end }}
  179. {{ return $_ }}