willnorris / microformats

Go library for parsing microformats
https://pkg.go.dev/willnorris.com/go/microformats
MIT License
64 stars 6 forks source link

feat(ptd): add support for new types #23

Closed hacdias closed 10 months ago

hacdias commented 11 months ago

Adds the post type discovery algorithm to this package. I have it in my library, but I think that it might fit here better since its... Microformats. It is a slightly augmented version compared to the original, as it checks for other post types too.

--

Thanks @nekr0z for asking me I had thought about making a PR here.

willnorris commented 11 months ago

this is already implemented in the ptd package: https://pkg.go.dev/willnorris.com/go/microformats/ptd . If you want to add support for additional types, add them there? Though I'd also want to see how closely those additional types match what is used in the wild, and/or other microformat parsers.

hacdias commented 11 months ago

Oh, I have no idea how I missed the sub-package. I will take a better look and update the PR.

Though I'd also want to see how closely those additional types match what is used in the wild, and/or other microformat parsers.

Regarding that, indeed I'm not sure how common we'll find them in the wild. The post types do exist, but are not considered for the algorithm. My personal case before, when I implemented this, was to not allow certain post types.

https://micropublish.net/ for example has support for most of the post types.

hacdias commented 11 months ago

@willnorris I updated the PR to only add support for recipe, review and audio. The following I did not add: bookmark, follow, read, watch, listen, checkin, ate, drank, itinerary. They do exist in the wild, I would say bookmark and checkins being the most common.

XRay for example gives those post-types. Some posts you can try:

XRay seems to also have support for bookmark, checkin and follows:

https://github.com/aaronpk/XRay/blob/9c0a8ba48b3328a8bc290a4dbeaf9cfd0c891ef5/lib/XRay/PostType.php#L26-L33

I can add those if desired, and leave the other ones out.

codecov-commenter commented 11 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (3f6d1e0) 100.00% compared to head (23e996c) 98.28%. Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #23 +/- ## =========================================== - Coverage 100.00% 98.28% -1.72% =========================================== Files 4 5 +1 Lines 843 935 +92 =========================================== + Hits 843 919 +76 - Misses 0 11 +11 - Partials 0 5 +5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

willnorris commented 11 months ago

oops... looks like I had email notifications for this repo getting filtered so I didn't see your reply 😕

In any event, this looks great. And I'd be down with adding the other that XRay supports as well. Though interestingly, I don't think XRay has different methods for PostType and ReplyType, which is how the spec breaks it out. For things like bookmark-of and follow-of, I think those should be in ReplyType here in the go library.

hacdias commented 11 months ago

@willnorris just pushed an addition for bookmark-of. I also wanted to add follow-of and checkin. But I have some thoughts:

willnorris commented 11 months ago

I think just checking for existence is fine in both cases. If those properties are present, then I think the intent is clear.

hacdias commented 11 months ago

@willnorris updated :) I think it should be ready.

hacdias commented 11 months ago

Ping @willnorris

willnorris commented 10 months ago

Sorry, still haven't fixed my mail filter for GitHub notifications 😱 Thanks for adding this!