mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
shortcodes: convert to partials feature #277
This commit is contained in:
parent
46d2e17ec0
commit
e62381572a
21 changed files with 390 additions and 293 deletions
50
layouts/partials/shortcodes/attachments.html
Normal file
50
layouts/partials/shortcodes/attachments.html
Normal file
|
@ -0,0 +1,50 @@
|
|||
{{- $context := .context }}
|
||||
{{- $content := .content }}
|
||||
{{- $style := .style | default "transparent" }}
|
||||
{{- $title := .title | default ($style | T) | default ("Attachments-label" | T) }}
|
||||
{{- $icon := .icon | default "" }}
|
||||
{{- if and (not $icon) (eq (len $icon) 0) }}
|
||||
{{- $icon = "paperclip" }}
|
||||
{{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }}
|
||||
{{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }}
|
||||
{{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }}
|
||||
{{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }}
|
||||
{{- end }}
|
||||
{{- $icon = trim $icon " " }}
|
||||
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
|
||||
{{- $icon = printf "fa-fw fas fa-%s" $icon }}
|
||||
{{- end }}
|
||||
{{- $sort := .sort | default "asc" }}
|
||||
{{- $pattern := .pattern | default "" }}
|
||||
{{- with $context }}
|
||||
<div class="box attachments cstyle {{ $style }}">
|
||||
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i> {{ end }}{{ $title }}</div>
|
||||
<ul class="box-content attachments-files">
|
||||
{{- $filesName := "files" }}
|
||||
{{- if ne .Page.File.BaseFileName "index" }}
|
||||
{{- $filesName = printf "%s.files" .Page.File.BaseFileName }}
|
||||
{{- end }}
|
||||
{{- $fileLink := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
|
||||
{{- $fileLink = replace (replace $fileLink "\\" "/") "content/" "" }}
|
||||
{{- $fileDir := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
|
||||
{{- $fileDir = replace $fileDir "\\" "/" }}
|
||||
{{- range sort (readDir (printf "%s%s" $fileDir $filesName) ) "Name" $sort }}
|
||||
{{- if findRE $pattern .Name}}
|
||||
{{- $size := .Size }}
|
||||
{{- $unit := "Byte-symbol" }}
|
||||
{{- if ge $size 1024 }}
|
||||
{{- $size = div $size 1024 }}
|
||||
{{- $unit = "Kilobyte-symbol" }}
|
||||
{{- end }}
|
||||
{{- if ge $size 1024 }}
|
||||
{{- $size = div $size 1024 }}
|
||||
{{- $unit = "Megabyte-symbol" }}
|
||||
{{- end }}
|
||||
{{- $unitsymbol := $unit | T }}
|
||||
<li><a href="{{ (printf "%s%s/%s" $fileLink $filesName .Name) | relURL }}">{{.Name}}</a> ({{$size}} {{$unitsymbol}})</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</ul>
|
||||
{{- $content }}
|
||||
</div>
|
||||
{{- end }}
|
30
layouts/partials/shortcodes/button.html
Normal file
30
layouts/partials/shortcodes/button.html
Normal file
|
@ -0,0 +1,30 @@
|
|||
{{- $context := .context }}
|
||||
{{- $content := .content }}
|
||||
{{- $href := .href }}
|
||||
{{- $style := .style | default "transparent" }}
|
||||
{{- $title := .title | default ($content) | default ($style | T) }}
|
||||
{{- $icon := .icon | default "" }}
|
||||
{{- if and (not $icon) (eq (len $icon) 0) }}
|
||||
{{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }}
|
||||
{{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }}
|
||||
{{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }}
|
||||
{{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }}
|
||||
{{- end }}
|
||||
{{- $icon = trim $icon " " }}
|
||||
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
|
||||
{{- $icon = printf "fa-fw fas fa-%s" $icon }}
|
||||
{{- end }}
|
||||
{{- $iconposition := .iconposition | default "left" }}
|
||||
{{- with $context }}
|
||||
<span class="btn cstyle {{ $style }}">
|
||||
<a href="{{ $href }}" target="_blank">
|
||||
{{- if and $icon (eq $iconposition "left") }}
|
||||
<i class="{{ $icon }}"></i>
|
||||
{{- end }}
|
||||
{{ $title }}
|
||||
{{- if and $icon (eq $iconposition "right") }}
|
||||
<i class="{{ $icon }}"></i>
|
||||
{{- end }}
|
||||
</a>
|
||||
</span>
|
||||
{{- end }}
|
107
layouts/partials/shortcodes/children.html
Normal file
107
layouts/partials/shortcodes/children.html
Normal file
|
@ -0,0 +1,107 @@
|
|||
{{- $context := .context }}
|
||||
{{- $showhidden := .showhidden | default false }}
|
||||
{{- if eq (printf "%T" $showhidden) "string" }}
|
||||
{{- $showhidden = (eq $showhidden "true") }}
|
||||
{{- end }}
|
||||
{{- $style := .style | default "li" }}
|
||||
{{- $depth := .depth | default 1 }}
|
||||
{{- $withDescription := .description | default false }}
|
||||
{{- if eq (printf "%T" $withDescription) "string" }}
|
||||
{{- $withDescription = (eq $withDescription "true") }}
|
||||
{{- end }}
|
||||
{{- $sortTerm := .sort | lower }}
|
||||
{{- $containerstyle := .containerstyle | default "ul" }}
|
||||
{{- if( and (not (eq $style "li") ) (eq $containerstyle "ul" ) ) }}
|
||||
{{- $containerstyle = "div" }}
|
||||
{{- end }}
|
||||
|
||||
{{- with $context }}
|
||||
{{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }}
|
||||
{{- $pages := .Page.Pages }}
|
||||
{{- if .Page.IsHome }}
|
||||
{{- $pages = .Page.Sections }}
|
||||
{{- else if .Page.Sections}}
|
||||
{{- $pages = (.Page.Pages | union .Page.Sections) }}
|
||||
{{- end }}
|
||||
|
||||
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
||||
{{- $currentOrdersectionsby := $sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
||||
{{- if eq $currentOrdersectionsby "weight" }}
|
||||
{{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- else if or (eq $currentOrdersectionsby "name") (eq $currentOrdersectionsby "title") }}
|
||||
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- else if eq $currentOrdersectionsby "publishdate" }}
|
||||
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- else if eq $currentOrdersectionsby "date" }}
|
||||
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- else if eq $currentOrdersectionsby "length" }}
|
||||
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- else }}
|
||||
{{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- end }}
|
||||
{{ (printf "</%s>" $containerstyle)|safeHTML }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "childs" }}
|
||||
{{- range .menu }}
|
||||
{{- $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
|
||||
{{- if not $hidden }}
|
||||
{{- if not .IsHome }}
|
||||
{{- if hasPrefix $.style "h" }}
|
||||
{{- $num := sub ( int (trim $.style "h") ) 1 }}
|
||||
{{- $numn := add $num $.count }}
|
||||
|
||||
{{ (printf "<h%d>" $numn)|safeHTML -}}
|
||||
<a href="{{ .RelPermalink }}" >{{ .Title }}</a>
|
||||
{{- (printf "</h%d>" $numn)|safeHTML }}
|
||||
|
||||
{{- else }}
|
||||
{{ (printf "<%s>" $.style)|safeHTML -}}
|
||||
<a href="{{ .RelPermalink }}" >{{ .Title }}</a>
|
||||
{{- (printf "</%s>" $.style)|safeHTML }}
|
||||
{{- end }}
|
||||
|
||||
{{- if $.description }}
|
||||
{{- if .Description }}
|
||||
<p>{{ .Description }}</p>
|
||||
{{else}}
|
||||
<p>{{ .Summary }}</p>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if lt $.count $.depth }}
|
||||
|
||||
{{- if eq $.style "li" }}
|
||||
{{- (printf "<%s>" $.containerstyle)|safeHTML }}
|
||||
{{- end }}
|
||||
|
||||
{{- $pages := .Page.Pages }}
|
||||
{{- if .Page.IsHome }}
|
||||
{{- $pages = .Page.Sections }}
|
||||
{{- else if .Page.Sections}}
|
||||
{{- $pages = (.Page.Pages | union .Page.Sections) }}
|
||||
{{- end }}
|
||||
|
||||
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
||||
{{- $currentOrdersectionsby := $.sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
||||
{{- if eq $currentOrdersectionsby "weight" }}
|
||||
{{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- else if or (eq $.currentOrdersectionsby "name") (eq $.currentOrdersectionsby "title") }}
|
||||
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- else if eq $.currentOrdersectionsby "publishdate" }}
|
||||
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- else if eq $.currentOrdersectionsby "date" }}
|
||||
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- else if eq $.currentOrdersectionsby "length" }}
|
||||
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- else }}
|
||||
{{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- end }}
|
||||
|
||||
{{- if eq $.style "li" }}
|
||||
{{- (printf "</%s>" $.containerstyle)|safeHTML }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
24
layouts/partials/shortcodes/expand.html
Normal file
24
layouts/partials/shortcodes/expand.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{{- $context := .context }}
|
||||
{{- $content := .content }}
|
||||
{{- $title := .title | default (T "Expand-title") }}
|
||||
{{- $expanded := .open | default false }}
|
||||
{{- if eq (printf "%T" $expanded) "string" }}
|
||||
{{- $expanded = (eq $expanded "true") }}
|
||||
{{- end }}
|
||||
{{- with $context }}
|
||||
<div class="expand
|
||||
{{- if $expanded }} expand-expanded{{ end -}}
|
||||
">
|
||||
{{/* things are getting complicated when search tries to open the expand box while jquery sets the display CSS on the element */}}{{ "" -}}
|
||||
<a class="expand-label" onclick="$t=$(this); if($t.parent('.expand-expanded.expand-marked').length){ $t.next().css('display','none') }else if($t.parent('.expand-marked').length){ $t.next().css('display','block') }else{ $t.next('.expand-content').slideToggle(100); } $t.parent().toggleClass('expand-expanded');">
|
||||
<i class="fas fa-chevron-down"></i>
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
{{ $title }}
|
||||
</a>
|
||||
<div class="expand-content" style="display:
|
||||
{{- if $expanded }} block{{ else }} none{{ end -}}
|
||||
;">
|
||||
{{ $content | safeHTML }}
|
||||
</div>
|
||||
</div>
|
||||
{{- end }}
|
13
layouts/partials/shortcodes/include.html
Normal file
13
layouts/partials/shortcodes/include.html
Normal file
|
@ -0,0 +1,13 @@
|
|||
{{- $context := .context }}
|
||||
{{- $file := .file }}
|
||||
{{- $showFirstHeading := .showfirstheading | default true }}
|
||||
{{- if eq (printf "%T" $showFirstHeading) "string" }}
|
||||
{{- $showFirstHeading = (eq $showFirstHeading "true") }}
|
||||
{{- end }}
|
||||
{{- if not $showFirstHeading }}<div class="include hide-first-heading">{{ end }}
|
||||
{{- with $context }}
|
||||
|
||||
{{ $file | readFile | safeHTML }}
|
||||
|
||||
{{- if not $showFirstHeading }}</div>{{ end }}
|
||||
{{- end }}
|
9
layouts/partials/shortcodes/mermaid.html
Normal file
9
layouts/partials/shortcodes/mermaid.html
Normal file
|
@ -0,0 +1,9 @@
|
|||
{{- $context := .context }}
|
||||
{{- $content := .content }}
|
||||
{{- $align := .align | default "center" }}
|
||||
{{- with $context }}
|
||||
<div class="mermaid" align="{{ $align }}">
|
||||
{{- safeHTML $content -}}
|
||||
</div>
|
||||
{{- .Page.Store.Set "htmlHasMermaid" true }}
|
||||
{{- end }}
|
22
layouts/partials/shortcodes/notice.html
Normal file
22
layouts/partials/shortcodes/notice.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
{{- $context := .context }}
|
||||
{{- $content := .content }}
|
||||
{{- $style := .style | default "default" }}
|
||||
{{- $title := .title | default ($style | T) }}
|
||||
{{- $icon := .icon | default "" }}
|
||||
{{- if and (not $icon) (eq (len $icon) 0) }}
|
||||
{{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }}
|
||||
{{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }}
|
||||
{{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }}
|
||||
{{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }}
|
||||
{{- end }}
|
||||
{{- $icon = trim $icon " " }}
|
||||
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
|
||||
{{- $icon = printf "fa-fw fas fa-%s" $icon }}
|
||||
{{- end }}
|
||||
{{- with $context }}
|
||||
<div class="box notices cstyle {{ $style }}">
|
||||
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i> {{ end }}{{ $title }}</div>
|
||||
<div class="box-content">
|
||||
{{ $content | safeHTML }} </div>
|
||||
</div>
|
||||
{{- end }}
|
10
layouts/partials/shortcodes/siteparam.html
Normal file
10
layouts/partials/shortcodes/siteparam.html
Normal file
|
@ -0,0 +1,10 @@
|
|||
{{- $context := .context }}
|
||||
{{- $paramName := .name }}
|
||||
{{- with $context }}
|
||||
{{- $siteParams := .Site.Params }}
|
||||
{{- with $paramName }}
|
||||
{{- with $siteParams }}
|
||||
{{- index . (lower $paramName) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
28
layouts/partials/shortcodes/swagger.html
Normal file
28
layouts/partials/shortcodes/swagger.html
Normal file
|
@ -0,0 +1,28 @@
|
|||
{{- $context := .context }}
|
||||
{{- $src := .src }}
|
||||
{{- with $context }}
|
||||
{{- with .Page.Resources.Match $src }}
|
||||
{{- range . }}
|
||||
{{- $src = .RelPermalink }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
<style>
|
||||
rapi-doc::part(section-endpoint-head-method) {
|
||||
font-size: 11px;
|
||||
}
|
||||
</style>
|
||||
<rapi-doc
|
||||
allow-spec-file-download="true"
|
||||
default-schema-tab="example"
|
||||
font-size="largest"
|
||||
layout="column"
|
||||
load-fonts="false"
|
||||
render-style="view"
|
||||
schema-description-expanded="true"
|
||||
schema-style="table"
|
||||
show-header="false"
|
||||
spec-url="{{ $src }}"
|
||||
sort-tags="true"
|
||||
></rapi-doc>
|
||||
{{- .Page.Store.Set "htmlHasSwagger" true }}
|
||||
{{- end }}
|
24
layouts/partials/shortcodes/tabs.html
Normal file
24
layouts/partials/shortcodes/tabs.html
Normal file
|
@ -0,0 +1,24 @@
|
|||
{{- $context := .context }}
|
||||
{{- $tabs := .tabs | default slice }}
|
||||
{{- $groupId := .groupId | default "default" }}
|
||||
{{- with $context }}
|
||||
<div class="tab-panel">
|
||||
<div class="tab-nav">
|
||||
{{- range $idx, $tab := $tabs }}
|
||||
<button
|
||||
data-tab-item="{{ .name }}"
|
||||
data-tab-group="{{ $groupId }}"
|
||||
class="tab-nav-button {{ cond (eq $idx 0) "active" ""}}"
|
||||
onclick="switchTab('{{ $groupId }}','{{ .name }}')"
|
||||
><span>{{ .name }}</span></button>
|
||||
{{- end }}
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
{{- range $idx, $tab := $tabs }}
|
||||
<div data-tab-item="{{ .name }}" data-tab-group="{{ $groupId }}" class="tab-item {{ cond (eq $idx 0) "active" ""}}">
|
||||
{{ .content | safeHTML }}
|
||||
</div>
|
||||
{{- end }}
|
||||
</div>
|
||||
</div>
|
||||
{{- end }}
|
|
@ -1,47 +1,10 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- $style := .Get "style" | default "transparent" }}
|
||||
{{- $title := .Get "title" | default ($style | T) | default ("Attachments-label" | T) }}
|
||||
{{- $icon := .Get "icon" | default "" }}
|
||||
{{- if and (not $icon) (eq (len $icon) 0) }}
|
||||
{{- $icon = "paperclip" }}
|
||||
{{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }}
|
||||
{{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }}
|
||||
{{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }}
|
||||
{{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }}
|
||||
{{- end }}
|
||||
{{- $icon = trim $icon " " }}
|
||||
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
|
||||
{{- $icon = printf "fa-fw fas fa-%s" $icon }}
|
||||
{{- end }}
|
||||
{{- $sort := .Get "sort" | default "asc" }}
|
||||
{{- $pattern := .Get "pattern" | default "" }}
|
||||
<div class="box attachments cstyle {{ $style }}">
|
||||
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i> {{ end }}{{ $title }}</div>
|
||||
<ul class="box-content attachments-files">
|
||||
{{- $filesName := "files" }}
|
||||
{{- if ne .Page.File.BaseFileName "index" }}
|
||||
{{- $filesName = printf "%s.files" .Page.File.BaseFileName }}
|
||||
{{- end }}
|
||||
{{- $fileLink := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
|
||||
{{- $fileLink = replace (replace $fileLink "\\" "/") "content/" "" }}
|
||||
{{- $fileDir := printf "%s/%s" (.Page.Language.ContentDir | default "content") .Page.File.Dir }}
|
||||
{{- $fileDir = replace $fileDir "\\" "/" }}
|
||||
{{- range sort (readDir (printf "%s%s" $fileDir $filesName) ) "Name" $sort }}
|
||||
{{- if findRE $pattern .Name}}
|
||||
{{- $size := .Size }}
|
||||
{{- $unit := "Byte-symbol" }}
|
||||
{{- if ge $size 1024 }}
|
||||
{{- $size = div $size 1024 }}
|
||||
{{- $unit = "Kilobyte-symbol" }}
|
||||
{{- end }}
|
||||
{{- if ge $size 1024 }}
|
||||
{{- $size = div $size 1024 }}
|
||||
{{- $unit = "Megabyte-symbol" }}
|
||||
{{- end }}
|
||||
{{- $unitsymbol := $unit | T }}
|
||||
<li><a href="{{ (printf "%s%s/%s" $fileLink $filesName .Name) | relURL }}">{{.Name}}</a> ({{$size}} {{$unitsymbol}})</li>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
</ul>
|
||||
{{- .Inner }}
|
||||
</div>
|
||||
{{- partial "shortcodes/attachments.html" (dict
|
||||
"context" .
|
||||
"content" .Inner
|
||||
"icon" (.Get "icon")
|
||||
"pattern" (.Get "pattern")
|
||||
"style" (.Get "style")
|
||||
"sort" (.Get "sort")
|
||||
"title" (.Get "title")
|
||||
) }}
|
|
@ -1,27 +1,10 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- $href := .Get "href" }}
|
||||
{{- $style := .Get "style" | default "transparent" }}
|
||||
{{- $title := .Get "title" | default (.Inner) | default ($style | T) }}
|
||||
{{- $icon := .Get "icon" | default "" }}
|
||||
{{- if and (not $icon) (eq (len $icon) 0) }}
|
||||
{{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }}
|
||||
{{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }}
|
||||
{{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }}
|
||||
{{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }}
|
||||
{{- end }}
|
||||
{{- $icon = trim $icon " " }}
|
||||
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
|
||||
{{- $icon = printf "fa-fw fas fa-%s" $icon }}
|
||||
{{- end }}
|
||||
{{- $iconposition := .Get "icon-position" | default "left" }}
|
||||
<span class="btn cstyle {{ $style }}">
|
||||
<a href="{{ $href }}" target="_blank">
|
||||
{{- if and $icon (eq $iconposition "left") }}
|
||||
<i class="{{ $icon }}"></i>
|
||||
{{- end }}
|
||||
{{ $title }}
|
||||
{{- if and $icon (eq $iconposition "right") }}
|
||||
<i class="{{ $icon }}"></i>
|
||||
{{- end }}
|
||||
</a>
|
||||
</span>
|
||||
{{- partial "shortcodes/button.html" (dict
|
||||
"context" .
|
||||
"content" .Inner
|
||||
"href" (.Get "href")
|
||||
"icon" (.Get "icon")
|
||||
"icon-position" (.Get "iconposition")
|
||||
"style" (.Get "style")
|
||||
"title" (.Get "title")
|
||||
) }}
|
|
@ -1,105 +1,10 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- $showhidden := .Get "showhidden" | default false }}
|
||||
{{- if eq (printf "%T" $showhidden) "string" }}
|
||||
{{- $showhidden = (eq $showhidden "true") }}
|
||||
{{- end }}
|
||||
{{- $style := .Get "style" | default "li" }}
|
||||
{{- $depth := .Get "depth" | default 1 }}
|
||||
{{- $withDescription := .Get "description" | default false }}
|
||||
{{- if eq (printf "%T" $withDescription) "string" }}
|
||||
{{- $withDescription = (eq $withDescription "true") }}
|
||||
{{- end }}
|
||||
{{- $sortTerm := .Get "sort" | lower }}
|
||||
{{- $containerstyle := .Get "containerstyle" | default "ul" }}
|
||||
{{- if( and (not (eq $style "li") ) (eq $containerstyle "ul" ) ) }}
|
||||
{{- $containerstyle = "div" }}
|
||||
{{- end }}
|
||||
|
||||
{{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }}
|
||||
{{- $pages := .Page.Pages }}
|
||||
{{- if .Page.IsHome }}
|
||||
{{- $pages = .Page.Sections }}
|
||||
{{- else if .Page.Sections}}
|
||||
{{- $pages = (.Page.Pages | union .Page.Sections) }}
|
||||
{{- end }}
|
||||
|
||||
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
||||
{{- $currentOrdersectionsby := $sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
||||
{{- if eq $currentOrdersectionsby "weight" }}
|
||||
{{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- else if or (eq $currentOrdersectionsby "name") (eq $currentOrdersectionsby "title") }}
|
||||
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- else if eq $currentOrdersectionsby "publishdate" }}
|
||||
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- else if eq $currentOrdersectionsby "date" }}
|
||||
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- else if eq $currentOrdersectionsby "length" }}
|
||||
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- else }}
|
||||
{{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
||||
{{- end }}
|
||||
{{ (printf "</%s>" $containerstyle)|safeHTML }}
|
||||
|
||||
{{- define "childs" }}
|
||||
{{- range .menu }}
|
||||
{{- $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
|
||||
{{- if not $hidden }}
|
||||
{{- if not .IsHome }}
|
||||
{{- if hasPrefix $.style "h" }}
|
||||
{{- $num := sub ( int (trim $.style "h") ) 1 }}
|
||||
{{- $numn := add $num $.count }}
|
||||
|
||||
{{ (printf "<h%d>" $numn)|safeHTML -}}
|
||||
<a href="{{ .RelPermalink }}" >{{ .Title }}</a>
|
||||
{{- (printf "</h%d>" $numn)|safeHTML }}
|
||||
|
||||
{{- else }}
|
||||
{{ (printf "<%s>" $.style)|safeHTML -}}
|
||||
<a href="{{ .RelPermalink }}" >{{ .Title }}</a>
|
||||
{{- (printf "</%s>" $.style)|safeHTML }}
|
||||
{{- end }}
|
||||
|
||||
{{- if $.description }}
|
||||
{{- if .Description }}
|
||||
<p>{{ .Description }}</p>
|
||||
{{else}}
|
||||
<p>{{ .Summary }}</p>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if lt $.count $.depth }}
|
||||
|
||||
{{- if eq $.style "li" }}
|
||||
{{- (printf "<%s>" $.containerstyle)|safeHTML }}
|
||||
{{- end }}
|
||||
|
||||
{{- $pages := .Page.Pages }}
|
||||
{{- if .Page.IsHome }}
|
||||
{{- $pages = .Page.Sections }}
|
||||
{{- else if .Page.Sections}}
|
||||
{{- $pages = (.Page.Pages | union .Page.Sections) }}
|
||||
{{- end }}
|
||||
|
||||
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
||||
{{- $currentOrdersectionsby := $.sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
||||
{{- if eq $currentOrdersectionsby "weight" }}
|
||||
{{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- else if or (eq $.currentOrdersectionsby "name") (eq $.currentOrdersectionsby "title") }}
|
||||
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- else if eq $.currentOrdersectionsby "publishdate" }}
|
||||
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- else if eq $.currentOrdersectionsby "date" }}
|
||||
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- else if eq $.currentOrdersectionsby "length" }}
|
||||
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- else }}
|
||||
{{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
||||
{{- end }}
|
||||
|
||||
{{- if eq $.style "li" }}
|
||||
{{- (printf "</%s>" $.containerstyle)|safeHTML }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- partial "shortcodes/children.html" (dict
|
||||
"context" .
|
||||
"containerstyle" (.Get "containerstyle")
|
||||
"descrption" (.Get "description")
|
||||
"depth" (.Get "depth")
|
||||
"showhidden" (.Get "showhidden")
|
||||
"sort" (.Get "sort")
|
||||
"style" (.Get "style")
|
||||
) }}
|
|
@ -1,22 +1,7 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- $title := .Get "title" | default (.Get 0) | default (T "Expand-title") }}
|
||||
{{- $expanded := .Get "open" | default (.Get 1) | default false }}
|
||||
{{- if eq (printf "%T" $expanded) "string" }}
|
||||
{{- $expanded = (eq $expanded "true") }}
|
||||
{{- end }}
|
||||
{{- $content := .Inner | safeHTML }}
|
||||
<div class="expand
|
||||
{{- if $expanded }} expand-expanded{{ end -}}
|
||||
">
|
||||
{{/* things are getting complicated when search tries to open the expand box while jquery sets the display CSS on the element */}}{{ "" -}}
|
||||
<a class="expand-label" onclick="$t=$(this); if($t.parent('.expand-expanded.expand-marked').length){ $t.next().css('display','none') }else if($t.parent('.expand-marked').length){ $t.next().css('display','block') }else{ $t.next('.expand-content').slideToggle(100); } $t.parent().toggleClass('expand-expanded');">
|
||||
<i class="fas fa-chevron-down"></i>
|
||||
<i class="fas fa-chevron-right"></i>
|
||||
{{ $title }}
|
||||
</a>
|
||||
<div class="expand-content" style="display:
|
||||
{{- if $expanded }} block{{ else }} none{{ end -}}
|
||||
;">
|
||||
{{ $content }}
|
||||
</div>
|
||||
</div>
|
||||
{{- partial "shortcodes/expand.html" (dict
|
||||
"context" .
|
||||
"content" .Inner
|
||||
"open" (.Get "open" | default (.Get 1))
|
||||
"title" (.Get "title" | default (.Get 0))
|
||||
) }}
|
|
@ -1,10 +1,5 @@
|
|||
{{- $file := .Get "file" | default (.Get 0) }}
|
||||
{{- $showFirstHeading := .Get "showfirstheading" | default (.Get 1) | default true }}
|
||||
{{- if eq (printf "%T" $showFirstHeading) "string" }}
|
||||
{{- $showFirstHeading = (eq $showFirstHeading "true") }}
|
||||
{{- end }}
|
||||
{{- if not $showFirstHeading }}<div class="include hide-first-heading">{{ end }}
|
||||
|
||||
{{ $file | readFile | safeHTML }}
|
||||
|
||||
{{- if not $showFirstHeading }}</div>{{ end }}
|
||||
{{- partial "shortcodes/include.html" (dict
|
||||
"context" .
|
||||
"file" (.Get "align" | default (.Get 0))
|
||||
"showFirstHeading" (.Get "showfirstheading" | default (.Get 1))
|
||||
) }}
|
|
@ -1,6 +1,6 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- $align := .Get "align" | default "center" }}
|
||||
<div class="mermaid" align="{{ $align }}">
|
||||
{{- safeHTML .Inner -}}
|
||||
</div>
|
||||
{{- .Page.Store.Set "htmlHasMermaid" true }}
|
||||
{{- partial "shortcodes/mermaid.html" (dict
|
||||
"context" .
|
||||
"content" .Inner
|
||||
"align" (.Get "align")
|
||||
) }}
|
|
@ -1,19 +1,8 @@
|
|||
{{- $_hugo_config := `{ "version": 1 }` }}
|
||||
{{- $style := .Get "style" | default (.Get 0) | default "default" }}
|
||||
{{- $title := .Get "title" | default (.Get 1) | default ($style | T) }}
|
||||
{{- $icon := .Get "icon" | default (.Get 2) | default "" }}
|
||||
{{- if and (not $icon) (eq (len $icon) 0) }}
|
||||
{{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }}
|
||||
{{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }}
|
||||
{{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }}
|
||||
{{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }}
|
||||
{{- end }}
|
||||
{{- $icon = trim $icon " " }}
|
||||
{{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }}
|
||||
{{- $icon = printf "fa-fw fas fa-%s" $icon }}
|
||||
{{- end }}
|
||||
<div class="box notices cstyle {{ $style }}">
|
||||
<div class="box-label">{{ if $icon }}<i class="{{ $icon }}"></i> {{ end }}{{ $title }}</div>
|
||||
<div class="box-content">
|
||||
{{ .Inner }} </div>
|
||||
</div>
|
||||
{{- partial "shortcodes/notice.html" (dict
|
||||
"context" .
|
||||
"content" .Inner
|
||||
"icon" (.Get "icon" | default (.Get 2))
|
||||
"style" (.Get "style" | default (.Get 0))
|
||||
"title" (.Get "title" | default (.Get 1))
|
||||
) }}
|
|
@ -1,7 +1,4 @@
|
|||
{{- $paramName := .Get "name" | default (.Get 0) -}}
|
||||
{{- $siteParams := .Site.Params -}}
|
||||
{{- with $paramName -}}
|
||||
{{- with $siteParams -}}
|
||||
{{- index . (lower $paramName) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- partial "shortcodes/siteparam.html" (dict
|
||||
"context" .
|
||||
"name" (.Get "name" | default (.Get 0))
|
||||
) }}
|
|
@ -1,25 +1,4 @@
|
|||
{{- $original := .Get "src" }}
|
||||
{{- with .Page.Resources.Match $original }}
|
||||
{{- range . }}
|
||||
{{- $original = .RelPermalink }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
<style>
|
||||
rapi-doc::part(section-endpoint-head-method) {
|
||||
font-size: 11px;
|
||||
}
|
||||
</style>
|
||||
<rapi-doc
|
||||
allow-spec-file-download="true"
|
||||
default-schema-tab="example"
|
||||
font-size="largest"
|
||||
layout="column"
|
||||
load-fonts="false"
|
||||
render-style="view"
|
||||
schema-description-expanded="true"
|
||||
schema-style="table"
|
||||
show-header="false"
|
||||
spec-url="{{ $original }}"
|
||||
sort-tags="true"
|
||||
></rapi-doc>
|
||||
{{- .Page.Store.Set "htmlHasSwagger" true }}
|
||||
{{- partial "shortcodes/swagger.html" (dict
|
||||
"context" .
|
||||
"src" (.Get "src")
|
||||
) }}
|
|
@ -1,11 +1,10 @@
|
|||
{{ if .Parent }}
|
||||
{{ $name := trim (.Get "name") " " }}
|
||||
{{ if not (.Parent.Scratch.Get "tabs") }}
|
||||
{{ .Parent.Scratch.Set "tabs" slice }}
|
||||
{{ end }}
|
||||
{{ with .Inner }}
|
||||
{{ $.Parent.Scratch.Add "tabs" (dict "name" $name "content" . ) }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{- $content := .Inner }}
|
||||
{{- $name := (.Get "name") }}
|
||||
{{- if .Parent }}
|
||||
{{- if not (.Parent.Scratch.Get "tabs") }}
|
||||
{{- .Parent.Scratch.Set "tabs" slice }}
|
||||
{{- end }}
|
||||
{{- $.Parent.Scratch.Add "tabs" (dict "name" (trim $name " ") "content" $content ) }}
|
||||
{{- else }}
|
||||
{{- errorf "[%s] %q: tab shortcode missing its parent" site.Language.Lang .Page.Path -}}
|
||||
{{ end}}
|
||||
{{- end}}
|
|
@ -1,21 +1,6 @@
|
|||
{{- with .Inner }}{{/* don't do anything, just call it */}}{{ end }}
|
||||
{{- $groupId := .Get "groupId" | default "default" }}
|
||||
<div class="tab-panel">
|
||||
<div class="tab-nav">
|
||||
{{- range $idx, $tab := .Scratch.Get "tabs" }}
|
||||
<button
|
||||
data-tab-item="{{ .name }}"
|
||||
data-tab-group="{{ $groupId }}"
|
||||
class="tab-nav-button {{ cond (eq $idx 0) "active" ""}}"
|
||||
onclick="switchTab('{{ $groupId }}','{{ .name }}')"
|
||||
><span>{{ .name }}</span></button>
|
||||
{{- end }}
|
||||
</div>
|
||||
<div class="tab-content">
|
||||
{{- range $idx, $tab := .Scratch.Get "tabs" }}
|
||||
<div data-tab-item="{{ .name }}" data-tab-group="{{ $groupId }}" class="tab-item {{ cond (eq $idx 0) "active" ""}}">
|
||||
{{ .content }}
|
||||
</div>
|
||||
{{- end }}
|
||||
</div>
|
||||
</div>
|
||||
{{- partial "shortcodes/tabs.html" (dict
|
||||
"context" .
|
||||
"content" .Inner
|
||||
"groupId" (.Get "groupId")
|
||||
"tabs" (.Scratch.Get "tabs")
|
||||
) }}
|
Loading…
Reference in a new issue