Support for Image Caption via <figcaption>; Customized site.min.css and _default/_markup/render_image.html

This commit is contained in:
constantinos 2023-07-14 17:41:48 +03:00
parent 4c95e82b78
commit 0eb3cb66de
2 changed files with 25 additions and 12 deletions

View file

@ -1,21 +1,23 @@
{{- $text_link := .Text -}} <!-- Layout element for the pattern: ![TEXT](URL) Used for Internal links; BIB references; videos; links to static files -->
{{- $text_link := .Text -}} <!-- variable for the link text -->
{{ $_ := newScratch }} {{ $_ := newScratch }}
{{- range $k, $v := .Page.Site.Data.sandpointsnamegraph -}} {{- range $k, $v := .Page.Site.Data.sandpointsnamegraph -}}
{{ $_.Add "triads" $k }} {{ $_.Add "triads" $k }}
{{- end -}} {{- end -}}
{{- if strings.HasPrefix .Destination "img:" -}} {{- if strings.HasPrefix .Destination "img:" -}} <!--clause for prefix img: -->
{{- $img_params := (substr .Destination 4) -}} {{- $img_params := (substr .Destination 4) -}}
{{- $img_src := index (split $img_params " ") 0 -}} {{- $img_src := index (split $img_params " ") 0 -}}
{{- $img_attr := index (split $img_params $img_src) 1 -}} {{- $img_attr := index (split $img_params $img_src) 1 -}}
<img class="sandpoints-img" src="{{ $img_src }}" {{ $img_attr | safeHTMLAttr }} /> <img class="sandpoints-img" src="{{ $img_src }}" {{ $img_attr | safeHTMLAttr }} />
{{- else if strings.HasPrefix .Destination "vid:" -}} {{- else if strings.HasPrefix .Destination "vid:" -}} <!-- clause for prefix vid: -->
{{- $vid_params := (substr .Destination 4) -}} {{- $vid_params := (substr .Destination 4) -}}
{{- $vid_src := index (split $vid_params " ") 0 -}} {{- $vid_src := index (split $vid_params " ") 0 -}}
{{- $vid_attr := index (split $vid_params $vid_src) 1 -}} {{- $vid_attr := index (split $vid_params $vid_src) 1 -}}
<video class="sandpoints-vid" controls src="{{ $vid_src }}" {{ $vid_attr | safeHTMLAttr }}></video> <video class="sandpoints-vid" controls src="{{ $vid_src }}" {{ $vid_attr | safeHTMLAttr }}></video>
{{- else if strings.HasPrefix .Destination "bib:" -}} {{- else if strings.HasPrefix .Destination "bib:" -}} <!-- clause for prefix bib: -->
{{- $destination := (substr .Destination 4) -}} {{- $destination := (substr .Destination 4) -}}
{{- $c_prefix := .Page.Site.Params.sandpointsCatalogPrefix | default "/library/" -}} {{- $c_prefix := .Page.Site.Params.sandpointsCatalogPrefix | default "/library/" -}}
{{- if index $.Page.Site.Data.books.catalog $destination -}} {{- if index $.Page.Site.Data.books.catalog $destination -}}
@ -26,7 +28,7 @@
{{- $bibtitle = printf "%s" $b.title }} {{- $bibtitle = printf "%s" $b.title }}
{{ end }} {{ end }}
{{ .Page.Scratch.Add "bibs" (slice (slice $bibhref $bibtitle)) }} {{ .Page.Scratch.Add "bibs" (slice (slice $bibhref $bibtitle)) }}
{{- if not $text_link -}} {{- if not $text_link -}} <!-- if no title (in square brackets) then compile bibliographic citation text.-->
<span>{{- delimit $b.authors ", " " & " -}}{{- with $b.pubdate -}},&nbsp;{{- substr . 0 4}}{{- end -}}.&nbsp;<a href="{{- $c_prefix | safeURL -}}BROWSE_LIBRARY.html#/book/{{- $destination -}}"{{- with $b.title}} title="{{- . -}}"{{- end -}} target="_blank"><span class="sup">bib</span><i>{{- $b.title -}}</i></a>.&nbsp;{{- with $b.publisher -}}{{- . -}}.{{- end -}}</span> <span>{{- delimit $b.authors ", " " & " -}}{{- with $b.pubdate -}},&nbsp;{{- substr . 0 4}}{{- end -}}.&nbsp;<a href="{{- $c_prefix | safeURL -}}BROWSE_LIBRARY.html#/book/{{- $destination -}}"{{- with $b.title}} title="{{- . -}}"{{- end -}} target="_blank"><span class="sup">bib</span><i>{{- $b.title -}}</i></a>.&nbsp;{{- with $b.publisher -}}{{- . -}}.{{- end -}}</span>
{{- else -}} {{- else -}}
<span class="sup">bib</span><a href="{{- $c_prefix | safeURL -}}BROWSE_LIBRARY.html#/book/{{- $destination -}}"{{- with $b.title}} title="{{- . -}}"{{- end -}} target="_blank">{{- $text_link -}}</a> <span class="sup">bib</span><a href="{{- $c_prefix | safeURL -}}BROWSE_LIBRARY.html#/book/{{- $destination -}}"{{- with $b.title}} title="{{- . -}}"{{- end -}} target="_blank">{{- $text_link -}}</a>
@ -34,7 +36,7 @@
{{- else -}} {{- else -}}
<a href="{{- $c_prefix | safeURL -}}BROWSE_LIBRARY.html#/book/{{- $destination -}}"{{- with .Title}} title="{{- . -}}"{{- end -}}>{{- $text_link -}}⦚<span>bib:{{- $destination -}} not found</span></a> <a href="{{- $c_prefix | safeURL -}}BROWSE_LIBRARY.html#/book/{{- $destination -}}"{{- with .Title}} title="{{- . -}}"{{- end -}}>{{- $text_link -}}⦚<span>bib:{{- $destination -}} not found</span></a>
{{- end -}} {{- end -}}
{{- else if in ($_.Get "triads") (index (split .Destination ":") 0) -}} {{- else if in ($_.Get "triads") (index (split .Destination ":") 0) -}} <!-- clause for internal reference to some markdown file in /content/ -->
{{- if $.Page.Site.GetPage (printf "/%s" (replace .Destination ":" "/")) -}} {{- if $.Page.Site.GetPage (printf "/%s" (replace .Destination ":" "/")) -}}
{{- $session := $.Page.Site.GetPage (printf "/%s" (replace .Destination ":" "/")) -}} {{- $session := $.Page.Site.GetPage (printf "/%s" (replace .Destination ":" "/")) -}}
{{ .Page.Scratch.Add "links" (slice $session) }} {{ .Page.Scratch.Add "links" (slice $session) }}
@ -46,15 +48,18 @@
{{- else -}} {{- else -}}
<a href="{{- .Destination -}}/{{- if eq hugo.Environment "offline" -}}index.html{{- end -}}">{{- $text_link -}}⦚<span>{{- .Destination -}} not found</span></a> <a href="{{- .Destination -}}/{{- if eq hugo.Environment "offline" -}}index.html{{- end -}}">{{- $text_link -}}⦚<span>{{- .Destination -}} not found</span></a>
{{- end -}} {{- end -}}
{{- else if strings.HasPrefix .Destination "audio:" -}} {{- else if strings.HasPrefix .Destination "audio:" -}} <!-- clause for prefix audio:-->
{{- $a_destination := (substr .Destination 6) -}} {{- $a_destination := (substr .Destination 6) -}}
{{- if findRE "^.*static" $a_destination -}} {{- if findRE "^.*static" $a_destination -}}
<span class="soundcite" data-url="{{- (replaceRE "^.*static" "" $a_destination ) | safeURL -}}">{{ .Text }}</span> <span class="soundcite" data-url="{{- (replaceRE "^.*static" "" $a_destination ) | safeURL -}}">{{ .Text }}</span>
{{- else -}} {{- else -}}
<span class="soundcite" data-url="{{- $a_destination | safeURL -}}">{{ .Text }}</span> <span class="soundcite" data-url="{{- $a_destination | safeURL -}}">{{ .Text }}</span>
{{- end -}} {{- end -}}
{{- else if findRE "^.*static" .Destination -}} {{- else if findRE "^.*static" .Destination -}} <!-- EDITED clause for link to file in /static/ folder -->
<img src="{{- (replaceRE "^.*static" "" .Destination ) | safeURL -}}" alt="{{- .Text -}}" {{- with .Title}} title="{{- . -}}"{{- end -}} /> <img src="{{- (replaceRE "^.*static" "" .Destination ) | safeURL -}}" alt="{{- .Title -}}" {{- with .Title}} title="{{- . -}}"{{- end -}} />
{{- else -}} {{ if .Text }}
<figcaption> {{with .Text }} {{ . }} {{end}}</figcaption> <!-- ALT becomes caption. Title becomes moouse over text.-->
{{ end }}
{{- else -}} <!-- else-->
<img src="{{- .Destination | safeURL -}}" alt="{{- .Text -}}" {{- with .Title}} title="{{- . -}}"{{- end -}} /> <img src="{{- .Destination | safeURL -}}" alt="{{- .Text -}}" {{- with .Title}} title="{{- . -}}"{{- end -}} />
{{- end -}} {{- end -}}

View file

@ -1,4 +1,4 @@
html,body,dl,dt,dd,blockquote,figure,fieldset,legend,textarea,pre,iframe,hr{ html,body,dl,dt,dd,blockquote,figcaption, figure,fieldset,legend,textarea,pre,iframe,hr{
margin:0; margin:0;
padding:0 padding:0
} }
@ -247,6 +247,7 @@ input:focus,select:focus,textarea:focus,label:focus,button:focus{
font-size:1em; font-size:1em;
margin-left:-.37em margin-left:-.37em
} }
footer{ footer{
display:flex; display:flex;
margin-bottom:1rem; margin-bottom:1rem;
@ -464,6 +465,13 @@ blockquote{
code { /*edited by anybody; added background color same as in pre above*/ code { /*edited by anybody; added background color same as in pre above*/
background-color: #fff5f5; background-color: #fff5f5;
} }
figcaption {/*edited by anybody*/
margin-left:1rem;
font-size: 75%;
margin-bottom:1rem;
margin-top: -0.7rem; /*negative top margin so that it's colser to the image*/
}
h2+p:first-letter{ h2+p:first-letter{
font-family:great vibes,cursive; font-family:great vibes,cursive;
color:rgba(0,0,0,.8); color:rgba(0,0,0,.8);