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.

105 lines
4.2 KiB

  1. {{ define "urls" }}
  2. <h2>Backlinks, outgoing URLs, bibliographic references and internal links:</h2>
  3. {{ $s := partialCached "scratch.html" . }}
  4. <div id="toggleAllLinks" onclick="toggleAllLinks()">[toggle expand/collapse]</div>
  5. <p></p>
  6. {{ range $p := .Site.RegularPages }}
  7. <details><summary>{{ with $p.File }}<span class="sup">{{- substr .Dir 0 -1 -}}⁄</span>{{ end }}<a href="{{ $p.RelPermalink }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ $p.Title }}</a></summary>
  8. {{ $pPath := printf "/%s" $p.File }}
  9. {{ with $ss := $s.Get $pPath }}
  10. {{ with $ss.backlinks }}
  11. {{ range $i, $_ := $ss.backlinks }}
  12. {{ if eq $i 0 }}
  13. <details><summary>Mentioned in other Sandpoints pages ({{ len $ss.backlinks }}):</summary><ul>
  14. {{ end }}
  15. <li>{{ with $_.File }}<span class="sup">{{ substr .Dir 0 -1 }}⁄</span>{{ end }}<a href="{{ $_.RelPermalink }}">{{ $_.Title }}</a></li>
  16. {{ end }}
  17. </ul></details>
  18. {{ end }}
  19. {{ end }}
  20. {{ with ($p.Scratch.Get "links") }}
  21. {{ range $i, $_ := uniq ($p.Scratch.Get "links") }}
  22. {{ if eq $i 0 }}
  23. <details><summary>Internal links to other Sandpoint pages ({{ len (uniq ($p.Scratch.Get "links")) }}):</summary><ul>
  24. {{ end }}
  25. <li>{{ with $_.File }}<span class="sup">{{ substr .Dir 0 -1 }}⁄</span>{{ end }}<a href="{{ $_.RelPermalink }}">{{ $_.Title }}</a></li>
  26. {{ end }}
  27. </ul></details>
  28. {{ end }}
  29. {{ $http_links := (slice) }}
  30. {{ $library_links := (slice) }}
  31. {{ $anchor_links := (slice) }}
  32. {{ $other_links := (slice) }}
  33. {{ with ($p.Scratch.Get "urls") }}
  34. {{- $c_prefix := $p.Site.Params.sandpointsCatalogPrefix | default "/library/" -}}
  35. {{ range $i, $_ := ($p.Scratch.Get "urls") }}
  36. {{ if strings.HasPrefix $_ "http" }}
  37. {{ $http_links = $http_links | append $_ }}
  38. {{ else if strings.HasPrefix $_ $c_prefix }}
  39. {{ $library_links = $library_links | append $_ }}
  40. {{ else}}
  41. {{ $other_links = $other_links | append $_ }}
  42. {{ end }}
  43. {{ end }}
  44. {{ end }}
  45. {{ with $http_links }}
  46. {{ range $i, $_ := $http_links }}
  47. {{ if eq $i 0 }}
  48. <details><summary>Outgoing links to other pages on Internet ({{ len $http_links }}):</summary><ul>
  49. {{ end }}
  50. <li><span class="sup">www⁄</span><a href="{{ $_ }}" target="_blank">{{ $_ }}</a></li>
  51. {{ end }}
  52. </ul></details>
  53. {{ end }}
  54. {{ with $library_links }}
  55. {{ range $i, $_ := $library_links }}
  56. {{ if eq $i 0 }}
  57. <details><summary>Links to Sandpoint's library ({{ len $library_links }}):</summary><ul>
  58. {{ end }}
  59. <li><span class="sup">lib⁄</span><a href="{{ $_ }}" target="_blank">{{ $_ }}</a></li>
  60. {{ end }}
  61. </ul></details>
  62. {{ end }}
  63. {{ with ($p.Scratch.Get "bibs") }}
  64. {{ range $i, $_ := ($p.Scratch.Get "bibs") }}
  65. {{ if eq $i 0 }}
  66. <details><summary>Bibliographic references ({{ len ($p.Scratch.Get "bibs") }}):</summary><ul>
  67. {{ end }}
  68. <li><span class="sup">bib⁄</span><a href="{{ index $_ 0 }}" target="_blank">{{ index $_ 1 }}</a></li>
  69. {{ end }}
  70. </ul></details>
  71. {{ end }}
  72. {{ with $other_links }}
  73. {{ $formattingN := 0 }}
  74. {{ $anchorN := 0 }}
  75. {{ range $i, $_ := $other_links }}
  76. {{ if eq $i 0 }}
  77. <details><summary>Anchor, formatting and other links ({{ len $other_links }}):</summary><ul>
  78. {{ end }}
  79. {{ if strings.HasPrefix $_ "#" }}
  80. {{ $anchorN = add $anchorN 1 }}
  81. {{ else if strings.HasPrefix $_ "{"}}
  82. {{ $formattingN = add $formattingN 1 }}
  83. {{ else }}
  84. <li><span class="sup">other⁄</span><a href="{{ $_ }}" target="_blank">{{ $_ }}</a></li>
  85. {{ end }}
  86. {{ end }}
  87. {{ with $formattingN }}<li>{{ $formattingN }} formatting links.</a></li>{{ end }}
  88. {{ with $anchorN }}<li>{{ $anchorN }} anchor links.</a></li>{{ end }}
  89. </ul></details>
  90. {{ end }}
  91. </details>
  92. {{ end }}
  93. {{ end }}