feat: add redaction

This commit is contained in:
Ben Goldsworthy 2023-12-12 22:40:30 +00:00
parent a35946ae92
commit b2dba13746
8 changed files with 1373 additions and 103 deletions

File diff suppressed because it is too large Load diff

View file

@ -36,9 +36,37 @@
{{- $paid_current := "#BCBC7E" -}}
{{ with ( .GetPage "cv/roles" ).Pages -}}
{{- range ( where . ".Params.organisations" "intersect" $titles ) -}}
{{- if ( not ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) ) -}}
[
"{{- delimit ( intersect .Params.organisations $titles ) ", " | safeHTML -}}",
"{{- .Title | plainify -}}",
"
{{- 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 -}}
@ -61,6 +89,7 @@
{{- end -}}
")
],
{{- end -}}
{{- end -}}
{{ end -}}
]);
@ -93,10 +122,13 @@
style="background-image: url({{ .RelPermalink }})"
{{ 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">{{ if ( .Params.markup_title ) }}{{ .Params.markup_title | safeHTML }}{{ else }}{{ .Title }}{{ end }}</h2>
</div>
<div class="article-header__title-wrapper{{ if .Params.title_in_logo }} article-header__title-wrapper--no-title{{ end }}">
<h2 class="article-header__title">{{ if ( .Params.markup_title ) }}{{ .Params.markup_title | safeHTML }}{{ else }}{{ .Title }}{{ end }}</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">
@ -148,37 +180,37 @@
<section id="related" class="row">
{{- $titles := .Scratch.Get "titles" -}}
{{ range (where ((.GetPage "blog").Sections) "Title" "Blog Posts") }}
{{ range ( where ( ( .GetPage "blog" ).Sections ) "Title" "Blog Posts" ) }}
{{ $section_title := .Title }}
{{ with where (where ( where .Site.Pages "Section" "blog" ) "Parent.Title" .Title ) ".Params.organisations" "intersect" $titles }}
{{ with where ( where ( where ( where .Site.Pages "Section" "blog" ) "Parent.Title" .Title ) ".Params.organisations" "intersect" $titles ) ".Params.redact" false }}
{{ partial "cv/organisations/organisation-items.html" ( dict "section_title" $section_title "content" . ) }}
{{ end }}
{{ end }}
{{ range (where ((.GetPage "portfolio").Sections) "Title" "!=" "Appearances").ByTitle }}
{{ range ( where ( ( .GetPage "portfolio" ).Sections ) "Title" "!=" "Appearances" ).ByTitle }}
{{ $section_title := .Title }}
{{ with where (where ( where .Site.Pages "Section" "portfolio" ) "Parent.Title" .Title ) ".Params.organisations" "intersect" $titles }}
{{ with where ( where ( where ( where .Site.Pages "Section" "portfolio" ) "Parent.Title" .Title ) ".Params.organisations" "intersect" $titles ) ".Params.redact" false }}
{{ partial "cv/organisations/organisation-items.html" ( dict "section_title" $section_title "content" . ) }}
{{ end }}
{{ end }}
{{ range (where ((.GetPage "cv").Sections) "Title" "Qualifications") }}
{{ range ( where ( ( .GetPage "cv" ).Sections ) "Title" "Qualifications" ) }}
{{ $section_title := .Title }}
{{ with where (where ( where .Site.Pages "Section" "cv" ) "Parent.Title" .Title ) ".Params.organisations" "intersect" $titles }}
{{ with where ( where ( where ( where .Site.Pages "Section" "cv" ) "Parent.Title" .Title ) ".Params.organisations" "intersect" $titles ) ".Params.redact" false }}
{{ partial "cv/organisations/organisation-items.html" ( dict "section_title" $section_title "content" . ) }}
{{ end }}
{{ end }}
{{ range (where ((.GetPage "cv").Sections) "Title" "Awards") }}
{{ range ( where ( (.GetPage "cv").Sections ) "Title" "Awards" ) }}
{{ $section_title := .Title }}
{{ with where (where ( where .Site.Pages "Section" "cv" ) "Parent.Title" .Title ) ".Params.organisations" "intersect" $titles }}
{{ with where ( where ( where ( where .Site.Pages "Section" "cv" ) "Parent.Title" .Title ) ".Params.organisations" "intersect" $titles ) ".Params.redact" false }}
{{ partial "cv/organisations/organisation-items.html" ( dict "section_title" $section_title "content" . ) }}
{{ end }}
{{ end }}
{{ range (where ((.GetPage "portfolio").Sections) "Title" "Appearances").ByTitle }}
{{ range ( where ( (.GetPage "portfolio").Sections ) "Title" "Appearances" ).ByTitle }}
{{ $section_title := .Title }}
{{ with where (where ( where .Site.Pages "Section" "portfolio" ) "Parent.Title" .Title ) ".Params.organisations" "intersect" $titles }}
{{ with where ( where ( where ( where .Site.Pages "Section" "portfolio" ) "Parent.Title" .Title ) ".Params.organisations" "intersect" $titles ) ".Params.redact" false }}
{{ partial "cv/organisations/organisation-items.html" ( dict "section_title" $section_title "content" . ) }}
{{ end }}
{{ end }}

View file

@ -1,13 +0,0 @@
<!--. is .c-->
<!--$ is .g-->
{{ $scratch := .g.Scratch }}
{{ if .c.Parent }}
{{ if ne .c.Parent.Type "cv/organisations" }}
{{ with .c.Parent }}
{{ partial "cv/organisations/recursive-parents.html" (dict "c" . "g" $.g ) }}
{{ end }}
{{ else }}
{{ $scratch.Set "top-level-parent" .c.Parent }}
{{ end }}
{{ end }}

View file

@ -9,30 +9,44 @@
</tr>
</thead>
<tbody>
{{ range .Pages }}
{{- range .Pages -}}
{{- if ( not ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) ) -}}
<tr>
<td>
{{- if .Params.featured_image -}}
<img class="organisation-table__logo" loading="lazy" src="
{{- if .Resources.GetMatch .Params.featured_image -}}
{{- ( .Resources.GetMatch .Params.featured_image ).RelPermalink -}}
{{- else -}}
{{- .Params.featured_image -}}
{{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
{{- if ( eq $.Site.Params.redact "black" ) -}}
{{- partialCached "redact-black.html" . -}}
{{- end -}}
{{- else -}}
{{- if .Params.featured_image -}}
<img class="organisation-table__logo" loading="lazy" src="
{{- if .Resources.GetMatch .Params.featured_image -}}
{{- ( .Resources.GetMatch .Params.featured_image ).RelPermalink -}}
{{- else -}}
{{- .Params.featured_image -}}
{{- end -}}
">
{{- end -}}
">
{{- end -}}
</td>
<td>
<a href="{{ .RelPermalink }}">
{{- if .Params.TitleLang -}}<i lang="{{ .Params.TitleLang }}" title="{{ .Params.TitleTrans }}"}>{{- end -}}
{{- with .Params.markup_title -}}{{- . | safeHTML -}}{{- else -}}{{- .Title | safeHTML -}}{{- end -}}
{{- if .Params.TitleLang -}}</i>{{- end -}}
</a>
{{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
{{- if ( eq $.Site.Params.redact "black" ) -}}
{{- partialCached "redact-black.html" . -}}
{{- end -}}
{{- else -}}
<a href="{{ .RelPermalink }}">
{{- if .Params.TitleLang -}}<i lang="{{ .Params.TitleLang }}" title="{{ .Params.TitleTrans }}"}>{{- end -}}
{{- with .Params.markup_title -}}{{- . | safeHTML -}}{{- else -}}{{- .Title | safeHTML -}}{{- end -}}
{{- if .Params.TitleLang -}}</i>{{- end -}}
</a>
{{- end -}}
</td>
<td>{{- if gt (len .Sections) 0 -}}&#10004;{{- end -}}</td>
<td></td>
</tr>
{{ end }}
{{- end -}}
{{- end -}}
</tbody>
</table>
</section>

View file

@ -1,5 +1,22 @@
<li class="hierarchy-item hierarchy-item--child"><a href="{{ .RelPermalink }}">{{ with .Params.markup_title }}{{ . | safeHTML }}{{ else }}{{ .Title | safeHTML }}{{ end }}</a>
{{- range .Sections -}}<ul>
{{- partialCached "cv/organisations/recursive-children.html" . .Title -}}
</ul>{{- end -}}
{{- if ( not ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) ) -}}
<li class="hierarchy-item hierarchy-item--child">
{{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
{{- if ( eq $.Site.Params.redact "black" ) -}}
{{- partialCached "redact-black.html" . -}}
{{- end -}}
{{- else -}}
<a href="{{ .RelPermalink }}">
{{- with .Params.markup_title }}
{{- . | safeHTML -}}
{{- else -}}
{{- .Title | safeHTML -}}
{{- end -}}
</a>
{{- range .Sections -}}
<ul>
{{- partialCached "cv/organisations/recursive-children.html" . .Title -}}
</ul>
{{- end -}}
{{- end -}}
</li>
{{- end -}}

View file

@ -1,56 +1,69 @@
<a id="{{ .Title | urlize }}" class="h-entry u-url link--tile" href="{{ .RelPermalink }}" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<article class="item-tile lazy {{- with .Params.site }} item-tile--{{ . }}{{ end -}}"
{{ if .Params.featured_image }}
{{ with .Resources.GetMatch .Params.featured_image }}
{{ if eq .MediaType.SubType "svg" }}
style="background-image: url({{ .RelPermalink }})"
{{ else }}
{{ with .Resize "1000x webp" }}
style="background-image: url({{ .RelPermalink }})"
{{ end }}
{{ end }}
{{ else }}
style="background-image: url({{ .Params.featured_image }})"
{{ end }}
{{ end }}
>
{{ if .Params.featured_image -}}
<img class="u-photo" style="display: none;" src="
{{- with .Resources.GetMatch .Params.featured_image -}}
{{- if eq .MediaType.SubType "svg" -}}
{{ .RelPermalink }}
{{- else -}}
{{- with .Resize "1000x webp" -}}
{{- .RelPermalink -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{ .Params.featured_image }}
{{ end }}
" alt="
{{- with .Resources.GetMatch .Params.featured_image -}}
{{- .Params.alt -}}
{{- end -}}
"
/>
{{- end }}
{{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
{{- if ( eq $.Site.Params.redact "black" ) -}}
<article class="item-tile item-tile--redacted {{- with .Params.site }} item-tile--{{ . }}{{ end -}}">
<header class="item-tile__header">
{{ if ( or .Params.series .Params.published_in ) }}
<span class="item-tile__banner item-tile__banner--{{ if .Params.series }}series{{ else if .Params.published_in }}published-in{{ end}}">
{{- if .Params.series -}}
{{ .Params.series | safeHTML }}
{{- else if .Params.published_in -}}
{{ .Params.published_in | safeHTML }}
<h2 class="p-name item-tile__title{{ if gt ( len ( .Title | plainify ) ) 40 }} item-tile__title--long{{ end }}" itemprop="name">
{{- partialCached "redact-black.html" . -}}
</h2>
<p style="display: none;">Published: <time class="dt-published" itemprop="datePublished" datetime="{{ .PublishDate | time.Format "2006-01-02T15:04:05-07:00" }}">{{ .PublishDate | time.Format "2006-01-02T15:04:05-07:00"}}</time></p>
</header>
</article>
{{- end -}}
{{- else -}}
<a id="{{ .Title | urlize }}" class="h-entry u-url link--tile" href="{{ .RelPermalink }}" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
<article class="item-tile lazy {{- with .Params.site }} item-tile--{{ . }}{{ end -}}"
{{ if .Params.featured_image }}
{{ with .Resources.GetMatch .Params.featured_image }}
{{ if eq .MediaType.SubType "svg" }}
style="background-image: url({{ .RelPermalink }})"
{{ else }}
{{ with .Resize "1000x webp" }}
style="background-image: url({{ .RelPermalink }})"
{{ end }}
{{ end }}
{{ else }}
style="background-image: url({{ .Params.featured_image }})"
{{ end }}
{{ end }}
>
{{ if .Params.featured_image -}}
<img class="u-photo" style="display: none;" src="
{{- with .Resources.GetMatch .Params.featured_image -}}
{{- if eq .MediaType.SubType "svg" -}}
{{ .RelPermalink }}
{{- else -}}
{{- with .Resize "1000x webp" -}}
{{- .RelPermalink -}}
{{- end -}}
{{- end -}}
{{- else -}}
{{ .Params.featured_image }}
{{ end }}
" alt="
{{- with .Resources.GetMatch .Params.featured_image -}}
{{- .Params.alt -}}
{{- end -}}
</span>
{{ end }}
<h2 class="p-name item-tile__title{{ if gt ( len ( .Title | plainify ) ) 40 }} item-tile__title--long{{ end }}" itemprop="name">
{{ .Title | safeHTML }}
</h2>
{{ with .Params.subtitle }}
<p class="item-tile__subtitle">{{ . | safeHTML }}</p>
{{ end }}
<p style="display: none;">Published: <time class="dt-published" itemprop="datePublished" datetime="{{ .PublishDate | time.Format "2006-01-02T15:04:05-07:00" }}">{{ .PublishDate | time.Format "2006-01-02T15:04:05-07:00"}}</time></p>
</header>
</article>
</a>
"
/>
{{- end }}
<header class="item-tile__header">
{{ if ( or .Params.series .Params.published_in ) }}
<span class="item-tile__banner item-tile__banner--{{ if .Params.series }}series{{ else if .Params.published_in }}published-in{{ end}}">
{{- if .Params.series -}}
{{ .Params.series | safeHTML }}
{{- else if .Params.published_in -}}
{{ .Params.published_in | safeHTML }}
{{- end -}}
</span>
{{ end }}
<h2 class="p-name item-tile__title{{ if gt ( len ( .Title | plainify ) ) 40 }} item-tile__title--long{{ end }}" itemprop="name">
{{ .Title | safeHTML }}
</h2>
{{ with .Params.subtitle }}
<p class="item-tile__subtitle">{{ . | safeHTML }}</p>
{{ end }}
<p style="display: none;">Published: <time class="dt-published" itemprop="datePublished" datetime="{{ .PublishDate | time.Format "2006-01-02T15:04:05-07:00" }}">{{ .PublishDate | time.Format "2006-01-02T15:04:05-07:00"}}</time></p>
</header>
</article>
</a>
{{- end -}}

View file

@ -30,7 +30,7 @@
{{- .Scratch.Set "i" 0 -}}
{{- range ( .GetTerms "skills" ).ByTitle -}}
{{- if hasPrefix .LinkTitle "CIISec/" -}}
<li class="p-category"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a> <span class="level">{{ index $.Params.skills_ciisec_levels ( $.Scratch.Get "i" ) }}</span></li>
<li class="p-category"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a> <span class="level">(level {{ index $.Params.skills_ciisec_levels ( $.Scratch.Get "i" ) }})</span></li>
{{- $.Scratch.Add "i" 1 -}}
{{- else -}}
<li class="p-category"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
@ -49,7 +49,13 @@
{{- range ( .GetTerms "organisations" ) -}}
{{ with ( where $all_organisations "Title" ( .Title | plainify ) ) }}
{{ range . }}
<li><a href="{{ .RelPermalink }}">{{ if ( .Params.markup_title ) }}{{ .Params.markup_title | safeHTML }}{{ else }}{{ .Title }}{{ end }}</a></li>
{{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
{{- if ( eq $.Site.Params.redact "black" ) -}}
<li>{{- partialCached "redact-black.html" . -}}</li>
{{- end -}}
{{- else -}}
<li><a href="{{ .RelPermalink }}">{{ if ( .Params.markup_title ) }}{{ .Params.markup_title | safeHTML }}{{ else }}{{ .Title }}{{ end }}</a></li>
{{- end -}}
{{ end }}
{{ else }}
{{ erroridf "missing-organisation" "Could not find organisation %q (%q)" .Title $.File.Path }}

View file

@ -0,0 +1 @@
&#9608;&#9608;&#9608;&#9608;&#9608;&#9608;&#9608;&#9608;&#9608;&#9608;&#9608;