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

Original post discovery: support for rel=alternate type=application/mf2+json #1569

Open
cybeardjm opened this issue Oct 11, 2023 · 6 comments
Labels

Comments

@cybeardjm
Copy link

Hi,

Been playing with the various IndieWeb and syndication features for WordPress today.

As it seems the old “Microformats2” plugin is not maintained anymore (doesn’t seem to work nice with the Twenty Twenty-Three theme anyway), I’m testing the MF2 Feeds plugin instead.

From the description: "Provides a Microformats2 JSON “Feed” for every WordPress URL, and helps to allow other sites to get pre-parsed Microformats-JSON even if the theme does not support Microformats2."

It generates these alternate links for posts:

<link rel="alternate" type="application/mf2+json" href="https://domain/sample-post/feed/mf2/" />
<link rel="alternate" type="application/jf2+json" href="https://domain/sample-post/feed/jf2/" />

But, they're not supported for discovery (so far, it seems) as alternate means to check for microformats in a post.
=> when I test a preview to publish on Mastodon, I get errors such as "Mastodon doesn't support type(s) h-cite, or no content was found." or "No h-entry found" (on a https://indiewebify.me/validate-h-entry/ test)

@snarfed
Copy link
Owner

snarfed commented Oct 11, 2023

Hmm, good idea! Right now we only support separate feeds with rel=feed, and only HTML: https://brid.gy/about#link . For other types like this, we probably wouldn't look for these URL paths specifically, and I doubt we'd add JF2 support, but we could maybe ingest MF2 via rel=alternate type=application/mf2+json.

Not a priority for me personally right now, but this would be a pretty reasonable first project if you want to contribute. Dev docs at https://bridgy.readthedocs.io/ , code for this would go somewhere around:

candidates = (author_mf2['rels'].get('feed', []) +
[a.get('url') for a in author_mf2.get('alternates', [])
if a.get('type') == MF2_HTML_MIME_TYPE])
for feed_url in candidates:
# check that it's html, not too big, etc
feed_url, _, feed_ok = util.get_webmention_target(feed_url)
if feed_url == author_url:
logger.debug('author url is the feed url, ignoring')
elif not feed_ok:
logger.debug("skipping feed since it's not HTML or otherwise bad")
else:
feed_urls.add(feed_url)
for feed_url in feed_urls:
try:
logger.debug(f"fetching author's rel-feed {feed_url}")
feed_mf2 = util.fetch_mf2(feed_url)
if not feed_mf2:
logger.debug('nothing found')
continue
feeditems = _merge_hfeeds(feeditems, _find_feed_items(feed_mf2))
domain = util.domain_from_link(feed_url)
if source.updates is not None and domain not in source.domains:
domains = source.updates.setdefault('domains', source.domains)
if domain not in domains:
logger.info(f'rel-feed found new domain {domain}! adding to source')
domains.append(domain)

@snarfed snarfed changed the title Support for /feed/mf2/ and/or /feed/jf2/ ? Original post discovery: support for rel=alternate type=application/mf2+json Oct 11, 2023
@cybeardjm
Copy link
Author

Thx @snarfed - unfortunately, am no dev, just an "advanced user", so wouldn't even try to mess with the code...
Ok, will wait till it works some day, will stick with ActivityPub 100% in the mean time...

@snarfed
Copy link
Owner

snarfed commented Oct 11, 2023

Np, we can keep it open!

@snarfed snarfed reopened this Oct 11, 2023
@dshanske
Copy link

I have another option we use in our Webmention plugin using the WordPress rest api... but someone would still need to implement.

@cybeardjm
Copy link
Author

OK, been playing with various plugins all day long, including Webmention, from various Fediverse apps...
Thx

@benharri
Copy link

This would be very handy as I haven't figured out a good way to get bridgy to read my wordpress feed. Might have a go at adding mf2+json support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants