plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
460 stars 624 forks source link

Internal links management/conversion: is there a better (safe) way to manage them? #2086

Open cekk opened 3 years ago

cekk commented 3 years ago

I'm struggling with internal links in Volto since the first day and i'm thinking about how we handle them in both frontend and backend.

The state of art is:

We're adding some additional complexity because in some of our websites we have some controlpanels with blocks and with internal links. We need to make same conversions here too.

These seems to me a lot of edge-cases where people (me) can miss something, forget to add right converters in some custom endpoints/fields, etc.

Is there a better solution to handle internal links in Plone/Volto? Especially in blocks.

Wild idea

This approach was good in early stages when we didn't have the object browser on text blocks, but now that we have it more or less everywhere why don't we directly send to Plone an url with internal uid so we don't need to parse/transform every single thing and make other catalog searches to get the uids? object browser entries have all the informations.

When we add new internal links in Volto we could:

we don't need to write custom serializers in restapi we could customize service render method to perform needed string substitutions (we have a json string there) based on standard pattern (resolveuid/uid) with the expanded url.

Plus: we could set into Plone registry the frontend url and use it to set right expanded url.

If we want to avoid last option, we could not transform anything in Plone and provide a new "resolveuid" endpoint that Volto could call to get the transformed url (but this means that volto will do a lot of new api calls for every page).

I don't know if i'm missing something but i feel that everything related to internal links is quite unstable or do not cover all possible use-cases.

tiberiuichim commented 3 years ago

I guess the original intention with Plone -> Volto as "full URLs" was due to the "client links"... So the router would see proper links instead of resolveuids.

tiberiuichim commented 3 years ago

How does the redirection work now? Can we use resolveuids in the client-side content and have the router location be replaced when the backend content arrives with a full "resolved" path?