diff --git a/layouts/cv/organisations/section.html b/layouts/cv/organisations/section.html
index d2f70c1..186019a 100644
--- a/layouts/cv/organisations/section.html
+++ b/layouts/cv/organisations/section.html
@@ -25,11 +25,6 @@
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
- {{- $unpaid_past := "#FFFFF0" -}}
- {{- $paid_past := "#FCFCA6" -}}
- {{- $unpaid_current := "#BBBBB0" -}}
- {{- $paid_current := "#BCBC7E" -}}
-
dataTable.addColumn({ type: 'string', id: 'Type' });
dataTable.addColumn({ type: 'string', id: 'Job Title' });
dataTable.addColumn({ type: 'string', id: 'style', role: 'style' });
@@ -37,61 +32,33 @@
dataTable.addColumn({ type: 'date', id: 'End' });
dataTable.addRows([
- {{ with ( .GetPage "cv/roles" ).Pages -}}
+ {{- with ( .GetPage "cv/roles" ).Pages -}}
{{- range ( where . ".Params.organisations" "intersect" $titles ) -}}
{{- if ( not ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) ) -}}
- [
- "
- {{- with .Params.organisations -}}
- {{- $.Scratch.Set "parents" ( slice ) -}}
- {{- range . -}}
- {{- range ( where ( where $.Site.Pages "Type" "cv" ) "Title" . ) -}}
- {{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
- {{- if ( eq $.Site.Params.redact "black" ) -}}
- {{- $.Scratch.Set "parents" ( $.Scratch.Get "parents" | append "███████████████" ) -}}
- {{- end -}}
- {{- else -}}
- {{- $.Scratch.Set "parents" ( $.Scratch.Get "parents" | append ( .Title | plainify ) ) -}}
- {{- end -}}
- {{- else -}}
- {{ erroridf "missing-organisation" "Could not find organisation %q (%q)" . $.File.Path }}
- {{- end -}}
- {{- end -}}
- {{- delimit ( $.Scratch.Get "parents" ) ", " -}}
- {{- $.Scratch.Delete "parents" -}}
- {{- end -}}
- ",
- "
- {{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
- {{- if ( eq $.Site.Params.redact "black" ) -}}
- ███████████████
- {{- end -}}
- {{- else -}}
- {{- .Title | plainify -}}
- {{- end -}}
- ",
- "{{ if .Params.end_date -}}
- {{- if .Params.paid -}}
- {{- $paid_past -}}
- {{- else -}}
- {{- $unpaid_past -}}
- {{- end -}}
- {{- else -}}
- {{- if .Params.paid -}}
- {{- $paid_current -}}
- {{- else -}}
- {{- $unpaid_current -}}
- {{- end -}}
- {{- end }}",
- new Date("{{ .Date.Format "2006-01-02" }}"),
- new Date("
- {{- if .Params.end_date -}}
- {{- .Params.end_date -}}
- {{- else -}}
- {{- now.Format "2006-01-02" -}}
- {{- end -}}
- ")
- ],
+ {{-
+ 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 -}}
diff --git a/layouts/partials/cv/organisation/get_organisation_parents.html b/layouts/partials/cv/organisation/get_organisation_parents.html
new file mode 100644
index 0000000..126c893
--- /dev/null
+++ b/layouts/partials/cv/organisation/get_organisation_parents.html
@@ -0,0 +1,47 @@
+
+
+
+
+{{- if ( not ( isset . "sc" ) ) -}}
+ {{- errorf "No site context passed" -}}
+{{- end -}}
+
+{{- if ( not ( isset . "pc" ) ) -}}
+ {{- errorf "No page context passed" -}}
+{{- end -}}
+
+{{- if ( not ( isset . "organisation" ) ) -}}
+ {{- errorf "No organisation passed" -}}
+{{- end -}}
+
+
+
+{{- $parents := slice -}}
+
+
+
+{{- $organisations_pages := ( where .sc.Site.Pages "Type" "cv" ) -}}
+{{- $matching_organisations_pages := where $organisations_pages "Title" .organisation -}}
+{{- range $matching_organisations_pages -}}
+ {{- if ( and ( $.pc.Params.redact ) ( ne $.sc.Site.Params.redact "show" ) ) -}}
+ {{- if ( eq $.sc.Site.Params.redact "black" ) -}}
+ {{- $parents = ( $parents | append "███████████████" ) -}}
+ {{- end -}}
+
+ {{- else -}}
+ {{- $parents = ( $parents | append ( .Title | htmlUnescape | plainify ) ) -}}
+
+ {{- end -}}
+
+{{- else -}}
+ {{ erroridf "missing-organisation" "Could not find organisation '%q' (%q)" .organisation $.pc.File.Path }}
+
+{{- end -}}
+
+{{- return $parents -}}
diff --git a/layouts/partials/cv/organisation/get_role_colour.html b/layouts/partials/cv/organisation/get_role_colour.html
new file mode 100644
index 0000000..b22024d
--- /dev/null
+++ b/layouts/partials/cv/organisation/get_role_colour.html
@@ -0,0 +1,50 @@
+
+
+
+
+{{- if ( not ( isset . "end_date" ) ) -}}
+ {{- errorf "No end date passed" -}}
+{{- end -}}
+
+{{- if ( not ( isset . "is_paid" ) ) -}}
+ {{- errorf "No 'is_paid' passed" -}}
+{{- end -}}
+
+
+
+
+{{- $end_date := .end_date -}}
+{{- $is_paid := .is_paid -}}
+
+
+
+
+{{- $unpaid_past := "#FFFFF0" -}}
+{{- $paid_past := "#FCFCA6" -}}
+{{- $unpaid_current := "#BBBBB0" -}}
+{{- $paid_current := "#BCBC7E" -}}
+{{- $colour := "" -}}
+
+
+
+
+{{- if $end_date -}}
+ {{- if $is_paid -}}
+ {{- $colour = $paid_past -}}
+ {{- else -}}
+ {{- $colour = $unpaid_past -}}
+ {{- end -}}
+{{- else -}}
+ {{- if $is_paid -}}
+ {{- $colour = $paid_current -}}
+ {{- else -}}
+ {{- $colour = $unpaid_current -}}
+ {{- end -}}
+{{- end }}
+
+{{- return $colour -}}
diff --git a/layouts/partials/cv/organisation/get_role_end_date.html b/layouts/partials/cv/organisation/get_role_end_date.html
new file mode 100644
index 0000000..6d7b9f6
--- /dev/null
+++ b/layouts/partials/cv/organisation/get_role_end_date.html
@@ -0,0 +1,21 @@
+
+
+
+
+{{- $end_date := "" -}}
+
+
+
+
+{{- if . -}}
+ {{- $end_date = . -}}
+{{- else -}}
+ {{- $end_date = ( now.Format "2006-01-02" ) -}}
+{{- end -}}
+
+{{- return ( printf "new Date('%s')" $end_date ) -}}
diff --git a/layouts/partials/cv/organisation/get_role_organisation_string.html b/layouts/partials/cv/organisation/get_role_organisation_string.html
new file mode 100644
index 0000000..d0c5f4a
--- /dev/null
+++ b/layouts/partials/cv/organisation/get_role_organisation_string.html
@@ -0,0 +1,38 @@
+
+
+
+
+
+{{- if ( not ( isset . "sc" ) ) -}}
+ {{- errorf "No site context passed" -}}
+{{- end -}}
+
+{{- if ( not ( isset . "pc" ) ) -}}
+ {{- errorf "No page context passed" -}}
+{{- end -}}
+
+
+
+{{- $parents := slice -}}
+
+
+
+{{- with .pc.Params.organisations -}}
+ {{- range . -}}
+ {{-
+ $parents = $parents | append (
+ partialCached
+ "cv/organisation/get_organisation_parents.html"
+ ( dict "sc" $.sc "pc" $.pc "organisation" . )
+ .
+ )
+ -}}
+ {{- end -}}
+{{- end -}}
+
+{{- return ( delimit $parents ", ") -}}
diff --git a/layouts/partials/cv/organisation/get_role_role_string.html b/layouts/partials/cv/organisation/get_role_role_string.html
new file mode 100644
index 0000000..4d83ed7
--- /dev/null
+++ b/layouts/partials/cv/organisation/get_role_role_string.html
@@ -0,0 +1,35 @@
+
+
+
+
+
+{{- if ( not ( isset . "sc" ) ) -}}
+ {{- errorf "No site context passed" -}}
+{{- end -}}
+
+{{- if ( not ( isset . "pc" ) ) -}}
+ {{- errorf "No page context passed" -}}
+{{- end -}}
+
+
+
+{{- $role_text := "" -}}
+
+
+
+{{- if ( and ( .pc.Params.redact ) ( ne .sc.Site.Params.redact "show" ) ) -}}
+ {{- if ( eq .sc.Site.Params.redact "black" ) -}}
+ {{- $role_text = "███████████████" -}}
+
+ {{- end -}}
+
+{{- else -}}
+ {{- $role_text = .pc.Title | htmlUnescape | plainify -}}
+{{- end -}}
+
+{{- return $role_text -}}
diff --git a/layouts/partials/cv/organisation/get_role_start_date.html b/layouts/partials/cv/organisation/get_role_start_date.html
new file mode 100644
index 0000000..abd1b29
--- /dev/null
+++ b/layouts/partials/cv/organisation/get_role_start_date.html
@@ -0,0 +1,17 @@
+
+
+
+
+{{- if ( not ( eq (printf "%T" . ) "time.Time" ) ) -}}
+ {{- errorf "Start date is not a `time.Time`, it's a %T" . -}}
+{{- end -}}
+
+
+
+
+{{- return ( printf "new Date('%s')" ( .Format "2006-01-02" ) ) -}}