use common *.baseof.html templates

This commit is contained in:
Ben Goldsworthy 2025-06-06 17:01:20 +02:00
parent 4e67efab84
commit af68a0e22d
No known key found for this signature in database
19 changed files with 486 additions and 408 deletions

45
layouts/cv/cv.html Normal file
View file

@ -0,0 +1,45 @@
{{ define "main-class" }}--section layouts-cv-cv{{ end }}
{{ define "header-scripts" }}
{{ if ( or ( eq .Type "cv" ) ( .IsDescendant ( .GetPage "/cv/organisations" ) ) ) }}
<script id="Google-Charts-script" src="/js/google-charts/google-charts.js"></script>
{{ end }}
{{ end }}
{{ define "footer-scripts" }}
{{ if ( not ( .IsDescendant ( .GetPage "/cv/organisations" ) ) ) }}
{{ $js := resources.Get "js/roles-chart.js" | resources.ExecuteAsTemplate "/js/render-roles-timeline.js" ( .GetPage "cv/roles" ) | resources.Fingerprint }}
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}"></script>
{{- end -}}
{{ end }}
{{ define "main-header" }}
<header class="site-content__header">
<h2 class="page-title">{{- .Title | safeHTML -}}. {{ if not ( or ( eq .Type "cv" ) ( eq .Type "cv/organisations" ) ) -}}
{{- range .AlternativeOutputFormats -}}
<a href="{{- .RelPermalink -}}" aria-label="{{- $.Title -}} RSS feed">
<img class="feed-icon" alt="RSS feed" src="{{- $.Site.Params.feedIcon -}}">
</a>
{{- end -}}
{{- end -}}
</h2>
{{- .Content -}}
<nav class="page-header__minor-links">
<ul>
{{- range ( where .Sections "Type" "not in" ( slice "cv/roles" ) ).ByTitle }}
<li><a href="{{- .RelPermalink -}}"><h3>{{- .Title -}}</h3></a> <p>({{- len (where ( where .Site.Pages "Section" "cv" ) "Parent.Title" .Title ) -}})</p></li>
{{- end -}}
</ul>
</nav>
{{- partialCached "cv/timeline-legend.html" . -}}
</header>
{{ end }}
{{ define "main-body" }}
<article class="site-content__body site-content__body--chart">
<div id="timeline" aria-label="Roles timeline" role="img" height="70vh">Javascript must be enabled to view this chart.</div>
</article>
{{ end }}

View file

@ -11,68 +11,7 @@
{{ end }}
{{ define "footer-scripts" }}
{{ $titles := .Scratch.Get "titles" }}
<script>
google.charts.load('current', {'packages':['timeline']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var container = document.getElementById('timeline');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Type' });
dataTable.addColumn({ type: 'string', id: 'Job Title' });
dataTable.addColumn({ type: 'string', id: 'style', role: 'style' });
dataTable.addColumn({ type: 'date', id: 'Start' });
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
{{- with ( .GetPage "cv/roles" ).Pages -}}
{{- range ( where . ".Params.organisations" "intersect" $titles ) -}}
{{- if ( not ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) ) -}}
{{-
printf `["%s", "%s", "%s", %s, %s],`
(
partialCached
"cv/organisation/get_role_organisation_string.html"
( dict "sc" $ "pc" . )
.
)
(
partialCached
"cv/organisation/get_role_role_string.html"
( dict "sc" $ "pc" . )
.
)
(
partialCached
"cv/organisation/get_role_colour.html"
( dict "end_date" .Params.end_date "is_paid" .Params.paid )
.Params.end_date .Params.paid
)
( partialCached "cv/organisation/get_role_start_date.html" .Date .Date )
( partialCached "cv/organisation/get_role_end_date.html" .Params.end_date .Params.end_date )
| safeJS
-}}
{{- end -}}
{{- end -}}
{{ end -}}
]);
var options = {
title: '{{ .Title | plainify }} Roles Timeline',
height: '100%',
chartArea: {
width: '94%'
},
width: '100%',
timeline: { showBarLabels: true }
};
chart.draw(dataTable, options);
}
</script>
{{- partial "scripts/show_organisation_roles_in_timeline.js" ( dict "sc" $ "pc" . "organisation_titles" ( .Scratch.Get "titles" ) ) -}}
{{ end }}
{{ define "main-header" }}
@ -139,11 +78,25 @@
{{ partial "cv/organisations/recursive-parents.html" ( dict "c" . "g" $ ) }}
{{- $parents := partial "cv/organisations/reverse-slice.html" ( $.Scratch.Get "parents" ) -}}
{{- range $parents -}}<ul><li class="hierarchy-item hierarchy-item--parent"><a href="{{ .RelPermalink }}">{{ default .Title .Params.markup_title | .Page.RenderString }}</a>{{- end -}}
<ul><li class="hierarchy-item hierarchy-item--current">{{ default .Title .Params.markup_title | .Page.RenderString }}</li>
{{ range .Sections }}<ul>{{ partial "cv/organisations/recursive-children.html" . }}</ul>{{ end }}
</ul>
{{- range $parents -}}</li></ul>{{- end -}}
{{- range $parents -}}
<ul>
<li class="hierarchy-item hierarchy-item--parent">
<a href="{{- .RelPermalink -}}">
{{- default .Title .Params.markup_title | .Page.RenderString -}}
</a>
{{- end -}}
<ul>
<li class="hierarchy-item hierarchy-item--current">
{{- default .Title .Params.markup_title | .Page.RenderString -}}
</li>
{{- range .Sections -}}
<ul>{{- partial "cv/organisations/recursive-children.html" . -}}</ul>
{{- end -}}
</ul>
{{- range $parents -}}
</li>
</ul>
{{- end -}}
</section>
</footer>
{{ end }}

