From 7baf433b53342ab55a32e74f3e3241ed5119032f Mon Sep 17 00:00:00 2001 From: Thedro Neely Date: Sat, 5 Jun 2021 23:05:48 -0400 Subject: generators/shortcodes: Footnote and image enhancements Defensive; hash footnote content and mark ids to ensure no conflicts on side-notes and images. Decouple PHP from image short-codes. Add margin images. Ensure consistency between foot-notes, side-notes, and side-images. --- .../hugo/themes/tdro/layouts/shortcodes/image.html | 20 ++++++------- .../tdro/layouts/shortcodes/marginimage.html | 14 +++++++++ .../themes/tdro/layouts/shortcodes/marginnote.html | 12 ++++---- .../themes/tdro/layouts/shortcodes/sideimage.html | 33 ++++++++-------------- .../themes/tdro/layouts/shortcodes/sidenote.html | 12 ++++---- public/css/tdro.css | 7 +++-- 6 files changed, 54 insertions(+), 44 deletions(-) create mode 100644 generators/hugo/themes/tdro/layouts/shortcodes/marginimage.html diff --git a/generators/hugo/themes/tdro/layouts/shortcodes/image.html b/generators/hugo/themes/tdro/layouts/shortcodes/image.html index a49ed94..afebef4 100644 --- a/generators/hugo/themes/tdro/layouts/shortcodes/image.html +++ b/generators/hugo/themes/tdro/layouts/shortcodes/image.html @@ -1,15 +1,15 @@ -{{ safeHTML " 100) ? $height . 'px' : $height / $width * 100 . '%'; -{{ safeHTML "?>" }} +{{ $imageFile := print "public" (.Get `source`) }} +{{ $image := imageConfig $imageFile }} + +{{ $ratio := 0 }} +{{ if lt (mul (div (float $image.Height) $image.Width) 100) 100 }} +{{ $ratio = mul (div (float $image.Height) $image.Width) 100 }} +{{ end }}
- -
` }}> - {{.Get `title`}}` }} - {{ safeHTMLAttr `` }} /> + +
+ {{ .Get `title` }}
{{ .Inner }}
diff --git a/generators/hugo/themes/tdro/layouts/shortcodes/marginimage.html b/generators/hugo/themes/tdro/layouts/shortcodes/marginimage.html new file mode 100644 index 0000000..b880adb --- /dev/null +++ b/generators/hugo/themes/tdro/layouts/shortcodes/marginimage.html @@ -0,0 +1,14 @@ +{{ $id := md5 (printf (.Get `mark`) .Inner) }} +{{ $imageFile := print "public" (.Get `source`) }} +{{ $image := imageConfig $imageFile }} + + + + + + + {{ .Inner }} + + {{ .Inner }} + + diff --git a/generators/hugo/themes/tdro/layouts/shortcodes/marginnote.html b/generators/hugo/themes/tdro/layouts/shortcodes/marginnote.html index 12f74be..7718cb3 100644 --- a/generators/hugo/themes/tdro/layouts/shortcodes/marginnote.html +++ b/generators/hugo/themes/tdro/layouts/shortcodes/marginnote.html @@ -1,7 +1,9 @@ +{{ $id := md5 (printf (.Get `mark`) .Inner) }} + - - - -{{ .Inner }} - + + + + {{ .Inner }} + diff --git a/generators/hugo/themes/tdro/layouts/shortcodes/sideimage.html b/generators/hugo/themes/tdro/layouts/shortcodes/sideimage.html index 39e22a4..3e4966c 100644 --- a/generators/hugo/themes/tdro/layouts/shortcodes/sideimage.html +++ b/generators/hugo/themes/tdro/layouts/shortcodes/sideimage.html @@ -1,23 +1,14 @@ - - - - - - - -{{ safeHTML " 100) ? $height . 'px' : $height / $width * 100 . '%'; -{{ safeHTML "?>" }} - - - {{ .Inner }}` }} - {{ safeHTMLAttr `` }} /> - - - {{ .Inner }} - +{{ $id := md5 (printf (.Get `mark`) .Inner) }} +{{ $imageFile := print "public" (.Get `source`) }} +{{ $image := imageConfig $imageFile }} + + + + + + {{ .Inner }} + + {{ .Inner }} + diff --git a/generators/hugo/themes/tdro/layouts/shortcodes/sidenote.html b/generators/hugo/themes/tdro/layouts/shortcodes/sidenote.html index 40d602a..f4c994c 100644 --- a/generators/hugo/themes/tdro/layouts/shortcodes/sidenote.html +++ b/generators/hugo/themes/tdro/layouts/shortcodes/sidenote.html @@ -1,7 +1,9 @@ +{{ $id := md5 (printf (.Get `mark`) .Inner) }} + - - - -{{ .Inner }} - + + + + {{ .Inner }} + diff --git a/public/css/tdro.css b/public/css/tdro.css index 84f3f09..842814c 100644 --- a/public/css/tdro.css +++ b/public/css/tdro.css @@ -4168,9 +4168,10 @@ input.sidenote-toggle, input.marginnote-toggle { display: none; } mark { background-color: transparent; color: unset; } .sidenote-container:hover .sidenote-mark span, -.sidenote-container:hover .sidenote mark { background-color: #fefe98; color: #000; } -.sidenote-container:hover .sidenote a { background-color: #fefe98; color: #000; border-color: dodgerblue; } - +.sidenote-container:hover .sidenote mark, +.marginnote-container:hover .marginnote-mark span, +.marginnote-container:hover .marginnote mark { background-color: #fefe98; color: #000; } +.sidenote-container:hover .sidenote a, .marginnote-container:hover .marginnote a { background-color: #fefe98; color: #000; border-color: dodgerblue; } .sideimage > a, .sideimage a:focus { border-bottom: 1px solid transparent !important; background-color: transparent !important; } @media (max-width: 768px) { -- cgit v1.2.3