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

Store webmentions using a known serialisation format #20

Open
paulrobertlloyd opened this issue Nov 10, 2023 · 4 comments
Open

Store webmentions using a known serialisation format #20

paulrobertlloyd opened this issue Nov 10, 2023 · 4 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@paulrobertlloyd
Copy link
Contributor

paulrobertlloyd commented Nov 10, 2023

Using getMentionsForPage, normalised objects are returned, but not in a specified or common format.

Mention data is currently normalised in a format that approximates JF2, but not for deeply nested properties, and uses non-standard values for type. This means it is not possible to query processed mentions, return mention data and convert it to a different format.

The use case for being able to covert mention data to different formats can be seen in indieweb/webmention-ecosystem#2, where there is a desire to return mentions with either mf2, JF2 or JSON Feed serialisations. I’d like to return mentions as JF2, at least initially, and potentially other formats in the future.

Unfortunately, the object normalisation takes place when mentions are processed, with the original mf2 parsing discarded. This means it's not possible to convert the mention data to JF2 (or mf2) with libraries that parse mf2, or without employing additional processing to convert the current serialisation to adhere to JF2.

Potential options

  • Store mf2 when processing mentions, and only do the conversion when using getMentionsForPage.
  • Use JF2 when processing mentions, and ensure the normalisation follows that specification.
  • Provide an option at the handler level to determine which serialisation format mentions are stored to the database with OR provide an option on the getMentionsForPage function to return a desired format (mf2 or JF2).

It would be useful to have a function to return all processed mentions, not just those for a given target, but I will create a separate PR for that.

@paulrobertlloyd paulrobertlloyd added the bug Something isn't working label Nov 10, 2023
@vandie vandie added enhancement New feature or request and removed bug Something isn't working labels Nov 10, 2023
@vandie
Copy link
Owner

vandie commented Nov 10, 2023

What's the use case?
Can you please also not label things as bugs when that's not what they are 😅

@paulrobertlloyd
Copy link
Contributor Author

paulrobertlloyd commented Nov 10, 2023

The bug label gets added by the new issue workflow and can’t be removed by an issue’s author.

I may have been a bit hasty with this issue; am trying to figure out how mentioned get saved/normalised. As I look at the different example webmentions that I’m testing with have been saved, it appears as if the normalisation only happens at the top level, and not for nested properties.

I have a library mf2tojf2 that normalises deeply nested MF2 objects; I can try creating a PR that uses that module?

@paulrobertlloyd paulrobertlloyd changed the title Return all webmentions using same normalisation algorithm Store webmentions using a known serialisation Nov 11, 2023
@paulrobertlloyd
Copy link
Contributor Author

I’ve updated my original comment to better describe my issue (hopefully!) and provide a link to some example use cases.

In the meantime, I’m going to implement the authorship spec on mf2tojf2, as it may be helpful to those converting from mf2 and JF2 for use in webmention parsing and processing.

@paulrobertlloyd paulrobertlloyd changed the title Store webmentions using a known serialisation Store webmentions using a known serialisation format Nov 11, 2023
@vandie
Copy link
Owner

vandie commented Nov 11, 2023

I think looking at it, option 2 makes the most sense but would be a breaking change both for users of this library as well as potentially for any storage implementations.

You're right in saying that this package currently uses a none standard format as it was built originally for my own use at a time when JF2 wasn't as common (with any similarities coming from the fact they're both rooted in MF2)

@vandie vandie added the help wanted Extra attention is needed label Nov 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants