Browse Source

merging from upstream Sandpoints

master
Sean Dockray 3 years ago
parent
commit
ab4df07eef
4 changed files with 118 additions and 77 deletions
  1. +11
    -6
      themes/sandpoints/data/sandpointsnamegraph.json
  2. +3
    -1
      themes/sandpoints/layouts/partials/header.html
  3. +101
    -69
      themes/sandpoints/layouts/partials/scratch.html
  4. +3
    -1
      themes/sandpoints/layouts/partials/singlebody.html

+ 11
- 6
themes/sandpoints/data/sandpointsnamegraph.json View File

@@ -1,8 +1,13 @@
{
"triads":[
["syllabus", "syllabi", "topic", "topics", "session", "sessions"],
["curriculum", "curriculums", "topic", "topics", "experiment", "experiments"],
["book", "books", "part", "parts", "chapter", "chapters"],
["journal", "journals", "issue", "issues", "article", "article"]
]
"syllabus": "syllabi",
"curriculum": "curriculums",
"book": "books",
"journal": "journals",
"topic": "topics",
"part": "parts",
"issue": "issues",
"experiment": "experiments",
"session": "sessions",
"chapter": "chapters",
"article": "articles"
}

+ 3
- 1
themes/sandpoints/layouts/partials/header.html View File

@@ -7,6 +7,7 @@
{{- $gitUrl := .Site.Params.giturl -}}
<div class="headiter">
<a class="edit-button" target="_blank" href="{{ $gitUrl }}/_edit/master/content/{{ .File }}">edit_this</a>
<a class="edit-button" target="_blank" href="{{ $gitUrl }}/_new/master/content/{{ $scratch.core }}/">add_new_{{ $scratch.core }}</a>
<a class="edit-button" target="_blank" href="{{ $gitUrl }}/_new/master/content/{{ $scratch.mantle }}/">add_new_{{ $scratch.mantle }}</a>
<a class="edit-button" target="_blank" href="{{ $gitUrl }}/_new/master/content/{{ $scratch.crust }}/">add_new_{{ $scratch.crust }}</a>
<a class="edit-button" target="_blank" href="{{ $gitUrl }}/_edit/master/PUBLISH.trigger.md">publish</a>
@@ -21,7 +22,7 @@
<div class="breadcrumbs">
{{ if eq $scratch.depth "mantle" }}
{{ if isset $scratch "is_in" }}
<a href="{{ with (index $scratch.is_in 0) }}{{ .RelPermalink }}{{ end }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}"><span class="sup">{{ with (index $scratch.is_in 0) }}{{ substr .Title 0 1 }}</span><i>{{ substr .Title 1 }}</i></a>{{ end }}
<a href="{{ with (index $scratch.is_in 0) }}{{ .RelPermalink }}{{ end }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}"><span class="sup">{{ with (index $scratch.is_in 0) }}{{ substr .Title 0 1 }}</span><i>{{ substr .Title 1 }}</i>{{ if gt (len $scratch.is_in) 1 }}+{{ end}}</a>{{ end }}
{{ end }}
<span class="mantlebar"><i> » <a href="{{ .RelPermalink }}{{ if eq hugo.Environment "offline" }}index.html{{ end }}">{{ .Title }}</a></i></span>
{{ end }}
@@ -41,3 +42,4 @@
{{ end }}
</div>
</div>


+ 101
- 69
themes/sandpoints/layouts/partials/scratch.html View File

@@ -1,80 +1,112 @@
{{ $currentNode := . }}

{{ $debug := (slice) }}

{{ $pPath := "" }}
{{ range $p := .Site.RegularPages }}
{{ $pageFilePath := printf "/%s" $p.File }}
{{ $pageDir := "" }}
{{ with $p.File }}
{{ $pageDir = (substr .Dir 0 -1)}}
{{ end }}
{{ $pPath = printf "/%s" $p.File }}
{{ $pageDir := "" }}
{{ with $p.File }}
{{ $pageDir = (substr .Dir 0 -1)}}
{{ end }}

