Skip to content

Move content type replacement and if needed conversion to ChainedConverter - #1030

Merged
jvherweg merged 8 commits into
versions/3.0.0from
fix/conversion
Nov 8, 2021
Merged

jvherweg merged 8 commits into
versions/3.0.0from
fix/conversion

Conversation

@jvherweg

Copy link
Copy Markdown
Member

Closes #756, closes #834.

Related to #1024. Wanted to push this so it could be part of the discussion there.

This PR changes the TypedRepresentationConverter class functions so it's probably a major semver change? Will need to make sure this gets merged to the correct branch!

ChainedConverter now starts from a path of length 0 and potentially uses that if it is a good solution for the requested preferences. It also checks the canHandle call of its converters now (which requires us making dummy metadata unfortunately).

Updated the RdfToQuadConverter so it likes all inputs equally when generating quads. Otherwise the ContentTypeReplacer would change the turtle to trig first because trig had a higher value.

Stole the integration tests from #1024.

@RubenVerborgh RubenVerborgh added the semver.major Requires a major version bump label Nov 2, 2021

@RubenVerborgh RubenVerborgh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet 🔥🔥🔥

"@type": "WaterfallHandler",
"handlers": [
{ "@id": "urn:solid-server:default:MarkdownToHtmlConverter" },
{ "@id": "urn:solid-server:default:DynamicJsonToTemplateConverter" },

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why still this one though? Maybe just get rid of the waterfall?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DynamicJsonToTemplateConverter is a special case because its output types depend on the metadata of the incoming Representation (it extracts templates from that) so it doesn't work as a TypedRepresentationConverter unfortunately. Currently this one is only used to generate the HTML templates in the IDP component.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment made me realize that there actually is an issue with this converter now. If you request application/json from the IDP you're still going to get JSON, but if you request application/json, text/html;q=0.5 you're going to get html. It's easy to fix it in that class but it is unfortunate that this is not part of the conversion chain.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And application/json is obviously a lie, because the content type is more specific 🙂
But good to leave as-is.

@jvherweg
jvherweg changed the base branch from main to versions/3.0.0 November 5, 2021 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver.major Requires a major version bump

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Simplify converter chain to avoid duplication Make ContentTypeReplacer smarter

2 participants