mirror of
https://github.com/by-jp/www.byjp.me.git
synced 2025-08-09 22:16:07 +01:00
Gemini: Fix calendar pages
This commit is contained in:
parent
26e57ca402
commit
9afb94536e
12 changed files with 87 additions and 48 deletions
|
@ -197,10 +197,11 @@ date = ["date", "publishDate", "lastmod", ":git"]
|
||||||
|
|
||||||
[outputs]
|
[outputs]
|
||||||
home = ["html", "rss", "gemini"]
|
home = ["html", "rss", "gemini"]
|
||||||
|
page = ["html", "gemini"]
|
||||||
|
rss = ["rss"]
|
||||||
section = ["html", "rss", "gemini"]
|
section = ["html", "rss", "gemini"]
|
||||||
taxonomy = ["html", "rss", "gemini"]
|
taxonomy = ["html", "rss", "gemini"]
|
||||||
term = ["html", "rss", "gemini"]
|
term = ["html", "rss", "gemini"]
|
||||||
page = ["html", "gemini"]
|
|
||||||
|
|
||||||
[minify]
|
[minify]
|
||||||
[minify.tdewolff]
|
[minify.tdewolff]
|
||||||
|
|
|
@ -3,6 +3,7 @@ title: Calendar
|
||||||
emoji: 🗓️
|
emoji: 🗓️
|
||||||
outputs:
|
outputs:
|
||||||
- html
|
- html
|
||||||
|
- gemini
|
||||||
- calendar
|
- calendar
|
||||||
- rss
|
- rss
|
||||||
summary: Some events I'm thinking of going to — get in touch if you'd like to join me!
|
summary: Some events I'm thinking of going to — get in touch if you'd like to join me!
|
||||||
|
|
|
@ -2,15 +2,15 @@
|
||||||
# Postscript
|
# Postscript
|
||||||
|
|
||||||
{{- $type := .Type -}}
|
{{- $type := .Type -}}
|
||||||
{{- $paginateType := (partial "article-type.txt" (default "page" $type)) | pluralize -}}
|
{{- $paginateType := (partial "article-type.txt" (default "page" $type)) -}}
|
||||||
{{- with .NextInSection }}
|
{{- with .NextInSection }}
|
||||||
=> {{ .RelPermalink }} Next post: {{ partial "page-title.txt" . }}{{ end }}
|
=> {{ .RelPermalink }} Next {{ $paginateType }}: {{ partial "page-title.txt" . }}{{ end }}
|
||||||
{{- with .PrevInSection }}
|
{{- with .PrevInSection }}
|
||||||
=> {{ .RelPermalink }} Previous post: {{ partial "page-title.txt" . }}{{ end }}
|
=> {{ .RelPermalink }} Previous {{ $paginateType }}: {{ partial "page-title.txt" . }}{{ end }}
|
||||||
{{ if eq .Kind "section" }}{{ with .Paginator.Next }}
|
{{ if eq .Kind "section" }}{{ with .Paginator.Next }}
|
||||||
=> {{ .URL }} Next page of {{ $paginateType }}{{ end }}
|
=> {{ .URL }} Next page of {{ $paginateType | pluralize }}{{ end }}
|
||||||
{{- with .Paginator.Prev }}
|
{{- with .Paginator.Prev }}
|
||||||
=> {{ .URL }} Previous page of {{ $paginateType }}{{ end }}{{ end }}
|
=> {{ .URL }} Previous page of {{ $paginateType | pluralize }}{{ end }}{{ end }}
|
||||||
=> https://www.byjp.me{{ replace .RelPermalink "index.gmi" "" }} View this page on the WWW
|
=> https://www.byjp.me{{ replace .RelPermalink "index.gmi" "" }} View this page on the WWW
|
||||||
|
|
||||||
{{ $dateType := "published" -}}
|
{{ $dateType := "published" -}}
|
||||||
|
@ -26,6 +26,8 @@ This {{ partial "article-type.txt" (default "page" $type) }} was {{ $dateType }}
|
||||||
{{- with .Params.tags }}
|
{{- with .Params.tags }}
|
||||||
|
|
||||||
I've not quite figured out if hashtags are useful in a Gemini context, but this post was tagged with{{ range (. | sort) }} #{{ . }}{{ end -}}.
|
I've not quite figured out if hashtags are useful in a Gemini context, but this post was tagged with{{ range (. | sort) }} #{{ . }}{{ end -}}.
|
||||||
|
|
||||||
|
=> /tags/ 🔗 List of all hashtags
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
You may also want to visit:
|
You may also want to visit:
|
||||||
|
|
18
layouts/calendar/list.gmi
Normal file
18
layouts/calendar/list.gmi
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{{- define "main" -}}
|
||||||
|
# {{ with .Params.emoji }}{{.}} {{end}}{{ title (replace .Title "-" " ") }}
|
||||||
|
|
||||||
|
{{- with .Page.RenderShortcodes }}
|
||||||
|
{{- partial "markdown.gmi" . -}}{{ end }}
|
||||||
|
|
||||||
|
{{ range $bundledEvents := (partial "events.obj" .Data.Pages) -}}
|
||||||
|
## {{ (index $bundledEvents 0).Date.Format "Jan 2006" }}
|
||||||
|
{{ range $bundledEvents -}}
|
||||||
|
{{- $hour := .Date.Format "15" -}}
|
||||||
|
{{- $duration := .Duration.Hours -}}
|
||||||
|
{{- $span := "eve" }}
|
||||||
|
{{- if and (gt $hour 9) (lt $hour 17) }}{{ $span = "day" }}{{ end -}}
|
||||||
|
{{- if ge $duration 24 }}{{ $span = "multi-day" }}{{ end -}}
|
||||||
|
=> {{ .Page.RelPermalink }} {{ with .Page.Params.emoji }}{{ . }} {{ end }}{{.Page.Title}} ({{ .Date.Format "Jan 2"}}, {{ $span }})
|
||||||
|
{{ end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
|
@ -14,16 +14,7 @@
|
||||||
<div class="content" data-pagefind-body data-pagefind-filter="type:{{.Type | title}}">{{ .Content }}</div>
|
<div class="content" data-pagefind-body data-pagefind-filter="type:{{.Type | title}}">{{ .Content }}</div>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ $events := dict }}
|
{{ $events := partial "events.obj" .Data.Pages }}
|
||||||
{{ range $page := .Data.Pages }}
|
|
||||||
{{ 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 }}
|
|
||||||
|
|
||||||
{{ range $bundledEvents := $events }}
|
{{ range $bundledEvents := $events }}
|
||||||
<div class="posts-group">
|
<div class="posts-group">
|
||||||
|
|
13
layouts/calendar/single.gmi
Normal file
13
layouts/calendar/single.gmi
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{{- define "main" -}}
|
||||||
|
# {{ with .Params.emoji }}{{.}} {{end}}{{ .Title | default (partial "page-title.txt" .) }}
|
||||||
|
|
||||||
|
{{ $event := partial "event.obj" .Params.timings -}}
|
||||||
|
{{ .Summary | htmlUnescape }}
|
||||||
|
{{- $starts := time.AsTime $event.timing.starts }}
|
||||||
|
I{{ if $event.isPast }} was{{ else }}'m{{ end }} planning on going to this event on {{ partial "year-relative-date.txt" $starts }}, from {{ $starts.Format "15:04 (MST)" }}.
|
||||||
|
{{ with .Params.location }}
|
||||||
|
=> {{ partial "geolink.url" . }} Location: {{ .name }}{{ end -}}
|
||||||
|
{{- with .Params.link }}
|
||||||
|
=> {{ . }} More info on: {{ strings.TrimPrefix "www." (urls.Parse .).Hostname }}{{ end }}
|
||||||
|
{{ partial "markdown.gmi" .Page.RenderShortcodes -}}
|
||||||
|
{{- end -}}
|
|
@ -2,20 +2,7 @@
|
||||||
<main class="post h-event">
|
<main class="post h-event">
|
||||||
{{ partial "memex-header.html" . }}
|
{{ partial "memex-header.html" . }}
|
||||||
|
|
||||||
{{ $timings := slice -}}
|
{{ $event := partial "event.obj" .Params.timings }}
|
||||||
{{ range .Params.timings -}}
|
|
||||||
{{ 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 .Params.timings 0 }}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
<hgroup class="post-title">
|
<hgroup class="post-title">
|
||||||
|
@ -40,9 +27,9 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<div class="post-content p-description" data-pagefind-body data-pagefind-filter="type:{{.Type | title}}">
|
<div class="post-content p-description" data-pagefind-body data-pagefind-filter="type:{{.Type | title}}">
|
||||||
{{ if not $isPast }}
|
{{ if not $event.isPast }}
|
||||||
<p class="next-visit">
|
<p class="next-visit">
|
||||||
{{ 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.
|
See the bottom of the post for more information.
|
||||||
</p>
|
</p>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -62,7 +49,7 @@
|
||||||
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
|
<path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
|
||||||
<circle cx="12" cy="10" r="3"></circle>
|
<circle cx="12" cy="10" r="3"></circle>
|
||||||
</svg>
|
</svg>
|
||||||
At <a href="{{ partial "geolink.html" . }}" class="p-location h-geo" target="_blank"><span class="p-name">{{ .name }}</span><span class="hidden" aria-hidden> (<span class="p-latitude">{{ .latitude }}</span>, <span class="p-longitude">{{ .longitude }}</span>)</span></a>
|
At <a href="{{ partial "geolink.url" . }}" class="p-location h-geo" target="_blank"><span class="p-name">{{ .name }}</span><span class="hidden" aria-hidden> (<span class="p-latitude">{{ .latitude }}</span>, <span class="p-longitude">{{ .longitude }}</span>)</span></a>
|
||||||
</p>{{ end }}
|
</p>{{ end }}
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
@ -72,29 +59,29 @@
|
||||||
<line x1="8" y1="2" x2="8" y2="6"></line>
|
<line x1="8" y1="2" x2="8" y2="6"></line>
|
||||||
<line x1="3" y1="10" x2="21" y2="10"></line>
|
<line x1="3" y1="10" x2="21" y2="10"></line>
|
||||||
</svg>
|
</svg>
|
||||||
On {{ partial "year-relative-date.html" (slice (time.AsTime $timing.starts) "dt-start") }}
|
On {{ partial "year-relative-date.html" (slice (time.AsTime $event.timing.starts) "dt-start") }}
|
||||||
{{ with sub (len $timings) 1 }}{{ if gt . 0 }} (and {{ . }} other{{ if gt . 1}}s{{end}}){{ end }}{{ end }}
|
{{ with sub (len $event.timings) 1 }}{{ if gt . 0 }} (and {{ . }} other{{ if gt . 1}}s{{end}}){{ end }}{{ end }}
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clock">
|
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-clock">
|
||||||
<circle cx="12" cy="12" r="10"></circle>
|
<circle cx="12" cy="12" r="10"></circle>
|
||||||
<polyline points="12 6 12 12 16 14"></polyline>
|
<polyline points="12 6 12 12 16 14"></polyline>
|
||||||
</svg>
|
</svg>
|
||||||
{{ $starts := time.AsTime $timing.starts }}
|
{{ $starts := time.AsTime $event.timing.starts }}
|
||||||
{{ $durationStr := ((strings.Substr $timing.duration 1) | strings.ToLower) }}
|
{{ $durationStr := ((strings.Substr $event.timing.duration 1) | strings.ToLower) }}
|
||||||
{{ $duration := partial "iso8601.duration" $timing.duration }}
|
{{ $duration := partial "iso8601.duration" $event.timing.duration }}
|
||||||
From {{ $starts.Format "15:04" }} until {{ $starts.Add $duration | dateFormat "15:04 (MST)" }} (<span class="dt-duration">{{ replace $durationStr "t" "" }}</span>)
|
From {{ $starts.Format "15:04" }} until {{ $starts.Add $duration | dateFormat "15:04 (MST)" }} (<span class="dt-duration">{{ replace $durationStr "t" "" }}</span>)
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{{ if $timing.attending }}
|
{{ if $event.timing.attending }}
|
||||||
<p class="attending">
|
<p class="attending">
|
||||||
{{ partial "svg.html" (dict "name" "attending") }}
|
{{ partial "svg.html" (dict "name" "attending") }}
|
||||||
{{ if eq $timing.attending true }}{{ partial "friend.html" "jp.no-emoji" }} is going
|
{{ if eq $event.timing.attending true }}{{ partial "friend.html" "jp.no-emoji" }} is going
|
||||||
{{ else if eq (len $timing.attending) 1 }}
|
{{ else if eq (len $event.timing.attending) 1 }}
|
||||||
{{ partial "friend.html" (printf "%s.no-emoji" (index $timing.attending 0)) }} is going
|
{{ partial "friend.html" (printf "%s.no-emoji" (index $event.timing.attending 0)) }} is going
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ $count := len $timing.attending}}
|
{{ $count := len $event.timing.attending}}
|
||||||
{{ range $i, $attendee := $timing.attending }}
|
{{ range $i, $attendee := $event.timing.attending }}
|
||||||
{{ partial "friend.html" (printf "%s.no-emoji" $attendee) -}}
|
{{ 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 }}
|
{{- if eq $i (sub $count 2) }}{{ if gt $count 2 }},{{ end }} and {{ else if lt $i (sub $count 1) }}, {{ end }}
|
||||||
{{ end }} are going
|
{{ end }} are going
|
||||||
|
|
15
layouts/partials/event.obj
Normal file
15
layouts/partials/event.obj
Normal file
|
@ -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) -}}
|
11
layouts/partials/events.obj
Normal file
11
layouts/partials/events.obj
Normal file
|
@ -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 -}}
|
|
@ -1,9 +1,9 @@
|
||||||
{{- $url := .url -}}
|
{{- $url := .url -}}
|
||||||
{{- $title := .Title -}}
|
{{- $title := .Title -}}
|
||||||
{{- $isExternal := strings.HasPrefix $url "http" -}}
|
{{- $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 */}}
|
{{/* 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 -}}
|
{{- $url := urls.Parse $text -}}
|
||||||
{{- $text = strings.TrimPrefix "www." $url.Hostname -}}
|
{{- $text = strings.TrimPrefix "www." $url.Hostname -}}
|
||||||
{{- if lt (len $url.Path) 16 -}}
|
{{- if lt (len $url.Path) 16 -}}
|
||||||
|
|
4
todo.md
4
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
|
- [ ] Remove http://gowal.la & https://4sq.com links and/or posts that are useless without them
|
||||||
- [ ] Gemini?!
|
- [ ] Gemini?!
|
||||||
- [x] Tags pages
|
- [x] Tags pages
|
||||||
- [ ] Calendar page
|
- [x] Calendar page
|
||||||
- [ ] Include link, location, date on event page
|
- [x] Include link, location, date on event page
|
||||||
- [ ] Handle `<details>` in posts (example: ChefGPT)
|
- [ ] Handle `<details>` in posts (example: ChefGPT)
|
||||||
- [ ] Actually serve it up
|
- [ ] Actually serve it up
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue