digitalfabrik / integreat-cms

Simplified content management back end for the Integreat App - a multilingual information platform for newcomers
https://digitalfabrik.github.io/integreat-cms/
Apache License 2.0
55 stars 33 forks source link

Add previous_paths property to all pages endpoints #1587

Open steffenkleinle opened 2 years ago

steffenkleinle commented 2 years ago

Motivation

In the cms changes of the slug and therefore the path of pages are possible. This currently breaks opening of the previous urls in the native apps since a find by path fails.

Proposed Solution

A new property previous_paths: string[] should be added containing all previous valid paths. If there are no previous paths, the array should be empty. This property should especially be added for the pages endpoint but best also for the children, parents and single post endpoints.

Alternatives

None

Additional Context

This blocks https://issues.tuerantuer.org/browse/IGAPP-1050, please update the issue once this is done and released. For the web app this was not needed as we just used (for now) the current implementation of the children endpoint which returns the page with the correct new path as first item in the response even if queried with one of the previous paths, see https://github.com/digitalfabrik/integreat-app/pull/716.

timobrembeck commented 2 years ago

@steffenkleinle at the moment, we do not keep track of path changes when pages are moved or one of the parent pages is renamed, currently only changes of the slug are versioned. Do you think a field with previous slugs would suffice here, or do we have to go the extra mile and store the path history in our database as well?

steffenkleinle commented 2 years ago

@steffenkleinle at the moment, we do not keep track of path changes when pages are moved or one of the parent pages is renamed, currently only changes of the slug are versioned. Do you think a field with previous slugs would suffice here, or do we have to go the extra mile and store the path history in our database as well?

It would be easier and cleaner for us if we really had the complete paths and not just previous slugs since we solely use those to identify categories in both web and native. It would probably be possible to compare only the last path segment with previous slugs as well so depends a little bit on how much effort it is for you. The relative nature of slugs is not a problem since slugs are unique for a city/language combination, right?

timobrembeck commented 1 year ago

This would become obsolete by implementing:

steffenkleinle commented 1 year ago

This would become obsolete by implementing:

* [Add checker for internal links #2174](https://github.com/digitalfabrik/integreat-cms/issues/2174)

Sounds good to me, feel free to close this. This probably also means we can remove the logic we already have to handle previous paths after that is done? Not sure anymore what exactly we did there but if I remember correctly we did something.

I think this only fixes the problem for internal links, correct? Also print materials or third-party websites could link with old urls in which case we would still need this. Or was it always just about internal links?