- {{ if not $isPast }} + {{ if not $event.isPast }}

- {{ partial "svg.html" (dict "name" "calendar") }} I'm planning on going to this event on {{ partial "year-relative-date.html" (slice (time.AsTime $timing.starts) "dt-start") }}. + {{ partial "svg.html" (dict "name" "calendar") }} I'm planning on going to this event on {{ partial "year-relative-date.html" (slice (time.AsTime $event.timing.starts) "dt-start") }}. See the bottom of the post for more information.

{{ end }} @@ -62,7 +49,7 @@ - At {{ .name }} + At {{ .name }}

{{ end }}

@@ -72,29 +59,29 @@ - On {{ partial "year-relative-date.html" (slice (time.AsTime $timing.starts) "dt-start") }} - {{ with sub (len $timings) 1 }}{{ if gt . 0 }} (and {{ . }} other{{ if gt . 1}}s{{end}}){{ end }}{{ end }} + On {{ partial "year-relative-date.html" (slice (time.AsTime $event.timing.starts) "dt-start") }} + {{ with sub (len $event.timings) 1 }}{{ if gt . 0 }} (and {{ . }} other{{ if gt . 1}}s{{end}}){{ end }}{{ end }}

- {{ $starts := time.AsTime $timing.starts }} - {{ $durationStr := ((strings.Substr $timing.duration 1) | strings.ToLower) }} - {{ $duration := partial "iso8601.duration" $timing.duration }} + {{ $starts := time.AsTime $event.timing.starts }} + {{ $durationStr := ((strings.Substr $event.timing.duration 1) | strings.ToLower) }} + {{ $duration := partial "iso8601.duration" $event.timing.duration }} From {{ $starts.Format "15:04" }} until {{ $starts.Add $duration | dateFormat "15:04 (MST)" }} ({{ replace $durationStr "t" "" }})

- {{ if $timing.attending }} + {{ if $event.timing.attending }}

{{ partial "svg.html" (dict "name" "attending") }} - {{ if eq $timing.attending true }}{{ partial "friend.html" "jp.no-emoji" }} is going - {{ else if eq (len $timing.attending) 1 }} - {{ partial "friend.html" (printf "%s.no-emoji" (index $timing.attending 0)) }} is going + {{ if eq $event.timing.attending true }}{{ partial "friend.html" "jp.no-emoji" }} is going + {{ else if eq (len $event.timing.attending) 1 }} + {{ partial "friend.html" (printf "%s.no-emoji" (index $event.timing.attending 0)) }} is going {{ else }} - {{ $count := len $timing.attending}} - {{ range $i, $attendee := $timing.attending }} + {{ $count := len $event.timing.attending}} + {{ range $i, $attendee := $event.timing.attending }} {{ partial "friend.html" (printf "%s.no-emoji" $attendee) -}} {{- if eq $i (sub $count 2) }}{{ if gt $count 2 }},{{ end }} and {{ else if lt $i (sub $count 1) }}, {{ end }} {{ end }} are going diff --git a/layouts/partials/event.obj b/layouts/partials/event.obj new file mode 100644 index 00000000..1923f7d6 --- /dev/null +++ b/layouts/partials/event.obj @@ -0,0 +1,15 @@ +{{- $timings := slice -}} +{{- range . -}} + {{- if (time.AsTime .starts).After time.Now -}} + {{- $timings = $timings | append . -}} + {{- end -}} +{{- end -}} +{{- $timing := dict -}} +{{- $isPast := true -}} +{{- if gt (len $timings) 0 -}} + {{- $timing = index $timings 0 -}} + {{- $isPast = false -}} +{{- else -}} + {{- $timing = index . 0 -}} +{{- end -}} +{{- return (dict "timings" $timings "timing" $timing "isPast" $isPast) -}} diff --git a/layouts/partials/events.obj b/layouts/partials/events.obj new file mode 100644 index 00000000..ff6de471 --- /dev/null +++ b/layouts/partials/events.obj @@ -0,0 +1,11 @@ +{{- $events := dict -}} +{{- range $page := . -}} + {{- range $page.Params.timings -}} + {{- $event := dict "Title" $page.Title "Page" $page.Page "Date" (time.AsTime .starts) "Duration" (partial "iso8601.duration" .duration) -}} + {{- if $event.Date.Before time.Now }}{{ continue }}{{ end -}} + {{- $bundle := $event.Date.Format "2006-01" -}} + {{- $events = merge $events (dict $bundle (sort ((index $events $bundle) | append $event) "Date" "asc")) -}} + {{- break -}}{{/* Only show the first on the list */}} + {{- end -}} +{{- end -}} +{{- return $events -}} diff --git a/layouts/partials/geolink.html b/layouts/partials/geolink.url similarity index 100% rename from layouts/partials/geolink.html rename to layouts/partials/geolink.url diff --git a/layouts/partials/rich-link.html b/layouts/partials/rich-link.html index b28faa34..f5d3dd1c 100644 --- a/layouts/partials/rich-link.html +++ b/layouts/partials/rich-link.html @@ -1,9 +1,9 @@ {{- $url := .url -}} {{- $title := .Title -}} {{- $isExternal := strings.HasPrefix $url "http" -}} -{{- $text := .Text -}} +{{- $text := .Text | default $url -}} {{/* It pains me that Hugo doesn't have a urls.IsValid method, and has no error catching to allow me to try urls.Parse and catch failures */}} -{{- if gt (len (strings.FindRE `^https?:\/\/[A-z0-9_-]*?[:]?[A-z0-9_-]*?[@]?[A-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$` .Text)) 0 -}} +{{- if gt (len (strings.FindRE `^https?:\/\/[A-z0-9_-]*?[:]?[A-z0-9_-]*?[@]?[A-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$` $text)) 0 -}} {{- $url := urls.Parse $text -}} {{- $text = strings.TrimPrefix "www." $url.Hostname -}} {{- if lt (len $url.Path) 16 -}} diff --git a/todo.md b/todo.md index e568620d..8004569f 100644 --- a/todo.md +++ b/todo.md @@ -21,8 +21,8 @@ Things I might work on within my personal blog's software. - [ ] Remove http://gowal.la & https://4sq.com links and/or posts that are useless without them - [ ] Gemini?! - [x] Tags pages - - [ ] Calendar page - - [ ] Include link, location, date on event page + - [x] Calendar page + - [x] Include link, location, date on event page - [ ] Handle `

` in posts (example: ChefGPT) - [ ] Actually serve it up