View file

@ -1,112 +1,24 @@
{{ define "main-class" }}
{{- if .IsDescendant ( .GetPage "/cv/organisations" ) -}}--single{{- else -}}--section{{- end }} layouts-cv-section
{{ end }}
{{ define "header-scripts" }}
{{ if ( or ( eq .Type "cv" ) ( .IsDescendant ( .GetPage "/cv/organisations" ) ) ) }}
<script id="Google-Charts-script" src="/js/google-charts/google-charts.js"></script>
{{ end }}
{{ end }}
{{ define "footer-scripts" }}
{{ if ( not ( .IsDescendant ( .GetPage "/cv/organisations" ) ) ) }}
{{ $js := resources.Get "js/roles-chart.js" | resources.ExecuteAsTemplate "/js/render-roles-timeline.js" ( .GetPage "cv/roles" ) | resources.Fingerprint }}
<script src="{{ $js.RelPermalink }}" integrity="{{ $js.Data.Integrity }}"></script>
{{- end -}}
{{ end }}
{{ define "main-class" }}--section layouts-cv-section{{ end }}
{{ define "main-header" }}
{{ if .IsDescendant ( .GetPage "/cv/organisations" ) }}
<header class="site-content__header">
<div class="article-header__featured-image article-header__featured-image--fit"
{{- with .Params.featured_image -}}
{{- with ( $.Resources.GetMatch . ) -}}
style="background-image: url({{- partialCached "images/get-image.html" ( dict "img" . ) .Title -}}){{ with .Params.bg -}}; background-color: {{ . -}};{{- end -}}"
{{- else -}}
{{- errorf "No Page Resource found for src '%q' (%q).\n\n\tAvailable Page Resources are:\n\t\t%v" . $.pc.Page.File.Path $.pc.Page.Resources -}}
{{- end -}}
{{- end -}}
>
<div class="article-header__title-wrapper{{ if .Params.title_in_logo }} article-header__title-wrapper--no-title{{ end }}">
<h2 class="article-header__title">{{ default .Title .Params.markup_title | .Page.RenderString }}</h2>
</div>
</div>
{{- with .Params.nka -}}<p>Now known as: {{ . }}</p>{{- end -}}
{{- with .Params.fka -}}<p>Formerly known as: {{ . }}</p>{{- end -}}
{{- with .Params.tka -}}<p>Then known as: {{ . }}</p>{{- end -}}
</header>
{{ else }}
<header class="site-content__header">
<h2 class="page-title">{{ .Title | safeHTML }}. {{ if not ( or ( eq .Type "cv" ) ( eq .Type "cv/organisations" ) ) -}}
{{- range .AlternativeOutputFormats -}}
<a href="{{ .RelPermalink }}" aria-label="{{ $.Title }} RSS feed">
<img class="feed-icon" alt="RSS feed" src="{{ $.Site.Params.feedIcon }}">
</a>
{{- end -}}
<header class="site-content__header">
<h2 class="page-title">{{ .Title | safeHTML }}. {{ if not ( or ( eq .Type "cv" ) ( eq .Type "cv/organisations" ) ) -}}
{{- range .AlternativeOutputFormats -}}
<a href="{{ .RelPermalink }}" aria-label="{{ $.Title }} RSS feed">
<img class="feed-icon" alt="RSS feed" src="{{ $.Site.Params.feedIcon }}">
</a>
{{- end -}}
</h2>
{{- .Content -}}
{{- end -}}
</h2>
{{- .Content -}}
{{- if ( and ( eq .Type "cv" ) ( not ( .IsDescendant ( .GetPage "/cv/organisations" ) ) ) ) -}}
<nav class="page-header__minor-links">
<ul>
{{ range ( where .Sections "Type" "not in" ( slice "cv/roles" ) ).ByTitle }}
<li><a href="{{ .RelPermalink }}"><h3>{{ .Title }}</h3></a> <p>({{ len (where ( where .Site.Pages "Section" "cv" ) "Parent.Title" .Title ) }})</p></li>
{{ end }}
</ul>
</nav>
{{- partialCached "cv/timeline-legend.html" . -}}
{{- else -}}
<nav class="page-header__minor-links">
{{- partial "years-list.html" . -}}
</nav>
{{- end -}}
</header>
{{ end }}
<nav class="page-header__minor-links">
{{- partial "years-list.html" . -}}
</nav>
</header>
{{ end }}
{{ define "main-body" }}
{{ if .IsDescendant ( .GetPage "/cv/organisations" ) }}
{{ $titles := slice ( .Title | plainify ) }}
{{ with .Sections }}
{{ $titles = $titles | append ( partial "cv/organisations/recursive-children-titles.html" . ) }}
{{ end }}
{{ .Scratch.Set "titles" $titles }}
<main class="site-content__body organisation">
{{- partial "cv/organisation/description.html" ( dict "content" .Content ) -}}
{{- partial "cv/organisation/roles-timeline.html" -}}
{{- partial "cv/organisation/related-items.html" ( dict "sc" $ "organisation_titles" ( .Scratch.Get "titles" ) "organisation_title" .Title ) -}}
</main>
{{ else if eq .Type "cv" }}
<article class="site-content__body site-content__body--chart">
<div id="timeline" aria-label="Roles timeline" role="img" height="70vh">Javascript must be enabled to view this chart.</div>
</article>
{{ else }}
{{ partial "items-grid.html" . }}
{{ end }}
{{ end }}
{{ define "main-footer" }}
{{ if .IsDescendant ( .GetPage "/cv/organisations" ) }}
<footer class="site-content__footer">
<section id="hierarchy">
<h3 class="subheading">Hierarchy</h3>
{{ $.Scratch.Set "parents" ( slice ) }}
{{ partial "cv/organisations/recursive-parents.html" ( dict "c" . "g" $ ) }}
{{- $parents := partial "cv/organisations/reverse-slice.html" ( $.Scratch.Get "parents" ) -}}
{{- range $parents -}}<ul><li class="hierarchy-item hierarchy-item--parent"><a href="{{ .RelPermalink }}">{{ default .Title .Params.markup_title | .Page.RenderString }}</a>{{- end -}}
<ul><li class="hierarchy-item hierarchy-item--current">{{ default .Title .Params.markup_title | .Page.RenderString }}</li>
{{ range .Sections }}<ul>{{ partial "cv/organisations/recursive-children.html" . }}</ul>{{ end }}
</ul>
{{- range $parents -}}</li></ul>{{- end -}}
</section>
</footer>
{{ end }}
{{ partial "items-grid.html" . }}
{{ end }}