Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ add h-event microformat markup #93

Merged
merged 2 commits into from
Feb 17, 2023

Conversation

chilledtonic
Copy link
Contributor

As referenced in #90

Added the invisible class names that make up the microformat requirements for an "h-event"

http://microformats.org/wiki/h-event

Including:

  • p-name
  • p-summary
  • dt-duration
  • p-location
  • u-url

I tested it using the Go Microformats Parser: https://go.microformats.io
And it parses and renders correctly!

@lowercasename
Copy link
Owner

This looks great; my only concern is that the element dt-duration has no easily machine readable data. Perhaps it would be more useful to render two <time> elements with display:none;, one for dt-start and one for dt-end. Those can then have datetime properties which will conform to a machine-readable format. Or they could be <data> elements, a little like this example linked from the microformats wiki: https://events.oauth.net/. There's some information on the <time> element here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time#attr-datetime

@chilledtonic
Copy link
Contributor Author

That makes sense. In previous use I've done <time>, so that's what I'll do for this as well.

To clarify, which Expression will give me a parseable timestamp? I confess to not being super experienced with Handlebars.

@lowercasename
Copy link
Owner

That's alright, first time for everything! It looks like we already generate a machine-readable timestamp on the server here and pass it through to Handlebars here. We don't seem to use it in the actual Handlebars file!

The only thing is that that gives us the times in UTC, which is probably less helpful that providing them in their local timezone. So I'd change those lines to eventStartISO = moment.tz(event.start, event.timezone).toISOString(), and check to make sure that the timezone is coming up as expected.

@lowercasename
Copy link
Owner

In the <time datetime=""> field, they should end up looking like one of these (from the MDN docs):

2011-11-18T14:54:39.929Z

2011-11-18T14:54:39.929-0400

2011-11-18T14:54:39.929-04:00

2011-11-18 14:54:39.929Z

2011-11-18 14:54:39.929-0400

2011-11-18 14:54:39.929-04:00

Added two invisible <time> tags which allow for microformat parsing of dt-start & dt-end
@chilledtonic
Copy link
Contributor Author

chilledtonic commented Feb 6, 2023

I added two invisible <time> tags, one for dt-start, the other for dt-end.

I didn't adjust the eventStartISO and eventEndISO scripts to use the user set timezone, since .toISOString() will always set it back to UTC anyways.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString

I dug through the spec, and couldn't find any specific guidelines for this situation. I don't think this is an issue, since any microformats reader parsing an h-event should compensate for the reading users TZ anyways.

For reference: https://indieweb.org/datetime

I checked the final rendered page against this parser, again: https://go.microformats.io/
And everything renders normally.

This covers all the basic properties of an h-event; if gathio ever adds long/lat, or another way to do Location lookup, it might be worth looking at h-geo down the line.

http://microformats.org/wiki/h-geo

@lowercasename
Copy link
Owner

Very happy to merge this, thank you!

@lowercasename lowercasename merged commit a75aad7 into lowercasename:master Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants