diff options
author | it-gro <13005925+it-gro@users.noreply.github.com> | 2021-09-05 14:04:42 +0300 |
---|---|---|
committer | it-gro <13005925+it-gro@users.noreply.github.com> | 2021-09-05 14:04:42 +0300 |
commit | c4980b26fb74c07bdcf1fb78827de17a5624cdba (patch) | |
tree | f0cba26b165706b5ff851b78d0f0dc4c42e3528b | |
parent | e9c321e7368be5f5cb7a959583d2a6bb06b66df2 (diff) |
-rw-r--r-- | layouts/shortcodes/res-attach.html | 99 | ||||
-rw-r--r-- | static/css/w3css-basic.css | 7 |
2 files changed, 59 insertions, 47 deletions
diff --git a/layouts/shortcodes/res-attach.html b/layouts/shortcodes/res-attach.html index 5a0c260..f12b91d 100644 --- a/layouts/shortcodes/res-attach.html +++ b/layouts/shortcodes/res-attach.html @@ -4,44 +4,46 @@ {{- $myDefaultCaption := $.Site.Params.resources.defaultAttachCaption | default `%%T` }} -{{- $.Scratch.Set `thePath` `.` }} -{{- $.Scratch.Set `theMatch` `**` }} -{{- $.Scratch.Set `theLabelText` `Attachments` }} -{{- $.Scratch.Set `theLabelIcon` `fas fa-paperclip` }} +{{- $thePath := `.` }} +{{- $theMatch := `**` }} +{{- $theLabelText := `Attachments` }} +{{- $theLabelIcon := `fas fa-paperclip` }} + +{{- $theResPage := "" }} {{- if .IsNamedParams }} - {{- $.Scratch.Set `thePath` (.Get `path`) }} - {{- $.Scratch.Set `theMatch` (.Get `match`) }} - {{- $.Scratch.Set `theLabelText` (.Get `label`) }} - {{- $.Scratch.Set `theLabelIcon` (.Get `icon`) }} + {{- $thePath = .Get `path` }} + {{- $theMatch = .Get `match` }} + {{- $theLabelText = .Get `label` }} + {{- $theLabelIcon = .Get `icon` }} {{- else }} - {{- $myPos := 0}} {{ if gt (len .Params) $myPos }} {{$.Scratch.Set `thePath` (.Get $myPos) }} {{end}} - {{- $myPos := 1}} {{ if gt (len .Params) $myPos }} {{$.Scratch.Set `theMatch` (.Get $myPos) }} {{end}} - {{- $myPos := 2}} {{ if gt (len .Params) $myPos }} {{$.Scratch.Set `theLabelText` (.Get $myPos) }} {{end}} - {{- $myPos := 3}} {{ if gt (len .Params) $myPos }} {{$.Scratch.Set `theLabelIcon` (.Get $myPos) }} {{end}} + {{- $myPos := 0}} {{ if gt (len .Params) $myPos }} {{$thePath = .Get $myPos }} {{end}} + {{- $myPos := 1}} {{ if gt (len .Params) $myPos }} {{$theMatch = .Get $myPos }} {{end}} + {{- $myPos := 2}} {{ if gt (len .Params) $myPos }} {{$theLabelText = .Get $myPos }} {{end}} + {{- $myPos := 3}} {{ if gt (len .Params) $myPos }} {{$theLabelIcon = .Get $myPos }} {{end}} {{- end }} {{- if or $.Site.Params.debug (findRE `\bdebug-shortcode(s|-res-attach)\b` $.Site.Params.traceFlags) }} <br/> -"thePath" : {{- $.Scratch.Get `thePath` }} <br/> -"theMatch" : {{- $.Scratch.Get `theMatch` }} <br/> -"theLabelText" : {{- $.Scratch.Get `theLabelText` }} <br/> -"theLabelIcon" : {{- $.Scratch.Get `theLabelIcon` }} <br/> +"thePath" : {{- $thePath }} <br/> +"theMatch" : {{- $theMatch }} <br/> +"theLabelText" : {{- $theLabelText }} <br/> +"theLabelIcon" : {{- $theLabelIcon }} <br/> {{- end }} -{{- $myResPagePath := $.Scratch.Get `thePath` }} +{{- $myResPagePath := $thePath }} {{- if eq $myResPagePath `.`}} - {{- $.Scratch.Set `theResPage` .Page }} + {{- $theResPage = .Page }} {{- else }} - {{- $.Scratch.Set `theResPage` (.Site.GetPage $myResPagePath ) }} + {{- $theResPage = .Site.GetPage $myResPagePath }} {{- end }} -{{- $myResPage := $.Scratch.Get `theResPage` }} +{{- $myResPage := $theResPage }} -{{- if gt (len ($.Scratch.Get `theLabelIcon`)) 0 }} - {{printf "<span class='%s' aria-hidden='true'></span> " ($.Scratch.Get `theLabelIcon`) | safeHTML }} +{{- if gt (len ($theLabelIcon)) 0 }} + {{printf "<span class='%s' aria-hidden='true'></span> " ($theLabelIcon) | safeHTML }} {{- end }} -{{ default ($.Scratch.Get `theLabelText`) (i18n ($.Scratch.Get `theLabelText`)) }} +{{ default ($theLabelText) (i18n ($theLabelText)) }} <ul class=" " > {{- if $.Site.Params.debug }} {{- range $myResource := ( ($myResPage.Resources.Match "**/*")) }} @@ -51,34 +53,37 @@ {{- if $myResPage }} {{- if $myResPage.Resources }} - {{/*- range $myResource := ( .Page.Resources.Match (printf "%s*" ($.Scratch.Get `theMatch`))) */}} - {{- range $myResource := ( ($myResPage.Resources.Match (printf "%s*" ($.Scratch.Get `theMatch`)) )) }} - {{- $myExt := replaceRE `.*\.` (``) ($myResource.Name) }} - {{- if eq $myExt "pdf" }} {{$.Scratch.Set `icon` `far fa-file-pdf` }} - {{- else if eq $myExt "docx" }} {{$.Scratch.Set `icon` `far fa-file-word` }} - {{- else if eq $myExt "xlsx" }} {{$.Scratch.Set `icon` `far fa-file-excel`}} - {{- else }} {{$.Scratch.Set `icon` `far fa-file` }} - {{- end}} + {{ range $myMatch := split $theMatch ";" }} + {{/*- range $myResource := ( $.Page.Resources.Match (printf "%s*" ($myMatch))) */}} + {{- range $myResource := ( ($myResPage.Resources.Match (printf "%s*" ($myMatch)) )) }} + {{ $icon := "" }} + {{- $myExt := replaceRE `.*\.` (``) ($myResource.Name) }} + {{- if eq $myExt "pdf" }} {{$icon = `far fa-file-pdf` }} + {{- else if eq $myExt "docx" }} {{$icon = `far fa-file-word` }} + {{- else if eq $myExt "xlsx" }} {{$icon = `far fa-file-excel`}} + {{- else }} {{$icon = `far fa-file` }} + {{- end}} - {{- $myLinkText := $myResource.Title }} - {{- $myIcon := (cond (gt (len (default "" $myResource.Params.icon)) 0) ($myResource.Params.icon) ($.Scratch.Get `icon`) ) }} + {{- $myLinkText := $myResource.Title }} + {{- $myIcon := (cond (gt (len (default "" $myResource.Params.icon)) 0) ($myResource.Params.icon) ($icon) ) }} - {{- if or $.Site.Params.debug (findRE `\bdebug-shortcode(s|-res-attach)\b` $.Site.Params.traceFlags) }} - <br/> - "$myResource.Name" : {{ $myResource.Name }} <br/> - "$myResource.Title" : {{ $myResource.Title }} <br/> - "$myResource.ResourceType" : {{ $myResource.ResourceType }} <br/> - "$myResource.Permalink" : {{ $myResource.Permalink }} <br/> - "$myResource.RelPermalink" : {{ $myResource.RelPermalink }} <br/> - "$myLinkText" : {{ $myLinkText }} <br/> - "$myIcon" : {{ $myIcon }} <br/> - {{- end }} + {{- if or $.Site.Params.debug (findRE `\bdebug-shortcode(s|-res-attach)\b` $.Site.Params.traceFlags) }} + <br/> + "$myResource.Name" : {{ $myResource.Name }} <br/> + "$myResource.Title" : {{ $myResource.Title }} <br/> + "$myResource.ResourceType" : {{ $myResource.ResourceType }} <br/> + "$myResource.Permalink" : {{ $myResource.Permalink }} <br/> + "$myResource.RelPermalink" : {{ $myResource.RelPermalink }} <br/> + "$myLinkText" : {{ $myLinkText }} <br/> + "$myIcon" : {{ $myIcon }} <br/> + {{- end }} - <li> - <a href="{{$myResource.RelPermalink}}">{{printf "<span class='%s' aria-hidden='true'></span>" $myIcon | safeHTML }} {{$myLinkText}}</a> - </li> + <li> + <a href="{{$myResource.RelPermalink}}">{{printf "<span class='%s' aria-hidden='true'></span>" $myIcon | safeHTML }} {{$myLinkText}}</a> + </li> - {{- end }} {{/* range */}} + {{- end }} {{/* range $myResource */}} + {{- end }} {{/* range $myMatch */}} {{- end }} {{- end }} diff --git a/static/css/w3css-basic.css b/static/css/w3css-basic.css index 63edc10..ee82b52 100644 --- a/static/css/w3css-basic.css +++ b/static/css/w3css-basic.css @@ -490,6 +490,13 @@ code.chroma { font-weight: bold; } + +/* -------------------------------------------------- */ +/* */ +pre { + line-height: 1; +} + /* -------------------------------------------------- */ /* shortcodes w3-code w3-codespan */ pre.w3-code, span.w3-codespan{ |