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.

154 lines
5.7 KiB

  1. {{- define "singlebody" -}}
  2. {{ $cssTemplate := `.css-_rplc_-h2 {
  3. counter-reset: css-_rplc_-h3;
  4. }
  5. .css-_rplc_-h3 {
  6. counter-reset: css-_rplc_-h4;
  7. }
  8. .css-_rplc_-h4 {
  9. counter-reset: css-_rplc_-h5;
  10. }
  11. .css-_rplc_-h5 {
  12. counter-reset: css-_rplc_-h6;
  13. }
  14. .css-_rplc_-h2:before {
  15. color: rgba(0, 0, 0, 0.4);
  16. counter-increment: css-_rplc_-h2 1;
  17. content: counter(css-_rplc_-h2) ". ";
  18. }
  19. .css-_rplc_-h3:before {
  20. color: rgba(0, 0, 0, 0.4);
  21. counter-increment: css-_rplc_-h3 1;
  22. content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) ". ";
  23. }
  24. .css-_rplc_-h4:before {
  25. color: rgba(0, 0, 0, 0.4);
  26. counter-increment: css-_rplc_-h4 1;
  27. content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) "." counter(css-_rplc_-h4) ". ";
  28. }
  29. .css-_rplc_-h5:before {
  30. color: rgba(0, 0, 0, 0.4);
  31. counter-increment: css-_rplc_-h5 1;
  32. content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) "." counter(css-_rplc_-h4) "." counter(css-_rplc_-h5) ". ";
  33. }
  34. .css-_rplc_-h6:before {
  35. color: rgba(0, 0, 0, 0.4);
  36. counter-increment: css-_rplc_-h6 1;
  37. content: counter(css-_rplc_-h2) "." counter(css-_rplc_-h3) "." counter(css-_rplc_-h4) "." counter(css-_rplc_-h5) "."
  38. counter(css-_rplc_-h6) ". ";
  39. }
  40. .css-_rplc_-h2.nocount:before,
  41. .css-_rplc_-h3.nocount:before,
  42. .css-_rplc_-h4.nocount:before,
  43. .css-_rplc_-h5.nocount:before,
  44. .css-_rplc_-h6.nocount:before {
  45. content: "";
  46. counter-increment: none;
  47. }` }}
  48. {{ $cssOutput := "" }}
  49. {{ $cssHashes := "" }}
  50. {{ $s := partialCached "scratch.html" . }}
  51. {{ $p := $.GetPage .Params.print }}
  52. {{ $scratch := $s.Get (printf "/%s" $p.File) }}
  53. {{ $currentDir := "" }}
  54. {{ with .File }}
  55. {{ $currentDir = .Dir }}
  56. {{ end }}
  57. <div class="print0">{{ partial "printsinglebody.html" $p }}</div>
  58. <div class="content">{{ $p.Content }}</div>
  59. {{ $cssOutput = printf "%s\n%s" $cssOutput (replace $cssTemplate "_rplc_" $p.File.UniqueID) }}
  60. {{ $cssHashes = printf "%s css-%s-h2" $cssHashes $p.File.UniqueID }}
  61. {{ range $scratch.has_children }}
  62. <div class="crustpage">
  63. {{ $addS := 0 }}
  64. {{ with .Params.authors }}
  65. {{ $addS = len . }}
  66. {{ end }}
  67. {{ range $n, $authorFile := .Params.authors }}
  68. {{ $author := $.GetPage (printf "/author/%s" $authorFile) }}
  69. {{ if eq $n 0 }}
  70. <div class="runningAuthors"><span class="sup">author{{ with (gt $addS 1) }}s{{ end }}⁄</span><a href="#ph-{{ $author.File.UniqueID }}">{{ $author.Title }}</a>
  71. {{ else }}
  72. , <a href="#ph-{{ $author.File.UniqueID }}">{{ $author.Title }}</a>
  73. {{ end }}
  74. {{ end }}
  75. {{ with .Params.authors }}</div>{{ end }}
  76. {{ $tit := .Title }}
  77. {{ if gt (len .Title) 54 }}
  78. {{ $tit = printf "%s…" (substr .Title 0 50) }}
  79. {{ end }}
  80. <div class="runningTitle"><span class="sup">{{ index $scratch.crust 0 }}⁄</span><a href="#ph-{{ .File.UniqueID }}">{{ $tit }}</a></div>
  81. {{ partial "printsinglebody.html" . }}
  82. {{ .Content }}
  83. {{ $cssOutput = printf "%s\n%s" $cssOutput (replace $cssTemplate "_rplc_" .File.UniqueID) }}
  84. {{ $cssHashes = printf "%s css-%s-h2" $cssHashes .File.UniqueID }}
  85. {{ $kid := $s.Get (printf "/%s" .File) }}
  86. {{ range $kid.has_children }}
  87. <div class="crustpage">
  88. {{ $addS := 0 }}
  89. {{ with .Params.authors }}
  90. {{ $addS = len . }}
  91. {{ end }}
  92. {{ range $n, $authorFile := .Params.authors }}
  93. {{ $author := $.GetPage (printf "/author/%s" $authorFile) }}
  94. {{ if eq $n 0 }}
  95. <div class="runningAuthors"><span class="sup">author{{ with (gt $addS 1) }}s{{ end }}⁄</span><a href="#ph-{{ $author.File.UniqueID }}">{{ $author.Title }}</a>
  96. {{ else }}
  97. , <a href="#ph-{{ $author.File.UniqueID }}">{{ $author.Title }}</a>
  98. {{ end }}
  99. {{ end }}
  100. {{ with .Params.authors }}</div>{{ end }}
  101. {{ $tit := .Title }}
  102. {{ if gt (len .Title) 54 }}
  103. {{ $tit = printf "%s…" (substr .Title 0 50) }}
  104. {{ end }}
  105. <div class="runningTitle"><span class="sup">{{ index $scratch.crust 0 }}⁄</span><a href="#ph-{{ .File.UniqueID }}">{{ $tit }}</a></div>
  106. {{ partial "printsinglebody.html" . }}
  107. {{ .Content }}
  108. {{ $cssOutput = printf "%s\n%s" $cssOutput (replace $cssTemplate "_rplc_" .File.UniqueID) }}
  109. {{ $cssHashes = printf "%s css-%s-h2" $cssHashes .File.UniqueID }}
  110. {{ end }}
  111. {{ end }}
  112. {{ range where $.Site.RegularPages "Section" "in" (slice "author" "editor") }}
  113. <div class="authorpage">
  114. <div class="runningTitle runningAuthors"><span class="sup">{{ index $scratch.mantle 0 }}⁄</span><a href="#ph-{{ $p.File.UniqueID }}">{{ $p.Title }}</a></div>
  115. <div id="ph-{{ .File.UniqueID }}" class="{{ $scratch.depth | default "crust" }}title"><span class="supt">{{ substr .File.Dir 0 -1 }}⁄</span>{{ .Title }}</div>
  116. {{ .Content }}
  117. {{ if in .Page.Site.Params.sandpointsMentionedIn (substr .File.Dir 0 -1) }}
  118. {{ $ss := $s.Get (printf "/%s" .File) }}
  119. <div class="has hasmentionedin">
  120. {{ with $ss }}
  121. <div class="hassup">mentioned in⁄</div>
  122. {{ end }}
  123. <div class="afterhas">
  124. {{ range $ss.backlinks }}
  125. <div class="{{ $ss.child_depth }}">
  126. <a href="#ph-{{ .File.UniqueID }}">{{ .Title }}</a>
  127. </div>
  128. {{ end }}
  129. </div></div>
  130. {{ end }}
  131. {{ end }}
  132. {{ $cssOutput = printf "body {counter-reset: %s;}\n%s" $cssHashes $cssOutput }}
  133. {{ $var := $cssOutput | resources.FromString "css/dyn.css" }}
  134. {{ $dummy := $var.Permalink }}
  135. {{- end -}}