Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/it-gro/hugo-theme-w3css-basic.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-gro <13005925+it-gro@users.noreply.github.com>2019-08-05 17:13:28 +0300
committerit-gro <13005925+it-gro@users.noreply.github.com>2019-08-05 17:13:28 +0300
commitf6a063f4ee06f3cb89c0d8a80f9584ce9920a5e3 (patch)
treec29762a80d8abfdcb6aef5d994e817849bf0c075
parentd2b93568e5f08f93170a707b62726878c4f7a4a0 (diff)
wip
-rw-r--r--exampleSite/config.toml1
-rw-r--r--exampleSite/content/pages/hugo-theme-w3css-basic/page-shortcodes/index.md7
-rw-r--r--exampleSite/content/pages/showcase/attach-page-resources/index.md17
-rw-r--r--exampleSite/data/jumbotron/02-jumbotron.yaml2
-rw-r--r--layouts/shortcodes/res-attach.html81
5 files changed, 68 insertions, 40 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index e887b39..49cde82 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -591,6 +591,7 @@ consectetuer adipiscing
# debug-shortcode-liti enable all shortcode liti debugging output
#traceFlags = "html-comment:debug-shortcodes"
#traceFlags = "html-comment:debug-shortcode-res-figure"
+ #traceFlags = "html-comment:debug-shortcode-res-attach"
#traceFlags = "html-comment:debug-shortcode-res-debug"
#traceFlags = "html-comment:debug-partial-resource-image"
traceFlags = "html-comment"
diff --git a/exampleSite/content/pages/hugo-theme-w3css-basic/page-shortcodes/index.md b/exampleSite/content/pages/hugo-theme-w3css-basic/page-shortcodes/index.md
index 0c7d915..dd88926 100644
--- a/exampleSite/content/pages/hugo-theme-w3css-basic/page-shortcodes/index.md
+++ b/exampleSite/content/pages/hugo-theme-w3css-basic/page-shortcodes/index.md
@@ -703,9 +703,10 @@ pre.terminal-out {
Argument | Position -1 | Default | What | Remark
---------|-------------|-------------------|----------------|-------
-match | 0 | ** | glob | only resources of type application
-label | 1 | Attachments | label | piped into i18n
-icon | 2 | fas fa-paperclip | label icon |
+path | 0 | "." | path to resource page |
+match | 1 | ** | glob |
+label | 2 | Attachments | label | piped into i18n
+icon | 3 | fas fa-paperclip | label icon |
### res-figure
diff --git a/exampleSite/content/pages/showcase/attach-page-resources/index.md b/exampleSite/content/pages/showcase/attach-page-resources/index.md
index 6cf78c9..a934ef6 100644
--- a/exampleSite/content/pages/showcase/attach-page-resources/index.md
+++ b/exampleSite/content/pages/showcase/attach-page-resources/index.md
@@ -18,7 +18,7 @@ resources:
---
-Add page resources of type *application* as attachments to a page via the
+Add page resources as attachments to a page via the
`res-attach` shortcode.
<!--more-->
@@ -41,9 +41,10 @@ lacus. Sed diam.
Argument | Position -1 | Default | What | Remark
---------|-------------|-------------------|----------------|-------
-match | 0 | ** | glob | only resources of type application
-label | 1 | Attachments | label | piped into i18n
-icon | 2 | fas fa-paperclip | label icon |
+path | 0 | . | path to resource page |
+match | 1 | ** | glob |
+label | 2 | Attachments | label | piped into i18n
+icon | 3 | fas fa-paperclip | label icon |
# Demo 2
@@ -52,11 +53,11 @@ tristique imperdiet. Donec at pede. Etiam vel neque nec dui dignissim
bibendum. Vivamus id enim.
## Attachments
-{{< res-attach "**/*.pdf" "" "" >}}
+{{< res-attach "." "**/*.pdf" "" "" >}}
*shortcode above*
{{< w3-code >}}
-{{</* res-attach "** /*.pdf" "" "" */>}}
+{{</* res-attach "." "** /*.pdf" "" "" */>}}
{{< /w3-code >}}
# Demo 3
@@ -65,9 +66,9 @@ Aliquam erat volutpat. Nunc eleifend leo vitae magna. In id erat non orci
commodo lobortis. Proin neque massa, cursus ut, gravida ut, lobortis eget,
lacus. Sed diam. Praesent fermentum tempor tellus.
-{{< res-attach "**/*.{doc,xls}*" "See more here" "fas fa-eye" >}}
+{{< res-attach "." "**/*.{doc,xls}*" "See more here" "fas fa-eye" >}}
*shortcode above*
{{< w3-code >}}
-{{</* res-attach "** /*.{doc,xls}*" "See more here" "fas fa-eye" */>}}
+{{</* res-attach "." "** /*.{doc,xls}*" "See more here" "fas fa-eye" */>}}
{{< /w3-code >}}
diff --git a/exampleSite/data/jumbotron/02-jumbotron.yaml b/exampleSite/data/jumbotron/02-jumbotron.yaml
index 80e1127..0ba232c 100644
--- a/exampleSite/data/jumbotron/02-jumbotron.yaml
+++ b/exampleSite/data/jumbotron/02-jumbotron.yaml
@@ -3,6 +3,6 @@ title: W3.CSS Basic Theme
resImg:
icon:
description: |
- * More than **50** predefined color themes
+ * More than **100** predefined color themes
* More than **25** shortcodes
* Support for image processing and attachments
diff --git a/layouts/shortcodes/res-attach.html b/layouts/shortcodes/res-attach.html
index cd8c92e..5a0c260 100644
--- a/layouts/shortcodes/res-attach.html
+++ b/layouts/shortcodes/res-attach.html
@@ -2,59 +2,84 @@
https://gohugo.io/content-management/page-resources/
*/}}
+
{{- $myDefaultCaption := $.Site.Params.resources.defaultAttachCaption | default `%%T` }}
+{{- $.Scratch.Set `thePath` `.` }}
{{- $.Scratch.Set `theMatch` `**` }}
{{- $.Scratch.Set `theLabelText` `Attachments` }}
{{- $.Scratch.Set `theLabelIcon` `fas fa-paperclip` }}
{{- if .IsNamedParams }}
+ {{- $.Scratch.Set `thePath` (.Get `path`) }}
{{- $.Scratch.Set `theMatch` (.Get `match`) }}
{{- $.Scratch.Set `theLabelText` (.Get `label`) }}
{{- $.Scratch.Set `theLabelIcon` (.Get `icon`) }}
{{- else }}
- {{- $myPos := 0}} {{ if gt (len .Params) $myPos }} {{$.Scratch.Set `theMatch` (.Get $myPos) }} {{end}}
- {{- $myPos := 1}} {{ if gt (len .Params) $myPos }} {{$.Scratch.Set `theLabelText` (.Get $myPos) }} {{end}}
- {{- $myPos := 2}} {{ if gt (len .Params) $myPos }} {{$.Scratch.Set `theLabelIcon` (.Get $myPos) }} {{end}}
+ {{- $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}}
{{- 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/>
{{- end }}
+{{- $myResPagePath := $.Scratch.Get `thePath` }}
+{{- if eq $myResPagePath `.`}}
+ {{- $.Scratch.Set `theResPage` .Page }}
+{{- else }}
+ {{- $.Scratch.Set `theResPage` (.Site.GetPage $myResPagePath ) }}
+{{- end }}
+
+{{- $myResPage := $.Scratch.Get `theResPage` }}
+
{{- if gt (len ($.Scratch.Get `theLabelIcon`)) 0 }}
{{printf "<span class='%s' aria-hidden='true'></span>&nbsp;" ($.Scratch.Get `theLabelIcon`) | safeHTML }}
{{- end }}
{{ default ($.Scratch.Get `theLabelText`) (i18n ($.Scratch.Get `theLabelText`)) }}
<ul class=" " >
-{{/*- range $myResource := ( .Page.Resources.Match (printf "%s*" ($.Scratch.Get `theMatch`))) */}}
-{{- range $myResource := ( (.Page.Resources.ByType `application`).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}}
-
- {{- $myLinkText := $myResource.Title }}
- {{- $myIcon := (cond (gt (len (default "" $myResource.Params.icon)) 0) ($myResource.Params.icon) ($.Scratch.Get `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/>
+{{- if $.Site.Params.debug }}
+ {{- range $myResource := ( ($myResPage.Resources.Match "**/*")) }}
+ {{ $myResource.ResourceType }} {{ $myResource.Name }}<br/>
{{- end }}
+{{- end }}
- <li>
- <a href="{{$myResource.RelPermalink}}">{{printf "<span class='%s' aria-hidden='true'></span>" $myIcon | safeHTML }}&nbsp;{{$myLinkText}}</a>
- </li>
+{{- 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}}
+
+ {{- $myLinkText := $myResource.Title }}
+ {{- $myIcon := (cond (gt (len (default "" $myResource.Params.icon)) 0) ($myResource.Params.icon) ($.Scratch.Get `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 }}
+
+ <li>
+ <a href="{{$myResource.RelPermalink}}">{{printf "<span class='%s' aria-hidden='true'></span>" $myIcon | safeHTML }}&nbsp;{{$myLinkText}}</a>
+ </li>
+
+ {{- end }} {{/* range */}}
+ {{- end }}
+{{- end }}
-{{- end }} {{/* range */}}
</ul>