Skip to content

Commit

Permalink
Merge branch 'main' into blocks/feature-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fekete-robert authored May 17, 2023
2 parents d34e3ff + 13db293 commit dd4bea1
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 132 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ For a list of issues targeted for the next release, see the [23Q1][] milestone.
- `blocks/section`: **default** and accepted values of the `type` argument
have changed! For details see [blocks/section] ([#1472]).

- **[Adaptation of shortcodes for diplay of cards (#1376)][1376]:
- shortcode `cardpane`: renamed CSS class `td-card-deck` to `td-card-group`.
- shortcode `card`, `card-code`: markup of inner content (html/markdown)
now depends on the syntax of the calling shortcode, not on extension
of page file any more [#906][906].
- shortcode `card-code` is now deprecated, use shortcode `card` with named
parameter `code=true` instead.

**Other changes**:

- Non-breaking changes that result from the Bootstrap v5 upgrade:
Expand Down
3 changes: 2 additions & 1 deletion assets/scss/shortcodes/cards-pane.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.td-card-deck.card-deck {
.td-card-group.card-group {
@extend .td-max-width-on-larger-screens;
}

Expand All @@ -8,6 +8,7 @@

.highlight {
border: none;
margin: 0;
}
}

Expand Down
1 change: 1 addition & 0 deletions dependencies/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ _merge = "deep"
[[module.imports]]
path = "github.com/twbs/bootstrap"
disable = false
ignoreConfig = true
[[module.imports.mounts]]
source = "scss"
target = "assets/vendor/bootstrap/scss"
Expand Down
2 changes: 1 addition & 1 deletion layouts/shortcodes/blocks/lead.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{{ $height := .Get "height" | default "auto" -}}
{{ with .Get "height" -}}
{{ if not ( or ( eq . "auto" ) ( eq . "min" ) ( eq . "med" ) ( eq . "max" ) ( eq . "full" ) ) -}}
{{ errorf "shortcode 'lead': parameter height is '%s', must be one of 'auto', 'min', 'med', 'max' or 'full'." . -}}
{{ errorf "shortcode 'lead': parameter height is %q, must be one of 'auto', 'min', 'med', 'max' or 'full'." . -}}
{{ end -}}
{{ end -}}

Expand Down
28 changes: 12 additions & 16 deletions layouts/shortcodes/card-code.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
<div class="td-card card">
{{ $lang := "" }}
{{ with $.Get "lang" }}
{{ $lang = $.Get "lang" }}
{{ end }}
{{ $highlight := "" }}
{{ with $.Get "highlight" }}
{{ $highlight = $.Get "highlight" }}
{{ end }}
{{- with $.Get "header" -}}
{{ warnf `shortcode 'card-code' is deprecated: use shortcode 'card' with named parameter 'code=true' instead.` -}}
{{ $lang := default "" ($.Get "lang") -}}
{{ $highlight := default "" ($.Get "highlight") -}}

<div class="td-card card border me-4">
{{ with $.Get "header" -}}
<div class="card-header bg-white">
{{- $.Get "header" | markdownify -}}
{{ . | markdownify -}}
</div>
{{end}}
<div class="card-body code p-l0 m-0">
{{ with $.Inner }}
{{- highlight $.Inner $lang $highlight -}}
{{ end }}
{{ end -}}
<div class="card-body code p-0 m-0">
{{ with $.Inner -}}
{{ highlight . $lang $highlight -}}
{{ end -}}
</div>
</div>
76 changes: 37 additions & 39 deletions layouts/shortcodes/card.html
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
<div class="td-card card mb-4">
{{ with $.Get "header" }}
<div class="card-header">
{{ if eq $.Page.File.Ext "md" }}
{{ $.Get "header" | markdownify }}
{{ else }}
{{ $.Get "header" | htmlUnescape | safeHTML }}
{{ end }}
{{/* Check parameter type */ -}}
{{ $code := false -}}
{{ with .Get "code" -}}
{{ $type := printf "%T" . -}}
{{ if ne $type "bool" -}}
{{ errorf `shortcode 'card': boolean value expected for parameter 'code', but got %s` $type -}}
{{ else }}
{{ $code = . -}}
{{ end -}}
{{ end -}}

{{ $lang := default "" (.Get "lang") -}}
{{ $highlight := default "" (.Get "highlight") -}}

<div class="td-card card border me-4">
{{ with $.Get "header" -}}
<div class="card-header{{- cond $code " bg-white" "" -}}">
{{ . | markdownify }}
</div>
{{ end }}
<div class="card-body">
{{ with $.Get "title" }}
{{ end -}}
<div class="card-body{{- cond $code " code p-0 m-0" "" -}}">
{{ with $.Get "title" -}}
<h5 class="card-title">
{{ if eq $.Page.File.Ext "md" }}
{{ $.Get "title" | markdownify }}
{{ else }}
{{ $.Get "title" | htmlUnescape | safeHTML }}
{{ end }}
{{ . | markdownify -}}
</h5>
{{ end }}
{{ with $.Get "subtitle" }}
<h6 class="card-title mb-2 text-muted">
{{ if eq $.Page.File.Ext "md" }}
{{ $.Get "subtitle" | markdownify }}
{{ else }}
{{ $.Get "subtitle" | htmlUnescape | safeHTML }}
{{ end }}
{{ end -}}
{{ with $.Get "subtitle" -}}
<h6 class="card-title ms-2 text-muted">
{{ . | markdownify -}}
</h6>
{{ end }}
{{ with $.Inner }}
{{ end -}}
{{ with $.Inner -}}
{{ if $code -}}
{{ highlight . $lang $highlight -}}
{{ else -}}
<p class="card-text">
{{ if eq $.Page.File.Ext "md" }}
{{ $.Inner | markdownify }}
{{ else }}
{{ $.Inner | htmlUnescape | safeHTML }}
{{ end }}
{{ . -}}
</p>
{{ end }}
{{ end -}}
{{ end -}}
</div>
{{ with $.Get "footer" }}
{{ with $.Get "footer" -}}
<div class="card-footer">
{{ if eq $.Page.File.Ext "md" }}
{{ $.Get "footer" | markdownify }}
{{ else }}
{{ $.Get "footer" | htmlUnescape | safeHTML }}
{{ end }}
{{ . | markdownify -}}
</div>
{{ end }}
{{ end -}}
</div>
4 changes: 2 additions & 2 deletions layouts/shortcodes/cardpane.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div class="td-card-deck card-deck mb-4">
<div class="td-card-group card-group p-0 mb-4">
{{- .Inner -}}
</div>
</div>
28 changes: 14 additions & 14 deletions layouts/shortcodes/imgproc.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{{ $original := .Page.Resources.GetMatch (printf "**%s*" (.Get 0)) }}
{{ $command := .Get 1 }}
{{ $options := .Get 2 }}
{{ if eq $command "Fit"}}
{{ .Scratch.Set "image" ($original.Fit $options) }}
{{ else if eq $command "Resize"}}
{{ .Scratch.Set "image" ($original.Resize $options) }}
{{ else if eq $command "Fill"}}
{{ .Scratch.Set "image" ($original.Fill $options) }}
{{ else if eq $command "Crop"}}
{{ .Scratch.Set "image" ($original.Crop $options) }}
{{ else }}
{{ errorf "Invalid image processing command: Must be one of Fit, Fill, Crop or Resize."}}
{{ end }}
{{ $original := .Page.Resources.GetMatch (printf "**%s*" (.Get 0)) -}}
{{ $command := .Get 1 -}}
{{ $options := .Get 2 -}}
{{ if eq $command "Fit" -}}
{{ .Scratch.Set "image" ($original.Fit $options) -}}
{{ else if eq $command "Resize" -}}
{{ .Scratch.Set "image" ($original.Resize $options) -}}
{{ else if eq $command "Fill" -}}
{{ .Scratch.Set "image" ($original.Fill $options) -}}
{{ else if eq $command "Crop" -}}
{{ .Scratch.Set "image" ($original.Crop $options) -}}
{{ else -}}
{{ errorf "Invalid image processing command %q: must be one of Fit, Fill, Crop or Resize." $command -}}
{{ end -}}
{{ $image := .Scratch.Get "image" }}
<figure class="card rounded p-2 td-post-card mb-4 mt-4" style="max-width: {{ add $image.Width 10 }}px">
<img class="card-img-top" src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}">
Expand Down
13 changes: 8 additions & 5 deletions layouts/shortcodes/tab.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{{- /* Make sure that we are enclosed within a tabpane shortcode block */ -}}

{{ with $.Parent -}}
{{ if ne $.Parent.Name "tabpane" -}}
{{ errorf "shortcode 'tab' must be used within a 'tabpane' block" -}}
{{ if ne $.Parent.Name "tabpane" -}}
{{ errorf "Found shortcode %q enclosed inside a %q block, must be enclosed inside a %q block. Error position: %s" $.Name $.Parent.Name "tabpane" $.Position -}}
{{ end -}}
{{ else -}}
{{ errorf "shortcode %q must be enclosed inside a %q block, but no parent block was found. Error position: %s" $.Name "tabpane" $.Position -}}
{{ end -}}

{{ $header := "Tab" -}}
Expand All @@ -23,19 +26,19 @@
{{ end -}}
{{ with $.Get "text" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "shortcode tab: parameter 'text' must be either true or false" -}}
{{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "text" (printf "%T" .) $.Position -}}
{{ end -}}
{{ $tab = merge $tab (dict "text" ($.Get "text")) -}}
{{ end -}}
{{ with $.Get "right" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "shortcode tab: parameter 'right' must be either true or false" -}}
{{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "right" (printf "%T" .) $.Position -}}
{{ end -}}
{{ $tab = merge $tab (dict "rightpush" ($.Get "right")) -}}
{{ end -}}
{{ with $.Get "disabled" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "shortcode tab: parameter 'disabled' must be either true or false" -}}
{{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "disabled" (printf "%T" .) $.Position -}}
{{ end -}}
{{ $tab = merge $tab (dict "disabled" ($.Get "disabled")) -}}
{{ end -}}
Expand Down
12 changes: 6 additions & 6 deletions layouts/shortcodes/tabpane.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{{/* Check parameter types */ -}}
{{ with .Get "langEqualsHeader" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "shortcode tabpane: parameter 'langEqualsHeader' must be either true or false" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "langEqualsHeader" (printf "%T" .) $.Position -}}
{{ end -}}
{{ end -}}

{{ with .Get "text" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "shortcode tabpane: parameter 'text' must be either true or false" -}}
{{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "text" (printf "%T" .) $.Position -}}
{{ end -}}
{{ end -}}

{{ with .Get "persistLang" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "shortcode tabpane: parameter 'persistLang' must be either true or false" -}}
{{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "persistLang" (printf "%T" .) $.Position -}}
{{ end -}}
{{ end -}}

{{ with .Get "right" -}}
{{ if ne ( printf "%T" . ) "bool" -}}
{{ errorf "shortcode tabpane: parameter 'right' must be either true or false" -}}
{{ errorf "Shortcode %q: boolean value expected for parameter %q, but got %s. Error position: %s" $.Name "right" (printf "%T" .) $.Position -}}
{{ end -}}
{{ end -}}

Expand Down Expand Up @@ -101,7 +101,7 @@
</ul>

{{ if $duplicate -}}
{{ warnf "Tabpane on page '%s': duplicate language '%s' detected, disabling persistance of language to avoid multiple tab display." .Page.RelPermalink $duplicateLang -}}
{{ warnf "Shortcode %q: duplicate language %q detected, disabling persistance of language to avoid multiple tab display. Position: %s" $.Name $duplicateLang $.Position -}}
{{ end -}}
{{ $duplicate = false -}}
{{ $langs = slice -}}
Expand Down
Loading

0 comments on commit dd4bea1

Please sign in to comment.