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" -}} {{- $paid_current := "#BCBC7E" -}}
{{ with ( .GetPage "cv/roles" ).Pages -}} {{ with ( .GetPage "cv/roles" ).Pages -}}
{{- range ( where . ".Params.organisations" "intersect" $titles ) -}} {{- 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.end_date -}}
{{- if .Params.paid -}} {{- if .Params.paid -}}
{{- $paid_past -}} {{- $paid_past -}}
@ -62,6 +90,7 @@
") ")
], ],
{{- end -}} {{- end -}}
{{- end -}}
{{ end -}} {{ end -}}
]); ]);
@ -97,6 +126,9 @@
<h2 class="article-header__title">{{ if ( .Params.markup_title ) }}{{ .Params.markup_title | safeHTML }}{{ else }}{{ .Title }}{{ end }}</h2> <h2 class="article-header__title">{{ if ( .Params.markup_title ) }}{{ .Params.markup_title | safeHTML }}{{ else }}{{ .Title }}{{ end }}</h2>
</div> </div>
</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> </header>
{{ else }} {{ else }}
<header class="site-content__header"> <header class="site-content__header">
@ -148,37 +180,37 @@
<section id="related" class="row"> <section id="related" class="row">
{{- $titles := .Scratch.Get "titles" -}} {{- $titles := .Scratch.Get "titles" -}}
{{ range (where ((.GetPage "blog").Sections) "Title" "Blog Posts") }} {{ range ( where ( ( .GetPage "blog" ).Sections ) "Title" "Blog Posts" ) }}
{{ $section_title := .Title }} {{ $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" . ) }} {{ partial "cv/organisations/organisation-items.html" ( dict "section_title" $section_title "content" . ) }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ range (where ((.GetPage "portfolio").Sections) "Title" "!=" "Appearances").ByTitle }} {{ range ( where ( ( .GetPage "portfolio" ).Sections ) "Title" "!=" "Appearances" ).ByTitle }}
{{ $section_title := .Title }} {{ $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" . ) }} {{ partial "cv/organisations/organisation-items.html" ( dict "section_title" $section_title "content" . ) }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ range (where ((.GetPage "cv").Sections) "Title" "Qualifications") }} {{ range ( where ( ( .GetPage "cv" ).Sections ) "Title" "Qualifications" ) }}
{{ $section_title := .Title }} {{ $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" . ) }} {{ partial "cv/organisations/organisation-items.html" ( dict "section_title" $section_title "content" . ) }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ range (where ((.GetPage "cv").Sections) "Title" "Awards") }} {{ range ( where ( (.GetPage "cv").Sections ) "Title" "Awards" ) }}
{{ $section_title := .Title }} {{ $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" . ) }} {{ partial "cv/organisations/organisation-items.html" ( dict "section_title" $section_title "content" . ) }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ range (where ((.GetPage "portfolio").Sections) "Title" "Appearances").ByTitle }} {{ range ( where ( (.GetPage "portfolio").Sections ) "Title" "Appearances" ).ByTitle }}
{{ $section_title := .Title }} {{ $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" . ) }} {{ partial "cv/organisations/organisation-items.html" ( dict "section_title" $section_title "content" . ) }}
{{ end }} {{ end }}
{{ 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,9 +9,15 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{{ range .Pages }} {{- range .Pages -}}
{{- if ( not ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) ) -}}
<tr> <tr>
<td> <td>
{{- 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 -}} {{- if .Params.featured_image -}}
<img class="organisation-table__logo" loading="lazy" src=" <img class="organisation-table__logo" loading="lazy" src="
{{- if .Resources.GetMatch .Params.featured_image -}} {{- if .Resources.GetMatch .Params.featured_image -}}
@ -21,18 +27,26 @@
{{- end -}} {{- end -}}
"> ">
{{- end -}} {{- end -}}
{{- end -}}
</td> </td>
<td> <td>
{{- if ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) -}}
{{- if ( eq $.Site.Params.redact "black" ) -}}
{{- partialCached "redact-black.html" . -}}
{{- end -}}
{{- else -}}
<a href="{{ .RelPermalink }}"> <a href="{{ .RelPermalink }}">
{{- if .Params.TitleLang -}}<i lang="{{ .Params.TitleLang }}" title="{{ .Params.TitleTrans }}"}>{{- end -}} {{- if .Params.TitleLang -}}<i lang="{{ .Params.TitleLang }}" title="{{ .Params.TitleTrans }}"}>{{- end -}}
{{- with .Params.markup_title -}}{{- . | safeHTML -}}{{- else -}}{{- .Title | safeHTML -}}{{- end -}} {{- with .Params.markup_title -}}{{- . | safeHTML -}}{{- else -}}{{- .Title | safeHTML -}}{{- end -}}
{{- if .Params.TitleLang -}}</i>{{- end -}} {{- if .Params.TitleLang -}}</i>{{- end -}}
</a> </a>
{{- end -}}
</td> </td>
<td>{{- if gt (len .Sections) 0 -}}&#10004;{{- end -}}</td> <td>{{- if gt (len .Sections) 0 -}}&#10004;{{- end -}}</td>
<td></td> <td></td>
</tr> </tr>
{{ end }} {{- end -}}
{{- end -}}
</tbody> </tbody>
</table> </table>
</section> </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> {{- if ( not ( and ( .Params.redact ) ( ne $.Site.Params.redact "show" ) ) ) -}}
{{- range .Sections -}}<ul> <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 -}} {{- partialCached "cv/organisations/recursive-children.html" . .Title -}}
</ul>{{- end -}} </ul>
{{- end -}}
{{- end -}}
</li> </li>
{{- end -}}

View file

@ -1,4 +1,16 @@
<a id="{{ .Title | urlize }}" class="h-entry u-url link--tile" href="{{ .RelPermalink }}" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting"> {{- 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">
<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 -}}" <article class="item-tile lazy {{- with .Params.site }} item-tile--{{ . }}{{ end -}}"
{{ if .Params.featured_image }} {{ if .Params.featured_image }}
{{ with .Resources.GetMatch .Params.featured_image }} {{ with .Resources.GetMatch .Params.featured_image }}
@ -53,4 +65,5 @@
<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> <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> </header>
</article> </article>
</a> </a>
{{- end -}}

View file

@ -30,7 +30,7 @@
{{- .Scratch.Set "i" 0 -}} {{- .Scratch.Set "i" 0 -}}
{{- range ( .GetTerms "skills" ).ByTitle -}} {{- range ( .GetTerms "skills" ).ByTitle -}}
{{- if hasPrefix .LinkTitle "CIISec/" -}} {{- 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 -}} {{- $.Scratch.Add "i" 1 -}}
{{- else -}} {{- else -}}
<li class="p-category"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li> <li class="p-category"><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></li>
@ -49,7 +49,13 @@
{{- range ( .GetTerms "organisations" ) -}} {{- range ( .GetTerms "organisations" ) -}}
{{ with ( where $all_organisations "Title" ( .Title | plainify ) ) }} {{ with ( where $all_organisations "Title" ( .Title | plainify ) ) }}
{{ range . }} {{ range . }}
{{- 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> <li><a href="{{ .RelPermalink }}">{{ if ( .Params.markup_title ) }}{{ .Params.markup_title | safeHTML }}{{ else }}{{ .Title }}{{ end }}</a></li>
{{- end -}}
{{ end }} {{ end }}
{{ else }} {{ else }}
{{ erroridf "missing-organisation" "Could not find organisation %q (%q)" .Title $.File.Path }} {{ 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;