{{ $gp := $.GetPage $pPath }}
{{ $gpPath := printf "/%s" $gp.File }}
{{ range $k, $v := $gp.Params }}
{{ with in $k "has_" }}
{{ $s := index (split $k "has_") 1 }}
{{ range $sin,$plur := $currentNode.Site.Data.sandpointsnamegraph }}
{{ if eq $s $plur }}
{{ range index $gp.Params $k }}
{{ $cp := $.GetPage (printf "/%s/%s" $sin .) }}
{{ $cpPath := printf "/%s" $cp.File }}
{{ range $kcp, $vcp := $cp.Params }}
{{ with in $kcp "has_" }}
{{ $scp := index (split $kcp "has_") 1 }}
{{ range $sincp,$plurcp := $currentNode.Site.Data.sandpointsnamegraph }}
{{ if eq $scp $plurcp }}

{{ $.Scratch.SetInMap $gpPath "depth" "core" }}
{{ $.Scratch.SetInMap $gpPath "child_depth" "mantle" }}
{{ $.Scratch.SetInMap $gpPath "has" $s }}

{{ with $gp.File }}
{{ $core := substr .Dir 0 -1 }}
{{ $.Scratch.SetInMap $gpPath "core" $core }}
{{ $.Scratch.SetInMap $cpPath "core" $core }}
{{ end }}

{{ with $cp.File }}
{{ $mantle := substr .Dir 0 -1 }}
{{ $.Scratch.SetInMap $gpPath "mantle" $mantle }}
{{ $.Scratch.SetInMap $cpPath "mantle" $mantle }}
{{ end }}

{{ with $.Scratch.Get $gpPath }}
{{ if .has_children }}
{{ $hasChildren := index . "has_children" | append $cp }}
{{ $.Scratch.SetInMap $gpPath "has_children" (uniq $hasChildren) }}
{{ else }}
{{ $.Scratch.SetInMap $gpPath "has_children" (slice $cp) }}
{{ end }}
{{ end }}

{{ $.Scratch.SetInMap $cpPath "depth" "mantle" }}
{{ $.Scratch.SetInMap $cpPath "child_depth" "crust" }}
{{ $.Scratch.SetInMap $cpPath "plural" $plur }}
{{ $.Scratch.SetInMap $cpPath "has" $scp }}

{{ range $triad := (index $currentNode.Site.Data.sandpointsnamegraph "triads") }}
{{ with intersect $triad (slice $pageDir) }}
{{ $t := index . 0 }}
{{ if eq $t (index $triad 0) }}
{{ $.Scratch.SetInMap $pageFilePath "depth" "core" }}
{{ $.Scratch.SetInMap $pageFilePath "child_depth" "mantle" }}
{{ $.Scratch.SetInMap $pageFilePath "plural" (index $triad 1)}}
{{ $.Scratch.SetInMap $pageFilePath "has" (slice (index $triad 2) (index $triad 3))}}

{{ $gp := $.GetPage $pageFilePath }}
{{ $hasmantles := (slice) }}
{{ range index $gp.Params (printf "has_%s" (index $triad 3)) }}
{{ $hasmantles = $hasmantles | append ($.GetPage (printf "/%s/%s" (index $triad 2) . )) }}
{{ end }}
{{ $.Scratch.SetInMap $pageFilePath "has_children" $hasmantles }}

{{ range index $p.Params (printf "has_%s" (index $triad 3)) }}
{{ $childPath := printf "/%s/%s" (index $triad 2) . }}
{{ with $.Scratch.Get $childPath }}
{{ if isset . "is_in" }}
{{ $isin := index . "is_in" | append ($.GetPage $pageFilePath) }}
{{ $.Scratch.SetInMap $childPath "is_in" $isin }}
{{ else }}
{{ $.Scratch.SetInMap $childPath "is_in" (slice ($.GetPage $pageFilePath)) }}
{{ end }}
{{ else }}
{{ $.Scratch.SetInMap $childPath "is_in" (slice ($.GetPage $pageFilePath)) }}
{{ end }}
{{ end }}
{{ else if eq $t (index $triad 2) }}
{{ $.Scratch.SetInMap $pageFilePath "depth" "mantle" }}
{{ $.Scratch.SetInMap $pageFilePath "child_depth" "crust" }}
{{ $.Scratch.SetInMap $pageFilePath "plural" (index $triad 3)}}
{{ $.Scratch.SetInMap $pageFilePath "has" (slice (index $triad 4) (index $triad 5))}}

{{ $gp := $.GetPage $pageFilePath }}
{{ $hascrusts := (slice) }}
{{ range index $gp.Params (printf "has_%s" (index $triad 5)) }}
{{ $hascrusts = $hascrusts | append ($.GetPage (printf "/%s/%s" (index $triad 4) . )) }}
{{ end }}
{{ $.Scratch.SetInMap $pageFilePath "has_children" $hascrusts }}

