From 4969191708ff73bbcc8934ba344cdd8aba3a435d Mon Sep 17 00:00:00 2001 From: Chris Hodapp Date: Fri, 24 Apr 2020 23:52:27 -0400 Subject: [PATCH] Reworked figure shortcode to use Page Resources --- .gitignore | 3 ++ .lfsconfig | 2 ++ content/works/front.md | 51 +++++++++++++++++++++------------- layouts/shortcodes/figure.html | 46 +++++++++++++++++++++++++----- 4 files changed, 76 insertions(+), 26 deletions(-) create mode 100644 .lfsconfig diff --git a/.gitignore b/.gitignore index 48937cf..c0ed5bb 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ Temporary Items # End of https://www.gitignore.io/api/macos *~ + +# Local Netlify folder +.netlify \ No newline at end of file diff --git a/.lfsconfig b/.lfsconfig new file mode 100644 index 0000000..ca44ae7 --- /dev/null +++ b/.lfsconfig @@ -0,0 +1,2 @@ +[lfs] + url = https://5f7bd828-f7e2-4481-83c3-178851380a2b.netlify.app/.netlify/large-media diff --git a/content/works/front.md b/content/works/front.md index 2a7648a..f17c093 100644 --- a/content/works/front.md +++ b/content/works/front.md @@ -6,24 +6,37 @@ tags: {{< load-photoswipe >}} + + {{< gallery >}} - {{< figure src="/works/ramhorn-0004.jpg" title="Ram's Horn (September 15, 2019)" link="2019-09-15-rams-horns.md" >}} - {{< figure src="/works/2011-11-04-crystal1.png" title="Crystal #1 (November 4, 2011)" link="2011-11-04-crystal1.md" >}} - {{< figure src="/works/2011-09-09-conch.jpg" title="Conch (September 9, 2011)" link="2011-09-11-conch.md" >}} - {{< figure src="/works/2005-08-23-shear6.jpg" title="Shear #6 (August 23, 2005)" link="2005-08-23-shear6.md" >}} - {{< figure src="/works/2005-08-19-beach.jpg" title="Beach (August 19, 2005)" link="2005-08-19-beach.md" >}} - {{< figure src="/works/2005-08-06-tears.jpg" title="Tears (August 6, 2005)" link="2005-08-06-tears.md" >}} - {{< figure src="/works/2005-08-05-oasis.jpg" title="Oasis (August 5, 2005)" link="2005-08-05-oasis.md" >}} - {{< figure src="/works/2005-07-08-vaguely-celtic-metalwork.jpg" title="Vaguely Celtic Metalwork (July 8, 2005)" link="2005-07-08-vaguely-celtic-metalwork.md" >}} - {{< figure src="/works/2005-07-05-spiral-isosurface2.jpg" title="Spiral Isosurface (July 5, 2005)" link="2005-07-05-spiral.md" >}} - {{< figure src="/works/2005-06-09-superellipsoids.jpg" title="Superellipsoids (June 9, 2005)" link="2005-06-09-superellipsoids.md" >}} - {{< figure src="/works/2005-05-11-unknown-planet.jpg" title="Unknown Planet (May 11, 2005)" link="2005-05-11-unknown-planet.md" >}} - {{< figure src="/works/2005-05-10-haze.png" title="Haze 3 (May 10, 2005)" link="2005-05-10-haze.md" >}} - {{< figure src="/works/2004-12-23-butterfly.jpg" title="Butterfly (December 23, 2004)" link="2004-12-23-butterfly.md" >}} - {{< figure src="/works/2004-09-28-m4c-intro.png" title="M4C intro (September 28, 2004)" link="2004-09-28-m4c-intro.md" >}} - {{< figure src="/works/2004-09-19-roses.png" title="Roses (September 19, 2004)" link="2004-09-19-roses.md" >}} - {{< figure src="/works/2004-07-16-crunchy-bubbles.jpg" title="Crunchy Bubbles (July 16, 2004)" link="2004-07-16-crunchy-bubbles.md" >}} - {{< figure src="/works/2004-07-15-kpovmodeler-test.jpg" title="KPovModeler test (?) (July 15, 2004)" link="2004-07-15-kpovmodeler.md" >}} - {{< figure src="/works/1999-12-22-table.png" title="'Table' or something (Dec 22, 1999)" link="1999-12-22-table-polyray.md" >}} - {{< figure src="/works/1999-12-21-moo.png" caption="*Foo* [link](./link)" title="Moo (Dec 21, 1999)" link="../1999-12-21-moo-polyray/" class="no-photoswipe">}} + {{< figure resource="placeholder/screw0006.jpg" title="Screw (April 12, 2020)" >}} + {{< figure resource="placeholder/cinquefoil0010.png" title="Cinquefoil (November 16, 2019)" caption="Foo">}} + {{< figure resource="placeholder/dream20191115b_1000.png" title="Dream (November 15, 2019)" >}} + {{< figure resource="placeholder/ramhorn_branch_0002.png" title="ramhorn_branch? (December 16, 2019)" >}} + {{< figure resource="portfolio/ramhorn-0004.jpg" title="Ram's Horn (September 15, 2019)" link2="../2019-09-15-rams-horns.md" >}} + {{< figure resource="placeholder/iso_draft_0017.png" title="Isosurface try 2 (August 24, 2019)" >}} + {{< figure resource="placeholder/appleseed_spiral_thing_thumb.jpg" title="Appleseed spiral thing (August 20, 2018)" >}} + {{< figure resource="placeholder/appleseed_spiral_thing2_thumb.jpg" title="Appleseed spiral thing 2 (June 25, 2018)" >}} + {{< figure resource="placeholder/2011-11-25-electron.png" title="Electron (November 25, 2011)" >}} + {{< figure resource="portfolio/2011-11-04-crystal1.png" title="Crystal #1 (November 4, 2011)" link2="../2011-11-04-crystal1.md" >}} + {{< figure resource="placeholder/2011-11-03-feather2-thumb.jpg" title="Feather #2 (November 3, 2011)" >}} + {{< figure resource="placeholder/2011-11-03-feather1-thumb.jpg" title="Feather #1 (November 3, 2011)" >}} + {{< figure resource="portfolio/2011-09-09-conch.jpg" title="Conch (September 9, 2011)" link2="../2011-09-11-conch.md" >}} + {{< figure resource="placeholder/2011-09-09-flow1-thumb.jpg" title="Flow? (September 9, 2011)" >}} + {{< figure resource="portfolio/2005-08-23-shear6.jpg" title="Shear #6 (August 23, 2005)" link2="../2005-08-23-shear6.md" >}} + {{< figure resource="portfolio/2005-08-19-beach.jpg" title="Beach (August 19, 2005)" link2="../2005-08-19-beach.md" >}} + {{< figure resource="portfolio/2005-08-06-tears.jpg" title="Tears (August 6, 2005)" link2="../2005-08-06-tears.md" >}} + {{< figure resource="portfolio/2005-08-05-oasis.jpg" title="Oasis (August 5, 2005)" link2="../2005-08-05-oasis.md" >}} + {{< figure resource="portfolio/2005-07-08-vaguely-celtic-metalwork.jpg" title="Vaguely Celtic Metalwork (July 8, 2005)" link2="../2005-07-08-vaguely-celtic-metalwork.md" >}} + {{< figure resource="portfolio/2005-07-05-spiral-isosurface2.jpg" title="Spiral Isosurface (July 5, 2005)" link2="../2005-07-05-spiral.md" >}} + {{< figure resource="portfolio/2005-06-09-superellipsoids.jpg" title="Superellipsoids (June 9, 2005)" link2="../2005-06-09-superellipsoids.md" >}} + {{< figure resource="portfolio/2005-05-11-unknown-planet.jpg" title="Unknown Planet (May 11, 2005)" link2="../2005-05-11-unknown-planet.md" >}} + {{< figure resource="portfolio/2005-05-10-haze.png" title="Haze 3 (May 10, 2005)" link2="../2005-05-10-haze.md" >}} + {{< figure resource="portfolio/2004-12-23-butterfly.jpg" title="Butterfly (December 23, 2004)" link2="../2004-12-23-butterfly.md" >}} + {{< figure resource="portfolio/2004-09-28-m4c-intro.png" title="M4C intro (September 28, 2004)" link2="../2004-09-28-m4c-intro.md" >}} + {{< figure resource="portfolio/2004-09-19-roses.png" title="Roses (September 19, 2004)" link2="../2004-09-19-roses.md" >}} + {{< figure resource="portfolio/2004-07-16-crunchy-bubbles.jpg" title="Crunchy Bubbles (July 16, 2004)" link2="../2004-07-16-crunchy-bubbles.md" >}} + {{< figure resource="portfolio/2004-07-15-kpovmodeler-test.jpg" title="KPovModeler test (?) (July 15, 2004)" link2="../2004-07-15-kpovmodeler.md" >}} + {{< figure resource="portfolio/1999-12-22-table.png" title="'Table' or something (Dec 22, 1999)" link2="../1999-12-22-table-polyray.md" >}} + {{< figure resource="portfolio/1999-12-21-moo.png" caption="*Foo* [link](./link)" title="Moo (Dec 21, 1999)" caption="*Foo* [link](./link)" link2="../1999-12-21-moo-polyray/">}} {{< /gallery >}} diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html index 38924da..7e6bac3 100644 --- a/layouts/shortcodes/figure.html +++ b/layouts/shortcodes/figure.html @@ -2,22 +2,54 @@ Put this file in /layouts/shortcodes/figure.html NB this overrides Hugo's built-in "figure" shortcode but is backwards compatible Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/ ---> + --> + {{- if not ($.Page.Scratch.Get "figurecount") }}{{ end }} {{- $.Page.Scratch.Add "figurecount" 1 -}} - -{{- $thumb := .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }} + + + +{{ $pagename := "images" }} + +{{ $resize_opts := "600x jpg" }} + + + + +{{ $thumb := "" }} +{{ $href := "" }} +{{ if .Get "resource" }} + {{ $page := $.Site.GetPage $pagename }} + {{- if eq $page nil -}} + {{- errorf "Error: Can't find page %s" $pagename -}} + {{- end -}} + {{ $resource := (.Get "resource") }} + {{ $original := $page.Resources.GetMatch (printf "*%s*" $resource) }} + {{- if eq $original nil -}} + {{- errorf "Error: Can't find resource %s on page %s" $resource $pagename -}} + {{- end -}} + {{ .Scratch.Set "image" ($original.Resize $resize_opts) }} + {{ $image := .Scratch.Get "image" }} + {{- $thumb = $image.RelPermalink }} + {{- $href = $original.RelPermalink }} +{{ else }} + + {{- $thumb = .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }} + {{- $href = .Get "link" | default (.Get "src") }} +{{ end }} +
- +
- {{ with .Get "link" | default (.Get "src") }}{{ end }} - {{- if or (or (.Get "title") (.Get "caption")) (.Get "attr")}} + + + {{- if or (or (.Get "title") (.Get "caption" | markdownify)) (.Get "attr")}}
{{- with .Get "title" }}

{{.}}

{{ end }} - {{- if or (.Get "caption") (.Get "attr")}} + {{- if or (.Get "caption" | markdownify) (.Get "attr")}}

{{- .Get "caption" -}} {{- with .Get "attrlink"}}{{ .Get "attr" }}{{ else }}{{ .Get "attr"}}{{ end -}}