From e23e23e847607a9f49c1246378c7fef56ff08fb7 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sat, 18 Dec 2021 11:42:28 +0000 Subject: [PATCH] feat: migrate Portfolio widget to unified view system See https://wowchemy.com/docs/getting-started/page-builder/#view Close #2557 --- .../partials/functions/render_view.html | 10 +-- .../layouts/partials/portfolio_li_card.html | 44 ------------- .../partials/portfolio_li_compact.html | 6 -- .../layouts/partials/portfolio_li_list.html | 6 -- .../partials/portfolio_li_showcase.html | 61 ------------------- wowchemy/layouts/partials/views/card.html | 13 +++- wowchemy/layouts/partials/views/masonry.html | 45 ++++++++++++++ .../layouts/partials/widgets/portfolio.html | 32 ++++------ 8 files changed, 73 insertions(+), 144 deletions(-) delete mode 100644 wowchemy/layouts/partials/portfolio_li_card.html delete mode 100644 wowchemy/layouts/partials/portfolio_li_compact.html delete mode 100644 wowchemy/layouts/partials/portfolio_li_list.html delete mode 100644 wowchemy/layouts/partials/portfolio_li_showcase.html create mode 100644 wowchemy/layouts/partials/views/masonry.html diff --git a/wowchemy/layouts/partials/functions/render_view.html b/wowchemy/layouts/partials/functions/render_view.html index 73a5058d..7eacab72 100644 --- a/wowchemy/layouts/partials/functions/render_view.html +++ b/wowchemy/layouts/partials/functions/render_view.html @@ -7,14 +7,16 @@ {{ $view_dtype := printf "%T" $view }} {{ $index := .index }} -{{if eq $view_dtype "int" }} +{{if eq $view_dtype "int" | or (eq $view_dtype "int64") }} {{/* Support legacy numeric views 1-4 */}} {{ if eq $view 1 }} - {{ $view_file = "list" }} + {{ $view_file = "list" }} {{ else if eq $view 3 }} - {{ $view_file = "card" }} + {{ $view_file = "card" }} {{ else if eq $view 4 }} - {{ $view_file = "citation" }} + {{ $view_file = "citation" }} + {{ else if eq $view 5 }} + {{ $view_file = "showcase" }} {{ else }} {{ $view_file = "compact" }} {{ end }} diff --git a/wowchemy/layouts/partials/portfolio_li_card.html b/wowchemy/layouts/partials/portfolio_li_card.html deleted file mode 100644 index b1e12cf8..00000000 --- a/wowchemy/layouts/partials/portfolio_li_card.html +++ /dev/null @@ -1,44 +0,0 @@ -{{ $item := .item }} -{{ $widget := .widget }} -{{ $link := .link }} -{{ $target := .target }} -{{ $has_attachments := partial "functions/has_attachments" $item }} - -{{/* Get summary. */}} -{{ $summary := "" }} -{{ if $item.Params.summary }} - {{ $summary = $item.Params.summary | markdownify | emojify }} -{{ else if .Params.abstract }} - {{ $summary = .Params.abstract | markdownify | emojify | truncate (site.Params.abstract_length | default 135) }} -{{ else if $item.Summary }} - {{ $summary = $item.Summary }} -{{ end }} - -{{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} -{{ $js_tag_classes := delimit (apply (apply $item.Params.tags "replace" "." " " "-") "printf" "js-id-%s" ".") " " }} - -
-
- {{ with $resource }} - {{ $image := .Resize "550x" }} - - {{ $item.Title }} - - {{ end }} -
-

{{ $item.Title | markdownify | emojify }}

- - {{ with $summary }} -
-

{{ . }}

-
- {{ end }} - - {{ if $has_attachments }} - - {{ end }} -
-
-
diff --git a/wowchemy/layouts/partials/portfolio_li_compact.html b/wowchemy/layouts/partials/portfolio_li_compact.html deleted file mode 100644 index 336a38d9..00000000 --- a/wowchemy/layouts/partials/portfolio_li_compact.html +++ /dev/null @@ -1,6 +0,0 @@ -{{ $item := .item }} -{{ $js_tag_classes := delimit (apply (apply $item.Params.tags "replace" "." " " "-") "printf" "js-id-%s" ".") " " }} - -
- {{ partial "li_compact" $item }} -
diff --git a/wowchemy/layouts/partials/portfolio_li_list.html b/wowchemy/layouts/partials/portfolio_li_list.html deleted file mode 100644 index 6671d24c..00000000 --- a/wowchemy/layouts/partials/portfolio_li_list.html +++ /dev/null @@ -1,6 +0,0 @@ -{{ $item := .item }} -{{ $js_tag_classes := delimit (apply (apply $item.Params.tags "replace" "." " " "-") "printf" "js-id-%s" ".") " " }} - -
- {{ partial "li_list" $item }} -
diff --git a/wowchemy/layouts/partials/portfolio_li_showcase.html b/wowchemy/layouts/partials/portfolio_li_showcase.html deleted file mode 100644 index ff654482..00000000 --- a/wowchemy/layouts/partials/portfolio_li_showcase.html +++ /dev/null @@ -1,61 +0,0 @@ -{{ $item := .item }} -{{ $widget := .widget }} - -{{ $do_link := true }} -{{ if $item.Params.external_link | or $item.Content }} - {{ $do_link = true }} -{{ else }} - {{ $do_link = false }} -{{ end }} - -{{ $link := .link }} -{{ $target := .target }} - -{{/* Get summary. */}} -{{ $summary := "" }} -{{ if $item.Params.summary }} - {{ $summary = $item.Params.summary | markdownify | emojify }} -{{ else if .Params.abstract }} - {{ $summary = .Params.abstract | markdownify | emojify }} -{{ else if $item.Summary }} - {{ $summary = $item.Summary }} -{{ end }} - -{{ $order := "" }} -{{ if and ($widget.Params.design.flip_alt_rows | default true) (not (modBool .index 2)) }} - {{ $order = "order-md-2" }} -{{ end }} - -{{ $js_tag_classes := delimit (apply (apply $item.Params.tags "replace" "." " " "-") "printf" "js-id-%s" ".") " " }} - -
-
-
-
- {{- if $do_link}}{{end -}} - {{ $item.Title | markdownify | emojify }} - {{- if $do_link}}{{end -}} -
- - {{ with $summary }} -
- {{ . }} -
- {{ end }} - - - -
-
- {{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} - {{ with $resource }} - {{ $image := .Resize "540x" }} - {{if $do_link}}{{end}} - {{ $item.Title }} - {{if $do_link}}{{end}} - {{end}} -
-
-
diff --git a/wowchemy/layouts/partials/views/card.html b/wowchemy/layouts/partials/views/card.html index 8361d7f6..2aae4503 100644 --- a/wowchemy/layouts/partials/views/card.html +++ b/wowchemy/layouts/partials/views/card.html @@ -3,6 +3,13 @@ {{/* Dynamic view adjusts to content type. */}} {{ $has_attachments := partial "functions/has_attachments" . }} +{{ $link := $item.RelPermalink }} +{{ $target := "" }} +{{ if $item.Params.external_link }} + {{ $link = $item.Params.external_link }} + {{ $target = "target=\"_blank\" rel=\"noopener\"" }} +{{ end }} + {{/* Get summary. */}} {{ $summary := "" }} {{ if $item.Params.summary }} @@ -38,17 +45,17 @@ {{ $anchor := $item.Params.image.focal_point | default "Smart" }} {{ with $resource }} {{ $image := .Fill (printf "808x455 %s" $anchor) }} - +
{{ $item.Title }}
{{end}}
- {{ $item.Title }} + {{ $item.Title }}
{{ with $summary }} - +

{{.}}

diff --git a/wowchemy/layouts/partials/views/masonry.html b/wowchemy/layouts/partials/views/masonry.html new file mode 100644 index 00000000..7e0dadc2 --- /dev/null +++ b/wowchemy/layouts/partials/views/masonry.html @@ -0,0 +1,45 @@ +{{ $item := .item }} +{{ $has_attachments := partial "functions/has_attachments" $item }} + +{{ $link := $item.RelPermalink }} +{{ $target := "" }} +{{ if $item.Params.external_link }} + {{ $link = $item.Params.external_link }} + {{ $target = "target=\"_blank\" rel=\"noopener\"" }} +{{ end }} + +{{/* Get summary. */}} +{{ $summary := "" }} +{{ if $item.Params.summary }} + {{ $summary = $item.Params.summary | markdownify | emojify }} +{{ else if .Params.abstract }} + {{ $summary = .Params.abstract | markdownify | emojify | truncate (site.Params.abstract_length | default 135) }} +{{ else if $item.Summary }} + {{ $summary = $item.Summary }} +{{ end }} + +{{ $resource := ($item.Resources.ByType "image").GetMatch "*featured*" }} + +
+ {{ with $resource }} + {{ $image := .Resize "550x" }} + + {{ $item.Title }} + + {{ end }} +
+

{{ $item.Title | markdownify | emojify }}

+ + {{ with $summary }} +
+

{{ . }}

+
+ {{ end }} + + {{ if $has_attachments }} + + {{ end }} +
+
diff --git a/wowchemy/layouts/partials/widgets/portfolio.html b/wowchemy/layouts/partials/widgets/portfolio.html index 2418659d..60122aff 100644 --- a/wowchemy/layouts/partials/widgets/portfolio.html +++ b/wowchemy/layouts/partials/widgets/portfolio.html @@ -5,6 +5,7 @@ {{ $st := .page }} {{ $items_type := $st.Params.content.page_type | default "project" }} {{ $columns := $st.Params.design.columns | default "2" }} +{{ $view := $st.Params.design.view | default "masonry" }}
@@ -44,7 +45,7 @@ {{ end }} {{ end }} -
+
{{ $query := "" }} {{ if $st.Params.content.filters.tags }} @@ -53,25 +54,16 @@ {{ $query = where site.RegularPages "Type" $items_type }} {{ end }} - {{ range $idx, $item := $query }} + {{ range $index, $item := $query }} + {{ $js_tag_classes := delimit (apply (apply $item.Params.tags "replace" "." " " "-") "printf" "js-id-%s" ".") " " }} + {{ if in (slice "masonry" 3) $view }} +
+ {{else}} +
+ {{end}} + {{ partial "functions/render_view" (dict "page" $st "item" . "view" $view "index" $index) }} +
+ {{end}} - {{ $link := $item.RelPermalink }} - {{ $target := "" }} - {{ if $item.Params.external_link }} - {{ $link = $item.Params.external_link }} - {{ $target = "target=\"_blank\" rel=\"noopener\"" }} - {{ end }} - - {{ if eq $st.Params.design.view 1 }} - {{ partial "portfolio_li_list" (dict "item" $item) }} - {{ else if eq $st.Params.design.view 2 }} - {{ partial "portfolio_li_compact" (dict "item" $item) }} - {{ else if eq $st.Params.design.view 3 }} - {{ partial "portfolio_li_card" (dict "widget" $st "index" $idx "item" $item "link" $link "target" $target) }} - {{ else }} - {{ partial "portfolio_li_showcase" (dict "widget" $st "index" $idx "item" $item "link" $link "target" $target) }} - {{ end }} - - {{ end }}