From 93419f22da349b0b30bbf121ef58f36a41fe1789 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Thu, 15 Feb 2024 17:17:35 +0100 Subject: [PATCH] remove PrepareText --- layouts/events/single.html | 4 ++-- layouts/partials/GetTruncateContent | 2 +- layouts/partials/PrepareText | 6 ------ layouts/partials/blocks/templates/definitions.html | 4 ++-- layouts/partials/blocks/templates/features.html | 4 ++-- layouts/partials/blocks/templates/gallery/carousel.html | 8 ++++---- layouts/partials/blocks/templates/gallery/grid.html | 4 ++-- layouts/partials/blocks/templates/sound.html | 2 +- .../partials/blocks/templates/timeline/horizontal.html | 2 +- layouts/partials/blocks/templates/timeline/vertical.html | 8 ++++---- layouts/partials/commons/summary-in-content.html | 2 +- layouts/partials/diplomas/diplomas.html | 2 +- layouts/partials/diplomas/hero-single.html | 2 +- layouts/partials/head/seo.html | 2 +- layouts/partials/header/hero.html | 2 +- layouts/partials/pages/page.html | 4 ++-- layouts/partials/papers/abstract.html | 2 +- layouts/partials/papers/citations.html | 8 +++++++- layouts/partials/papers/summary.html | 2 +- layouts/partials/persons/hero-single.html | 2 +- layouts/partials/persons/list-item.html | 2 +- layouts/partials/persons/person.html | 2 +- layouts/partials/posts/author.html | 2 +- layouts/partials/programs/hero-single.html | 2 +- layouts/partials/publications/citations.html | 8 +++++++- layouts/posts/single.html | 6 +++--- 26 files changed, 50 insertions(+), 44 deletions(-) delete mode 100644 layouts/partials/PrepareText diff --git a/layouts/events/single.html b/layouts/events/single.html index 853cd94f..f1c4debe 100644 --- a/layouts/events/single.html +++ b/layouts/events/single.html @@ -4,8 +4,8 @@ <div class="document-content" itemscope itemtype="https://schema.org/Event"> <meta itemprop="name" content="{{ partial "PrepareHTML" .Title }}"> <meta itemprop="url" content="{{ .Permalink }}"> - {{ if .Params.summary }}<meta itemprop="abstract" content="{{ partial "PrepareText" .Params.summary }}">{{ end }} - {{ if .Summary }}<meta itemprop="description" content="{{ partial "PrepareText" .Summary }}">{{ end }} + {{ with .Params.summary }}<meta itemprop="abstract" content="{{ . | safeHTML }}">{{ end }} + {{ with .Summary }}<meta itemprop="description" content="{{ . | safeHTML }}">{{ end }} {{ partial "events/sidebar.html" . }} diff --git a/layouts/partials/GetTruncateContent b/layouts/partials/GetTruncateContent index ab6ddc10..1c066b83 100644 --- a/layouts/partials/GetTruncateContent +++ b/layouts/partials/GetTruncateContent @@ -6,4 +6,4 @@ {{ $text = chomp (truncate $length "…" (safeHTML (plainify $text))) }} {{ end }} -{{ return (partial "PrepareText" $text) }} \ No newline at end of file +{{ return safeHTML ($text) }} \ No newline at end of file diff --git a/layouts/partials/PrepareText b/layouts/partials/PrepareText deleted file mode 100644 index 8944cd99..00000000 --- a/layouts/partials/PrepareText +++ /dev/null @@ -1,6 +0,0 @@ -{{ -return - safeHTML ( - . - ) -}} \ No newline at end of file diff --git a/layouts/partials/blocks/templates/definitions.html b/layouts/partials/blocks/templates/definitions.html index 7cf7d624..64a79a9f 100644 --- a/layouts/partials/blocks/templates/definitions.html +++ b/layouts/partials/blocks/templates/definitions.html @@ -12,8 +12,8 @@ <div class="definitions"> {{- range .elements }} <details itemscope itemtype="https://schema.org/DefinedTerm"> - <summary itemprop="name">{{ partial "PrepareText" .title }}</summary> - <p itemprop="description">{{ partial "PrepareText" .description }}</p> + <summary itemprop="name">{{ .title | safeHTML }}</summary> + <p itemprop="description">{{ .description | safeHTML }}</p> </details> {{ end -}} </div> diff --git a/layouts/partials/blocks/templates/features.html b/layouts/partials/blocks/templates/features.html index 76e172a7..8f7f9f82 100644 --- a/layouts/partials/blocks/templates/features.html +++ b/layouts/partials/blocks/templates/features.html @@ -22,9 +22,9 @@ "attributes" "class='name' itemprop='name'" ) -}} {{ $heading_tag.open -}} - {{ partial "PrepareText" .title }} + {{ .title | safeHTML }} {{ $heading_tag.close -}} - <p>{{ partial "PrepareText" .description }}</p> + <p>{{ .description | safeHTML }}</p> </div> {{- if .image -}} <figure> diff --git a/layouts/partials/blocks/templates/gallery/carousel.html b/layouts/partials/blocks/templates/gallery/carousel.html index de6811bc..b1b5a396 100644 --- a/layouts/partials/blocks/templates/gallery/carousel.html +++ b/layouts/partials/blocks/templates/gallery/carousel.html @@ -33,11 +33,11 @@ {{ end }} {{ if or .text .credit }} <figcaption> - {{ if .text }} - <p>{{ partial "PrepareText" .text }}</p> + {{ with .text }} + <p>{{ . | safeHTML }}</p> {{ end }} - {{ if .credit }} - <div class="credit">{{ partial "PrepareText" .credit }}</div> + {{ with .credit }} + <div class="credit">{{ . | safeHTML }}</div> {{ end }} </figcaption> {{ end }} diff --git a/layouts/partials/blocks/templates/gallery/grid.html b/layouts/partials/blocks/templates/gallery/grid.html index 999cb8cd..8ffcd8ba 100644 --- a/layouts/partials/blocks/templates/gallery/grid.html +++ b/layouts/partials/blocks/templates/gallery/grid.html @@ -33,9 +33,9 @@ {{ if not site.Params.image_sizes.design_system.lightbox.disabled }} </a> {{ end }} - {{ if .text }} + {{ with .text }} <figcaption> - <p>{{- partial "PrepareText" .text -}}</p> + <p>{{- . | safeHTML -}}</p> </figcaption> {{ end }} </figure> diff --git a/layouts/partials/blocks/templates/sound.html b/layouts/partials/blocks/templates/sound.html index b52ed91a..c6fc6f02 100644 --- a/layouts/partials/blocks/templates/sound.html +++ b/layouts/partials/blocks/templates/sound.html @@ -14,7 +14,7 @@ {{ if .file }} {{ $file := partial "GetMedia" .file.id }} {{ if $file }} - <audio src="{{ $file.direct_url }}" controls title="{{ partial "PrepareText" .title }}"></audio> + <audio src="{{ $file.direct_url }}" controls title="{{ .title | safeHTML }}"></audio> {{ end }} {{ end }} diff --git a/layouts/partials/blocks/templates/timeline/horizontal.html b/layouts/partials/blocks/templates/timeline/horizontal.html index 03e5c5ef..d029f091 100644 --- a/layouts/partials/blocks/templates/timeline/horizontal.html +++ b/layouts/partials/blocks/templates/timeline/horizontal.html @@ -12,7 +12,7 @@ <li class="timeline-event"> {{ $heading_tag.open -}} - {{ partial "PrepareText" .title }} + {{ .title | safeHTML }} {{ $heading_tag.close -}} <div class="line"></div> <div class="description text">{{- partial "PrepareHTML" .text | markdownify -}}</div> diff --git a/layouts/partials/blocks/templates/timeline/vertical.html b/layouts/partials/blocks/templates/timeline/vertical.html index 77fbfdfd..1abf2727 100644 --- a/layouts/partials/blocks/templates/timeline/vertical.html +++ b/layouts/partials/blocks/templates/timeline/vertical.html @@ -8,13 +8,13 @@ <div class="timeline-events"> {{ range .events -}} <article class="timeline-event"> - {{ if .title }} + {{ with .title }} {{ $heading_tag.open -}} - {{ partial "PrepareText" .title }} + {{ . | safeHTML }} {{ $heading_tag.close -}} {{ end }} - {{ if .text }} - <p>{{ partial "PrepareText" .text }}</p> + {{ with .text }} + <p>{{ . | safeHTML }}</p> {{ end }} </article> {{ end -}} diff --git a/layouts/partials/commons/summary-in-content.html b/layouts/partials/commons/summary-in-content.html index 18bf1c32..077e44e1 100644 --- a/layouts/partials/commons/summary-in-content.html +++ b/layouts/partials/commons/summary-in-content.html @@ -1,4 +1,4 @@ -{{ $summary := .summary | default (partial "PrepareText" .context.Params.summary) }} +{{ $summary := .summary | default (.context.Params.summary | safeHTML) }} {{- if and (eq site.Params.summary.position "content") $summary -}} {{- if .block_wrapped -}} <div class="block block-summary"> diff --git a/layouts/partials/diplomas/diplomas.html b/layouts/partials/diplomas/diplomas.html index aed223f9..0c15a8d0 100644 --- a/layouts/partials/diplomas/diplomas.html +++ b/layouts/partials/diplomas/diplomas.html @@ -11,7 +11,7 @@ </a> <div class="content"> <div class="description"> - {{- partial "PrepareText" .Params.summary -}} + {{- .Params.summary | safeHTML -}} </div> <ol class="programs"> diff --git a/layouts/partials/diplomas/hero-single.html b/layouts/partials/diplomas/hero-single.html index 39ed5698..c45f7fb4 100644 --- a/layouts/partials/diplomas/hero-single.html +++ b/layouts/partials/diplomas/hero-single.html @@ -1,7 +1,7 @@ {{- $breadcrumb_is_after_hero := eq site.Params.breadcrumb.position "after-hero" -}} {{- $title := or .Params.header_text .Title -}} {{ $subtitle := "" }} -{{- $summary := partial "PrepareText" .Params.summary -}} +{{- $summary := .Params.summary | safeHTML -}} {{ if and (eq site.Params.summary.position "hero") $summary }} {{ $subtitle = $summary }} {{ end }} diff --git a/layouts/partials/head/seo.html b/layouts/partials/head/seo.html index ac7dc711..b812e410 100644 --- a/layouts/partials/head/seo.html +++ b/layouts/partials/head/seo.html @@ -11,7 +11,7 @@ {{- else if .Params.description -}} {{- $seoDescription = partial "PrepareHTML" .Params.description -}} {{/* LEGACY */}} {{- else if .Params.summary -}} - {{- $seoDescription = partial "PrepareText" .Params.summary -}} + {{- $seoDescription = .Params.summary | safeHTML -}} {{- else if .Content -}} {{- $seoDescription = partial "GetTruncateContent" ( dict "text" .Content ) -}} {{- else if .Params.legacy_text -}} diff --git a/layouts/partials/header/hero.html b/layouts/partials/header/hero.html index 65f8abf5..78fe9399 100644 --- a/layouts/partials/header/hero.html +++ b/layouts/partials/header/hero.html @@ -6,7 +6,7 @@ {{- $direction = partial "GetImageDirection" .image -}} {{ end }} -{{- $summary := partial "PrepareText" .context.Params.summary -}} +{{- $summary := .context.Params.summary | safeHTML -}} {{- $subtitle_is_summary := false -}} {{ if not $subtitle }} diff --git a/layouts/partials/pages/page.html b/layouts/partials/pages/page.html index d3ecfcf8..6bc6d96e 100644 --- a/layouts/partials/pages/page.html +++ b/layouts/partials/pages/page.html @@ -16,8 +16,8 @@ {{- partial "PrepareHTML" .Title -}} </a> {{- partial "PrepareHTML" (printf "</%s>" $heading) -}} - {{- if .Params.summary }} - <p>{{ partial "PrepareText" .Params.summary }}</p> + {{- with .Params.summary }} + <p>{{ . | safeHTML }}</p> {{ end -}} </div> </article> diff --git a/layouts/partials/papers/abstract.html b/layouts/partials/papers/abstract.html index 702fde2f..1b6a5cbc 100644 --- a/layouts/partials/papers/abstract.html +++ b/layouts/partials/papers/abstract.html @@ -1,7 +1,7 @@ <section class="paper-essentials" id="abstract"> {{ with .Params.Abstract }} <h2>{{ i18n "papers.abstract" }}</h2> - <p itemprop="abstract">{{ partial "PrepareText" . }}</p> + <p itemprop="abstract">{{ . | safeHTML }}</p> {{ end }} {{ if .Params.Pdf }} <h2>{{ i18n "papers.download" }}</h2> diff --git a/layouts/partials/papers/citations.html b/layouts/partials/papers/citations.html index 508515cf..2675cef5 100644 --- a/layouts/partials/papers/citations.html +++ b/layouts/partials/papers/citations.html @@ -4,7 +4,13 @@ <div> {{ range .Params.citations }} <div class="citation"> - <a data-click-to-copy="{{- partial "PrepareText" .content -}}" role="button" title="{{ i18n "commons.click_to_copy.button_title" }}" aria-label="{{ i18n "commons.click_to_copy.aria_label" (dict "description" .label )}}" tabindex="0">{{ .label }}</a> + <a data-click-to-copy="{{- .content | safeHTML -}}" + role="button" + title="{{ i18n "commons.click_to_copy.button_title" }}" + aria-label="{{ i18n "commons.click_to_copy.aria_label" (dict "description" .label )}}" + tabindex="0"> + {{ .label }} + </a> <p>{{ partial "PrepareHTML" .content }}</p> </div> {{ end }} diff --git a/layouts/partials/papers/summary.html b/layouts/partials/papers/summary.html index 45c401a2..08de78ed 100644 --- a/layouts/partials/papers/summary.html +++ b/layouts/partials/papers/summary.html @@ -1,4 +1,4 @@ -{{ $summary := (partial "PrepareText" .Params.summary) }} +{{ $summary := .Params.summary | safeHTML }} {{- if and (eq site.Params.summary.position "content") $summary -}} <section> <h2 class="lead">{{ $summary }}</h2> diff --git a/layouts/partials/persons/hero-single.html b/layouts/partials/persons/hero-single.html index 928702e8..eb46dc1c 100644 --- a/layouts/partials/persons/hero-single.html +++ b/layouts/partials/persons/hero-single.html @@ -1,6 +1,6 @@ {{- $breadcrumb_is_after_hero := eq site.Params.breadcrumb.position "after-hero" -}} {{ $subtitle := "" }} -{{- $summary := partial "PrepareText" .Params.summary -}} +{{- $summary := .Params.summary | safeHTML -}} {{ if and (eq site.Params.summary.position "hero") $summary }} {{ $subtitle = $summary }} {{ end }} diff --git a/layouts/partials/persons/list-item.html b/layouts/partials/persons/list-item.html index 8f004eca..dd7f669c 100644 --- a/layouts/partials/persons/list-item.html +++ b/layouts/partials/persons/list-item.html @@ -1,6 +1,6 @@ <li itemscope itemtype="https://schema.org/Person"> <p itemprop="name"><a href="{{ .Permalink }}">{{ partial "PrepareHTML" .Title }}</a></p> {{- if partial "GetTextFromHTML" .Params.summary }} - <p itemprop="jobTitle">{{- partial "PrepareText" .Params.summary -}}</p> + <p itemprop="jobTitle">{{- .Params.summary | safeHTML -}}</p> {{ end -}} </li> \ No newline at end of file diff --git a/layouts/partials/persons/person.html b/layouts/partials/persons/person.html index 2b709098..b047ff1e 100644 --- a/layouts/partials/persons/person.html +++ b/layouts/partials/persons/person.html @@ -3,7 +3,7 @@ {{- $title := partial "PrepareHTML" .Title }} <p class="name"><a href="{{ .Permalink }}">{{- $title -}}</a></p> {{- if partial "GetTextFromHTML" .Params.summary }} - <p>{{- partial "PrepareText" .Params.summary -}}</p> + <p>{{- .Params.summary | safeHTML -}}</p> {{ else if (partial "GetTextFromHTML" .Content) }} <p>{{- partial "GetTruncateContent" ( dict "text" .Content ) -}}</p> {{ end -}} diff --git a/layouts/partials/posts/author.html b/layouts/partials/posts/author.html index f0766546..6daa6199 100644 --- a/layouts/partials/posts/author.html +++ b/layouts/partials/posts/author.html @@ -2,7 +2,7 @@ {{- $person := site.GetPage (printf "/persons/%s" .Slug) -}} {{ with $person }} <div class="post-author" itemscope itemtype="https://schema.org/Person" itemprop="author"> - <p itemprop="name">{{ partial "PrepareText" .Title }}</p> + <p itemprop="name">{{ .Title | safeHTML }}</p> </div> {{ end }} {{ end }} \ No newline at end of file diff --git a/layouts/partials/programs/hero-single.html b/layouts/partials/programs/hero-single.html index 652ebe20..deb0f4ae 100644 --- a/layouts/partials/programs/hero-single.html +++ b/layouts/partials/programs/hero-single.html @@ -1,7 +1,7 @@ {{- $breadcrumb_is_after_hero := eq site.Params.breadcrumb.position "after-hero" -}} {{- $title := or .Params.header_text .Title -}} {{ $subtitle := "" }} -{{- $summary := partial "PrepareText" .Params.summary -}} +{{- $summary := .Params.summary | safeHTML -}} {{ if and (eq site.Params.summary.position "hero") $summary }} {{ $subtitle = $summary }} {{ end }} diff --git a/layouts/partials/publications/citations.html b/layouts/partials/publications/citations.html index 559b6d8e..c98fb331 100644 --- a/layouts/partials/publications/citations.html +++ b/layouts/partials/publications/citations.html @@ -4,7 +4,13 @@ <div> {{ range .Params.citations }} <div class="citation"> - <a data-click-to-copy="{{- partial "PrepareText" .content -}}" role="button" title="{{ i18n "commons.click_to_copy.button_title" }}" aria-label="{{ i18n "commons.click_to_copy.aria_label" (dict "description" .label )}}" tabindex="0">{{ .label }}</a> + <a data-click-to-copy="{{- .content | safeHTML -}}" + role="button" + title="{{ i18n "commons.click_to_copy.button_title" }}" + aria-label="{{ i18n "commons.click_to_copy.aria_label" (dict "description" .label )}}" + tabindex="0"> + {{ .label }} + </a> <p>{{ partial "PrepareHTML" .content }}</p> </div> {{ end }} diff --git a/layouts/posts/single.html b/layouts/posts/single.html index b87446a4..5523950f 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -4,9 +4,9 @@ <div class="document-content" itemscope itemtype="https://schema.org/NewsArticle"> <meta itemprop="headline" content="{{ partial "PrepareHTML" .Title }}"> <meta itemprop="url" content="{{ .Permalink }}"> - {{ if .Date }}<meta itemprop="datePublished" content="{{ .Date.Format "2006-01-02T15:04" }}">{{ end }} - {{ if .Params.summary }}<meta itemprop="abstract" content="{{ partial "PrepareText" .Params.summary }}">{{ end }} - {{ if .Summary }}<meta itemprop="description" content="{{ partial "PrepareText" .Summary }}">{{ end }} + {{ with .Date }}<meta itemprop="datePublished" content="{{ .Format "2006-01-02T15:04" }}">{{ end }} + {{ with .Params.summary }}<meta itemprop="abstract" content="{{ . | safeHTML }}">{{ end }} + {{ with .Summary }}<meta itemprop="description" content="{{ . | safeHTML }}">{{ end }} {{ partial "posts/sidebar.html" . }} -- GitLab