Calendar (#6)

Creates a (currently hidden) calendar page for me to show the events I am or might go to, with an invitation for others to get in touch if they want to join me.
This commit is contained in:
JP Hastings-Spital 2023-12-24 11:41:56 +00:00 committed by GitHub
parent ed3550f21f
commit 9fa87985e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 310 additions and 6 deletions

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
layouts/calendar/list.ics text eol=crlf

13
archetypes/calendar.md Normal file
View file

@ -0,0 +1,13 @@
---
title: "{{ replace .Name "-" " " | title }}"
emoji: ❓
date: {{ .Date }}
timings:
- starts: 2024-01-01T00:00Z
duration: P1H
link: https://...
location:
name:
latitude:
longitude:
---

View file

@ -130,7 +130,14 @@ date = ["date", "publishDate", "lastmod", ":git"]
[mediaTypes] [mediaTypes]
[mediaTypes.'text/opml'] [mediaTypes.'text/opml']
suffixes = ['opml'] suffixes = ['opml']
[mediaTypes.'text/calendar']
suffixes = ['ics']
[outputFormats] [outputFormats]
[outputFormats.opml] [outputFormats.opml]
mediaType = 'text/opml' mediaType = 'text/opml'
baseName = 'feeds' baseName = 'feeds'
[outputFormats.ics]
isPlainText = true
isHTML = false
mediaType = 'text/calendar'
baseName = 'events'

View file

@ -0,0 +1,10 @@
---
title: Calendar
emoji: 🗓️
outputs:
- html
- rss
- ics
---
I enjoy making new friends, and hanging out with the folks I already know and love. Below is a calendar of events I'm thinking of going to — if you'd like to come with me, get in touch and perhaps we can go together!

View file

@ -0,0 +1,20 @@
---
title: The Cable Street Rag Band
emoji: 🎻
date: 2023-12-22T12:27:13Z
timings:
- starts: 2023-12-21T20:30:00Z
duration: PT5H
link: https://www.ewanbleach.com/events/557688l959gl8pa-dflnz-2sykl-frkxa-f5p58-m2d3p-dybs2-kwew8-tjls6-94w7t-hytj4-mzjhe-z8zkw-f6hk4-x79yn-wlynt-6jtnm-tkwj3-rbyyk-pb4xx-bbdsh-35xpf-erye2-2nlxy-4cz4b-pme3d-gsb28
location:
name: Jamboree
latitude: 51.53052698618849
longitude: -0.1196719819977664
summary: A rag & swing band play jazz into the early hours.
---
> The Cable Street Rag Bands Thursday night residency at Jamboree. 1920s and 30s jazz and swing all night long with a jam session from 11:30 - 12:30.
>
> [Get your tickets here](https://www.wegottickets.com/event/598828/)
>
> [More Info](https://www.jamboreevenue.co.uk/events/limehouse-de-reverie-with-the-cable-street-rag-band-27/)

View file

@ -0,0 +1,18 @@
---
title: Whiskey Moon Face
emoji: 🪗
date: 2023-12-22T12:27:13Z
timings:
- starts: 2023-12-23T20:00:00Z
duration: PT3H
link: https://www.ewanbleach.com/events/2023/3/22/whiskey-moon-face-the-harrison-xgdwl-f9bnn-rhhjc-pxk77
location:
name: Larry's Live at the National Portrait Gallery
latitude: 51.50918934310175
longitude: -0.12754071312701715
summary: A delightful folk music band play in a cocktail bar at the national portrait gallery.
---
> Hidden behind a secret entrance on Charing Cross Road, Larrys is our brand-new underground cocktail bar located in the historic vaults of the National Portrait Gallery. Originally built as coal storage in 1896, the spectacular exposed brick space has been transformed offering a slice of elegance deep into the evening (seven days a week), just a short stroll from Covent Garden and Trafalgar Square. Sip on classic cocktails and dine on lavish bar snacks, amidst over 100 portraits of the famous faces of Londons West End.
>
> [More Info](https://www.daisygreenfood.com/location-larrys)

View file

@ -0,0 +1,17 @@
---
title: Interesting 2024
emoji: ✨
date: 2023-12-22T13:31:40Z
timings:
- starts: 2024-05-15T19:00:00+0100
duration: PT5H
link: https://www.eventbrite.com/e/interesting-2024-tickets-780721006547
location:
name: Conway Hall
latitude: 51.51972123177939
longitude: -0.11838331781213689
summary: Short talks about interesting things.
attending: true
---
> Short talks about interesting things. Same old same old.

View file

@ -0,0 +1,23 @@
---
title: Radical Left, LSE Library Archives Drop-in Session
emoji: 📖
date: 2023-12-22T12:27:13Z
timings:
- starts: 2024-01-24T16:00:00Z
duration: PT3H
link: https://www.lse.ac.uk/library/events/general/lse-library-archives-drop-in-session
location:
name: LSE Library Gallery
latitude: 51.514664134157435
longitude: -0.11572255524925255
summary: A tour of the development of Britain's radical left, told through the LSE Library's collection.
attending: [jp, yvette]
---
> Join us for an early evening sneak peek at the archives related to the radical left.
>
> Drop in to see some of our flagship collections on the theme of the early development of the British Left. On display will be items from anti-fascist activism, the Independent Labour Party, the Social Democratic Federation, anarchism, strikes, protests, and much more!
>
> You can also learn more from our friendly team of curators and archivists who will be on hand to answer any questions and talk more about using archives and special collections in your teaching, research or for personal interest.
>
> Book a place to register your interest and receive reminders about the day or just drop in and stay as long as you like!

3
data/friends/jp.yaml Normal file
View file

@ -0,0 +1,3 @@
name: JP
site: https://www.byjp.me
xfn: me

View file

@ -0,0 +1,45 @@
{{ define "main" }}
<main class="posts" {{ if eq .Kind "taxonomy" }}data-pagefind-ignore{{ end }}>
{{ partial "generic-list-header.html" . }}
<h1 class="p-name">
{{ with .Params.emoji }}<span data-emoji="{{.}}"></span>{{end}}
<a href="{{ .Permalink }}" class="noaccent u-url">{{ title (replace .Title "-" " ") }}</a>
</h1>
{{ if .Content }}
<div class="content" data-pagefind-body data-pagefind-filter="type:{{.Type | title}}">{{ .Content }}</div>
{{ end }}
{{ $events := dict }}
{{ range $page := .Data.Pages }}
{{ range $page.Params.timings }}
{{ $event := dict "Title" $page.Title "Page" $page.Page "Date" (time.AsTime .starts) }}
{{ if $event.Date.Before time.Now }}{{ continue }}{{ end }}
{{ $bundle := $event.Date.Format "Jan 2006" }}
{{ $events = merge $events (dict $bundle (sort ((index $events $bundle) | append $event) "Date" "asc")) }}
{{ end }}
{{ end }}
{{ range $key, $bundledEvents := $events }}
<div class="posts-group">
<div class="post-year">{{ $key }}</div>
<ul class="posts-list">
{{ range $bundledEvents }}
<li class="post-item">
<a href="{{.Page.RelPermalink}}">
{{ if .Page.Params.emoji }}<span class="post-emoji">{{ .Page.Params.emoji }}</span>{{ end }}
<span class="post-title">{{.Page.Title}}</span>
<span class="post-day">
{{ .Date.Format "Jan 2"}} {{ if or (lt (.Date.Format "15") 9) (gt (.Date.Format "15") 17) }}🌙{{ else }}🌞{{ end }}
</span>
</a>
</li>
{{ end }}
</ul>
</div>
{{ end }}
{{ partial "pagination-list.html" . }}
</main>
{{ end }}

33
layouts/calendar/list.ics Normal file
View file

@ -0,0 +1,33 @@
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
VERSION:2.0
PRODID:-//www.byjp.me
{{- range .Data.Pages}}
BEGIN:VEVENT
UID:byjp{{replace .Page.RelPermalink "/" "-"}}
DTSTAMP:{{ .Page.Date.UTC.Format "20060102T150405Z" }}
{{ with (index .Params.timings 0) -}}
DTSTART:{{ (time.AsTime .starts).UTC.Format "20060102T150405Z" }}
DURATION:{{ .duration }}
{{ end -}}
LOCATION:{{.Page.Params.location.name}}
GEO:{{.Page.Params.location.latitude}};{{.Page.Params.location.longitude}}
SUMMARY:{{.Page.Title}}
DESCRIPTION:{{ .Page.Summary | replaceRE "(.{62})(.*)" "$1\r\n $2" | replaceRE "( [^\r\n]{72})([^\r\n]*)" "$1\r\n $2" }}
URL:{{.Page.Params.link | replaceRE "(.{70})(.*)" "$1\r\n $2" | replaceRE "( [^\r\n]{72})([^\r\n]*)" "$1\r\n $2" }}
{{- $attendees := .Page.Params.attending -}}
{{- $jpDone := false -}}
{{- if eq .Page.Params.attending true}}{{ $attendees = slice "jp" }}{{ $jpDone = true }}{{ end -}}
{{ range $attendees -}}
{{- if eq . "jp" }}{{ $jpDone = true }}{{ end -}}
{{- with (index site.Data.friends .) }}
ATTENDEE;CUTYPE=INDIVIDUAL;CN={{ .name }} ({{site.Title}});
PARTSTAT=ACCEPTED:MAILTO:{{ .site }}
{{- end }}{{ end -}}
{{- if not $jpDone }}
ATTENDEE;CUTYPE=INDIVIDUAL;CN={{ site.Data.friends.jp.name }} ({{site.Title}};
PARTSTAT=NEEDS-ACTION:MAILTO:{{ site.Data.friends.jp.site }}
{{- end }}
END:VEVENT
{{- end }}
END:VCALENDAR

View file

@ -0,0 +1,101 @@
{{ define "main" }}
<main class="post h-event">
{{ $timing := index .Params.timings 0 -}}
{{ range .Params.timings -}}
{{ if (time.AsTime .starts).Before time.Now -}}
{{ $timing = . -}}
{{ end -}}
{{ end -}}
<article>
<hgroup class="post-title">
<h1 class="p-name">
{{ with .Params.emoji }}<span data-emoji="{{.}}"></span>{{end}}
<a href="{{ .Permalink }}" class="noaccent">{{ .Title | markdownify }}</a>
</h1>
</hgroup>
{{ with .Summary }}
<div class="post-summary p-summary" aria-hidden="true">{{ . }}</div>
{{ end }}
{{ if .Params.Cover }}
<figure class="post-cover">
<img src="{{ .Params.Cover | absURL }}" alt="{{ .Title }}" />
{{ if .Params.CoverCaption }}
<figcaption class="center">{{ .Params.CoverCaption | markdownify }}</figcaption>
{{ end }}
</figure>
{{ end }}
<div class="post-content p-description" data-pagefind-body data-pagefind-filter="type:{{.Type | title}}">
{{ .Content }}
</div>
</article>
<hr />
<div class="post-info">
{{ partial "tags.html" .Params.tags }}
<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-map-pin">
<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>
</svg>
At <a href="{{ partial "geolink.html" .Params.location }}" class="p-location h-geo" target="_blank">{{ .Params.location.name }}</a>
</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-calendar">
<rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
<line x1="16" y1="2" x2="16" y2="6"></line>
<line x1="8" y1="2" x2="8" y2="6"></line>
<line x1="3" y1="10" x2="21" y2="10"></line>
</svg>
On {{ partial "year-relative-date.html" (slice (time.AsTime $timing.starts) "dt-start") }}
</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">
<circle cx="12" cy="12" r="10"></circle>
<polyline points="12 6 12 12 16 14"></polyline>
</svg>
{{ $starts := time.AsTime $timing.starts }}
{{ $duration := ((strings.Substr $timing.duration 2) | strings.ToLower) }}
From {{ $starts.Format "15:04" }} until {{ $starts.Add (time.ParseDuration $duration) | dateFormat "15:04 (MST)" }} (<span class="dt-duration">{{ $duration }}</span>)
</p>
{{ if .Params.attending }}
<p class="attending">
<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-user-check"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path><circle cx="8.5" cy="7" r="4"></circle><polyline points="17 11 19 13 23 9"></polyline></svg>
{{ if eq .Params.attending true }}{{ partial "friend.html" "jp.no-emoji" }} is going
{{ else if eq (len .Params.attending) 1 }}
{{ partial "friend.html" (printf "%s.no-emoji" (index .Params.attending 0)) }} is going
{{ else }}
{{ $count := len .Params.attending}}
{{ range $i, $attendee := .Params.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
{{ end }}
</p>
{{ end }}
<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-link">
<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
</svg>
More info on <a href="{{.Params.link}}" class="u-url" target="_blank">{{ (urls.Parse .Params.link).Host }}</a>
</p>
</div>
<hr />
<div class="syndication">
{{ partial "syndication.html" . }}
</div>
{{ partial "pagination-single.html" . }}
</main>
{{ end }}

View file

@ -0,0 +1,6 @@
{{ $parts := strings.Split . "." }}
{{ with index site.Data.friends (index $parts 0) }}
<span class="h-card{{ range collections.Last (sub (len $parts) 1) $parts }} {{.}}{{ end }}"><a href="{{.site}}" rel="{{.xfn}}" class="u-url p-name" target="_blank">{{.name}}</a></span>
{{ else }}
{{ errorf "Could not display friend %s" . }}
{{ end }}

View file

@ -0,0 +1 @@
http://www.openstreetmap.org/?mlat={{.latitude}}&mlon={{.longitude}}&zoom=18&layers=M

View file

@ -1 +1,4 @@
<time timestamp="{{ . }}" title="{{ time . | dateFormat "2006-01-02 03:04 MST" }}">{{ time . | dateFormat "January 2" }}{{ if ne (time . | dateFormat "2006") (now | dateFormat "2006") }}, {{ time . | dateFormat "2006" }}{{ end }}</time> {{- $date := . -}}
{{- $extraClass := slice -}}
{{ if reflect.IsSlice . -}}{{ $date = index . 0 }}{{ $extraClass = index . 1 }}{{ end -}}
<time class="{{ with $extraClass }}{{.}}{{ end }}" timestamp="{{ $date }}" title="{{ time $date | dateFormat "2006-01-02 15:04 MST" }}">{{ time $date | dateFormat "January 2" }}{{ if ne (time $date | dateFormat "2006") (now | dateFormat "2006") }}, {{ time $date | dateFormat "2006" }}{{ end }}</time>

View file

@ -1,5 +1 @@
{{ with index .Site.Data.friends (.Get 0) }} {{ partial "friend.html" (.Get 0) }}
<span class="h-card"><a href="{{.site}}" rel="{{.xfn}}" class="u-url p-name" target="_blank">{{.name}}</a></span>
{{ else }}
{{ errorf "Could not display friend %s" (.Get 0) }}
{{ end }}

7
todo.md Normal file
View file

@ -0,0 +1,7 @@
Add single.html for Calendar {cm:2023-12-24}
Support repeating calendar events
Handle long lines {cm:2023-12-24}
Ensure ICS files have CRLF endings {cm:2023-12-22}
Add microformats {cm:2023-12-24}
Add lat & long to h-event p-location
Debug why h-event doesn't seem to be showing