Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tailwind): port support for Publications and Events
- Loading branch information
Showing
15 changed files
with
417 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.hb-attachment-link { | ||
@apply inline-block text-primary-600 dark:text-primary-400 font-bold uppercase outline-none focus:outline-none mr-1 mb-1 ease-linear transition-all duration-150; | ||
} | ||
|
||
.hb-attachment-link-small { | ||
@apply px-3 py-1 text-xs; | ||
} | ||
|
||
.hb-attachment-link-large { | ||
@apply px-8 py-3; | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Address formats. | ||
en-ca = {order = ['street', 'city', 'region', 'postcode', 'country'], delimiters = ['<br>', ', ', '<br>', '<br>']} | ||
en-us = {order = ['street', 'city', 'region', 'postcode'], delimiters = [', ', ', ', ' ', '']} | ||
en-gb = {order = ['street', 'city', 'region', 'postcode'], delimiters = [', ', ', ', ', ', '']} | ||
de = {order = ['street', 'postcode', 'city'], delimiters = ['<br>', ' ', '']} | ||
fr-ca = {order = ['street', 'city', 'region', 'postcode', 'country'], delimiters = ['<br>', ', ', '<br>', '<br>']} | ||
fr-fr = {order = ['street', 'postcode', 'city'], delimiters = ['<br>', ' ', '']} | ||
nl = {order = ['street', 'postcode', 'city', 'country'], delimiters = ['<br>', ' ', '<br>', '']} | ||
zh = {order = ['postcode', 'region', 'city', 'street'], delimiters = [' ', ' ', ' ', '']} | ||
pt-br = {order = ['street', 'city', 'region', 'postcode', 'country'], delimiters = ['<br>', ', ', '<br>', '<br>']} | ||
il = {order = ['street', 'city', 'postcode', 'country'], delimiters = [', ', ' ', ' ', '']} | ||
fi = {order = ['street', 'postcode', 'city', 'country'], delimiters = [', ', ' ', ', ']} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
modules/blox-tailwind/layouts/partials/functions/get_address.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{/* Function to return a formatted address given a semantic address. */}} | ||
|
||
{{/* Check for valid site config. */}} | ||
{{ if not site.Data.address_formats }}{{errorf "Address formats missing from `data/address_formats.toml`!"}}{{end}} | ||
|
||
{{ $page := . }} | ||
{{ $address := .address }} | ||
{{ $format_name := $page.Params.address_format | default site.Params.locale.address_format | default "en-us" }} | ||
|
||
{{ if not (isset site.Data.address_formats $format_name) }}{{ errorf "Address format `%s` missing from `data/address_formats.toml`!" $format_name }}{{end}} | ||
|
||
{{ $format := index site.Data.address_formats $format_name }} | ||
{{ $address_display := slice }} | ||
|
||
{{ range $k, $v := $format.order }} | ||
{{ if eq $v "street" | and $address.street }}{{$address_display = $address_display | append (transform.HTMLEscape $address.street) | append (index $format.delimiters $k | default "") }}{{end}} | ||
{{ if eq $v "city" | and $address.city }}{{$address_display = $address_display | append (transform.HTMLEscape $address.city) | append (index $format.delimiters $k | default "") }}{{end}} | ||
{{ if eq $v "region" | and $address.region }}{{$address_display = $address_display | append (transform.HTMLEscape $address.region) | append (index $format.delimiters $k | default "") }}{{end}} | ||
{{ if eq $v "postcode" | and $address.postcode }}{{$address_display = $address_display | append (transform.HTMLEscape $address.postcode) | append (index $format.delimiters $k | default "") }}{{end}} | ||
{{ if eq $v "country" | and $address.country }}{{$address_display = $address_display | append (transform.HTMLEscape $address.country) | append (index $format.delimiters $k | default "") }}{{end}} | ||
{{end}} | ||
|
||
{{ return safeHTML (delimit $address_display "") }} |
17 changes: 17 additions & 0 deletions
17
modules/blox-tailwind/layouts/partials/functions/get_event_dates.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{/* Function to get event start and end dates/times. */}} | ||
{{ $t1 := time .Date }}{{/* Start datetime. */}} | ||
{{ $str := slice (time.Format site.Params.locale.date_format (time $t1)) }}{{/* Init return string with start date. */}} | ||
{{/* Show start time if not all day event. */}} | ||
{{ if not .Params.all_day }}{{ $str = $str | append (time.Format site.Params.locale.time_format (time $t1)) }}{{ end }} | ||
{{/* Show event end date if provided. */}} | ||
{{ if .Params.date_end }} | ||
{{ $str = $str | append "—" }} | ||
{{ $t2 := time .Params.date_end}}{{/* End datetime. */}} | ||
{{/* Show end date if it differs to start date. */}} | ||
{{ if not (eq $t1.Year $t2.Year | and (eq $t1.Month $t2.Month) | and (eq $t1.Day $t2.Day)) }} | ||
{{ $str = $str | append (time.Format site.Params.locale.date_format (time $t2)) }} | ||
{{ end }} | ||
{{/* Show end time if not all day event. */}} | ||
{{ if not .Params.all_day }}{{ $str = $str | append (time.Format site.Params.locale.time_format (time $t2)) }}{{ end }} | ||
{{ end }} | ||
{{ return ((delimit $str " ") | safeHTML) }} |
23 changes: 23 additions & 0 deletions
23
modules/blox-tailwind/layouts/partials/functions/has_attachments.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{/* Return true if the page has attachments or link buttons to display. */}} | ||
|
||
{{ $page := . }} | ||
|
||
{{ $pdf_link := false }} | ||
{{/* Prevent Hugo warning ".File.ContentBaseName on zero object." for content not backed by a Markdown file, */}} | ||
{{/* such as auto-generated taxonomy pages, and sections without an explicit index file. */}} | ||
{{/* The file check is required when called from `_default/list.html`, the fallback list view for the above cases. */}} | ||
{{ with $page.File }} | ||
{{ $slug := $page.File.ContentBaseName }} | ||
{{ $resource := $page.Resources.GetMatch (printf "%s.pdf" $slug) }} | ||
{{ with $resource }} | ||
{{ $pdf_link = true }} | ||
{{ end }} | ||
{{ end }} | ||
|
||
{{ $cite_link := false }} | ||
{{ $resource := $page.Resources.GetMatch "cite.bib" }} | ||
{{ with $resource }} | ||
{{ $cite_link = true }} | ||
{{ end }} | ||
|
||
{{ return ($cite_link | or $pdf_link | or .Params.url_preprint | or .Params.url_pdf | or .Params.url_slides | or .Params.url_video | or .Params.url_source | or .Params.url_code | or .Params.url_dataset | or .Params.url_poster | or .Params.url_project | or .Params.doi | or .Params.links | or .Params.projects | or .Params.slides) }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
{{ $is_list := .is_list }} | ||
{{ $page := .page }} | ||
{{ $link := "" }} | ||
|
||
{{/* ***** TODO: Deprecate `url_preprint` in favour of `url_pdf` given there's now a dedicated "Preprint" pub. type. ***** */}} | ||
{{ with $page.Params.url_preprint }} | ||
{{ $resource := $page.Resources.GetMatch . }} | ||
{{ if $resource }} | ||
{{ $link = $resource.RelPermalink }} | ||
{{ else }} | ||
{{ $link = . | relURL }} | ||
{{ end }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener"> | ||
{{ i18n "btn_preprint" }} | ||
</a> | ||
{{ end }} | ||
{{ $pdf := "" }} | ||
{{ $resource := $page.Resources.GetMatch (printf "%s.pdf" $page.File.ContentBaseName) }} | ||
{{ with $resource }} | ||
{{ $pdf = .RelPermalink }} | ||
{{ else }} | ||
{{ if $page.Params.url_pdf }} | ||
{{ $pdf = $page.Params.url_pdf | relURL }} | ||
{{ end }} | ||
{{ end }} | ||
|
||
{{ with $pdf }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ . }}" target="_blank" rel="noopener"> | ||
{{ partial "functions/get_icon" (dict "name" "document-text" "attributes" "style=\"height: 1em\" class='inline-block'") }} | ||
{{ i18n "btn_pdf" }} | ||
</a> | ||
{{ end }} | ||
{{ $resource := $page.Resources.GetMatch "cite.bib" }} | ||
{{ with $resource }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ .RelPermalink }}" target="_blank" data-filename="{{ .RelPermalink }}"> | ||
{{ partial "functions/get_icon" (dict "name" "document-duplicate" "attributes" "style=\"height: 1em\" class='inline-block'") }} | ||
{{ i18n "btn_cite" }} | ||
</a> | ||
{{ end }} | ||
{{ with $page.Params.url_code }} | ||
{{ $resource := $page.Resources.GetMatch . }} | ||
{{ if $resource }} | ||
{{ $link = $resource.RelPermalink }} | ||
{{ else }} | ||
{{ $link = . | relURL }} | ||
{{ end }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener"> | ||
{{ partial "functions/get_icon" (dict "name" "code-bracket" "attributes" "style=\"height: 1em\" class='inline-block'") }} | ||
{{ i18n "btn_code" }} | ||
</a> | ||
{{ end }} | ||
{{ with $page.Params.url_dataset }} | ||
{{ $resource := $page.Resources.GetMatch . }} | ||
{{ if $resource }} | ||
{{ $link = $resource.RelPermalink }} | ||
{{ else }} | ||
{{ $link = . | relURL }} | ||
{{ end }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener"> | ||
{{ partial "functions/get_icon" (dict "name" "circle-stack" "attributes" "style=\"height: 1em\" class='inline-block'") }} | ||
{{ i18n "btn_dataset" }} | ||
</a> | ||
{{ end }} | ||
{{ if $page.Params.projects }} | ||
{{ range $page.Params.projects }} | ||
{{ with (site.GetPage (printf "project/%s" .)) }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ .RelPermalink }}"> | ||
{{ i18n "btn_project" }} | ||
</a> | ||
{{ else }} | ||
{{/* errorf "The `projects` parameter in `content/%s` references a project file, `content/project/%s`, which cannot be found. Please either set `projects = []` or fix the reference." $page.File.Path . */}} | ||
{{ end }} | ||
{{ end }} | ||
{{ else }} | ||
{{ with $page.Params.url_project }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ . }}" target="_blank" rel="noopener"> | ||
{{ i18n "btn_project" }} | ||
</a> | ||
{{ end }} | ||
{{ end }} | ||
{{ with $page.Params.url_poster }} | ||
{{ $resource := $page.Resources.GetMatch . }} | ||
{{ if $resource }} | ||
{{ $link = $resource.RelPermalink }} | ||
{{ else }} | ||
{{ $link = . | relURL }} | ||
{{ end }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener"> | ||
{{ partial "functions/get_icon" (dict "name" "photo" "attributes" "style=\"height: 1em\" class='inline-block'") }} | ||
{{ i18n "btn_poster" }} | ||
</a> | ||
{{ end }} | ||
{{ if $page.Params.slides }} | ||
{{ with (site.GetPage (printf "slides/%s" $page.Params.slides)) }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ .RelPermalink }}" target="_blank"> | ||
{{ partial "functions/get_icon" (dict "name" "presentation-chart-bar" "attributes" "style=\"height: 1em\" class='inline-block'") }} | ||
{{ i18n "btn_slides" }} | ||
</a> | ||
{{ end }} | ||
{{ else }} | ||
{{ with $page.Params.url_slides }} | ||
{{ $resource := $page.Resources.GetMatch . }} | ||
{{ if $resource }} | ||
{{ $link = $resource.RelPermalink }} | ||
{{ else }} | ||
{{ $link = . | relURL }} | ||
{{ end }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener"> | ||
{{ partial "functions/get_icon" (dict "name" "presentation-chart-bar" "attributes" "style=\"height: 1em\" class='inline-block'") }} | ||
{{ i18n "btn_slides" }} | ||
</a> | ||
{{ end }} | ||
{{ end }} | ||
{{ with $page.Params.url_video }} | ||
{{ $resource := $page.Resources.GetMatch . }} | ||
{{ if $resource }} | ||
{{ $link = $resource.RelPermalink }} | ||
{{ else }} | ||
{{ $link = . | relURL }} | ||
{{ end }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener"> | ||
{{ partial "functions/get_icon" (dict "name" "video-camera" "attributes" "style=\"height: 1em\" class='inline-block'") }} | ||
{{ i18n "btn_video" }} | ||
</a> | ||
{{ end }} | ||
{{ with $page.Params.url_source }} | ||
{{ $resource := $page.Resources.GetMatch . }} | ||
{{ if $resource }} | ||
{{ $link = $resource.RelPermalink }} | ||
{{ else }} | ||
{{ $link = . | relURL }} | ||
{{ end }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ $link }}" target="_blank" rel="noopener"> | ||
{{ partial "functions/get_icon" (dict "name" "document" "attributes" "style=\"height: 1em\" class='inline-block'") }} | ||
{{ i18n "btn_source" }} | ||
</a> | ||
{{ end }} | ||
{{ with $page.Params.doi }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="https://doi.org/{{ . }}" target="_blank" rel="noopener"> | ||
DOI | ||
</a> | ||
{{ end }} | ||
{{ range $page.Params.links }} | ||
{{ $pack := or .icon_pack "fas" }} | ||
{{ $pack_prefix := $pack }} | ||
{{ if in (slice "fab" "fas" "far" "fal") $pack }} | ||
{{ $pack_prefix = "fa" }} | ||
{{ end }} | ||
{{ $link := .url | default "" }} | ||
{{ $scheme := (urls.Parse $link).Scheme }} | ||
{{ $target := "" }} | ||
{{ if not $scheme }} | ||
{{ $resource := $page.Resources.GetMatch $link }} | ||
{{ if $resource }} | ||
{{ $link = $resource.RelPermalink }} | ||
{{ else }} | ||
{{ $link = $link | relURL }} | ||
{{ end }} | ||
{{ else if in (slice "http" "https") $scheme }} | ||
{{ $target = "target=\"_blank\" rel=\"noopener\"" }} | ||
{{ end }} | ||
<a class="hb-attachment-link {{ if $is_list }}hb-attachment-small{{else}}hb-attachment-large{{end}}" href="{{ $link | safeURL }}" {{ $target | safeHTMLAttr }}> | ||
{{ partial "functions/get_icon" (dict "name" "link" "attributes" "style=\"height: 1em\" class='inline-block'") }} | ||
{{ if .icon }}<i class="{{ $pack }} {{ $pack_prefix }}-{{ .icon }} {{if .name}}mr-1{{end}}"></i>{{end}} | ||
{{- with .name }}{{ . | safeHTML }}{{ end -}} | ||
</a> | ||
{{ end }} |
12 changes: 12 additions & 0 deletions
12
modules/blox-tailwind/layouts/partials/page_links_div.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{/* Div wrapper around page links. */}} | ||
{{/* The wrapper is hidden when the page has no link buttons. */}} | ||
|
||
{{ $has_attachments := partial "functions/has_attachments" . }} | ||
{{ if $has_attachments | or .Params.external_link }} | ||
<div class=""> | ||
{{ with .Params.external_link }} | ||
<a class="btn btn-outline-primary my-1" href="{{ . }}" target="_blank" rel="noopener">{{ i18n "open_project_site" }}</a> | ||
{{ end }} | ||
{{ partial "page_links" (dict "page" . "is_list" 0) }} | ||
</div> | ||
{{ end }} |
Oops, something went wrong.