{{ range index $p.Params (printf "has_%s" (index $triad 5)) }}
{{ $childPath := printf "/%s/%s" (index $triad 4) . }}
{{ with $.Scratch.Get $childPath }}
{{ if isset . "is_in" }}
{{ $isin := index . "is_in" | append ($.GetPage $pageFilePath) }}
{{ $.Scratch.SetInMap $childPath "is_in" $isin }}
{{ else }}
{{ $.Scratch.SetInMap $childPath "is_in" (slice ($.GetPage $pageFilePath)) }}
{{ end }}
{{ else }}
{{ $.Scratch.SetInMap $childPath "is_in" (slice ($.GetPage $pageFilePath)) }}
{{ end }}
{{ end }}

{{ else if eq $t (index $triad 4) }}
{{ $.Scratch.SetInMap $pageFilePath "depth" "crust" }}
{{ $.Scratch.SetInMap $pageFilePath "mantle_has" (index $triad 5) }}
{{ $.Scratch.SetInMap $pageFilePath "plural" (index $triad 5)}}
{{ $.Scratch.SetInMap $pageFilePath "in" (slice (index $triad 2) (index $triad 3))}}
{{ range index $cp.Params $kcp }}
{{ $gcp := $.GetPage (printf "/%s/%s" $sincp .) }}
{{ $gcpPath := printf "/%s" $gcp.File }}

{{ with $.Scratch.Get $cpPath }}
{{ if .has_children }}
{{ $hasGChildren := index . "has_children" | append $gcp }}
{{ $.Scratch.SetInMap $cpPath "has_children" (uniq $hasGChildren) }}
{{ else }}
{{ $.Scratch.SetInMap $cpPath "has_children" (slice $gcp) }}
{{ end }}

{{ if .is_in }}
{{ $isincore := index . "is_in" | append $gp}}
{{ $.Scratch.SetInMap $cpPath "is_in" (uniq $isincore) }}
{{ else }}
{{ $.Scratch.SetInMap $cpPath "is_in" (slice $gp) }}
{{ end }}
{{ end }}

{{ $.Scratch.SetInMap $gcpPath "depth" "crust" }}
{{ $.Scratch.SetInMap $gcpPath "plural" $plurcp }}
{{ $.Scratch.SetInMap $gcpPath "in" (slice $sin $plur) }}

{{ $.Scratch.SetInMap $pageFilePath "core" (index $triad 0) }}
{{ $.Scratch.SetInMap $pageFilePath "mantle" (index $triad 2) }}
{{ $.Scratch.SetInMap $pageFilePath "crust" (index $triad 4) }}
{{ with $gcp.File }}
{{ $crust := substr .Dir 0 -1 }}
{{ $.Scratch.SetInMap $gpPath "crust" $crust }}
{{ $.Scratch.SetInMap $cpPath "crust" $crust }}
{{ $.Scratch.SetInMap $gcpPath "crust" $crust }}
{{ end }}

{{ with $.Scratch.Get $gcpPath }}
{{ if .is_in }}
{{ $isinmantle := index . "is_in" | append $cp}}
{{ $.Scratch.SetInMap $gcpPath "is_in" (uniq $isinmantle) }}
{{ else }}
{{ $.Scratch.SetInMap $gcpPath "is_in" (slice $cp) }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}

{{ $.Scratch.SetInMap $pPath "debug" (printf "%#v" $debug) }}
{{ end }}

{{ return $.Scratch }}

+ 3
- 1
themes/sandpoints/layouts/partials/singlebody.html View File

@@ -1,5 +1,6 @@
{{ $s := partialCached "scratch.html" . }}

{{ $currentNode := . }}
{{ $currentDir := "" }}
{{ with .File }}
{{ $currentDir = .Dir }}
@@ -19,7 +20,7 @@
{{ if (not (eq $scratch.depth "crust")) }}
<div class="has">
{{ if isset $scratch "has" }}
<span class="sup">has {{ index $scratch.has 1 }}⁄</span>
<span class="sup">has {{ $scratch.has }}⁄</span>
{{ end }}
</div>
<div class="afterhas">
@@ -44,3 +45,4 @@
</div>
</div>
</div>


Loading…
Cancel
Save