plone.restapi icon indicating copy to clipboard operation
plone.restapi copied to clipboard

@site and @navroot endpoints

Open erral opened this issue 2 years ago • 29 comments

Fixes #1462

erral avatar Jul 29 '22 11:07 erral

@erral thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

mister-roboto avatar Jul 29 '22 11:07 mister-roboto

Deploy Preview for plone-restapi canceled.

Name Link
Latest commit 4b0626ac8559ee7b0877a769364d17e6b77dd2ef
Latest deploy log https://app.netlify.com/sites/plone-restapi/deploys/647a423d96caf300082c90c0

netlify[bot] avatar Jul 29 '22 11:07 netlify[bot]

@jenkins-plone-org please run jobs

erral avatar Jul 29 '22 12:07 erral

@jenkins-plone-org please run jobs

erral avatar Jul 31 '22 07:07 erral

@jenkins-plone-org please run jobs

erral avatar Jul 31 '22 16:07 erral

Sorry, but @site just returns a title? I would expect the whole site object information. Same for @navroot (even if it comes witth an URL). If its only the title I would name the endpoint @site-title or alike (similar for navroot).

jensens avatar Jul 31 '22 23:07 jensens

I initially thought of @site to have site-wide settings but at this point I see that I only need the title. In the @navroot we at least need the url and the title

erral avatar Aug 01 '22 05:08 erral

@cekk I have added some more settings to the @site endpoint:

  • Title
  • Logo URL (if defined)
  • robots_txt
  • image allowed sizes

I have a PR prepared in Volto that uses the logo defined in Plone to render it in Volto (https://github.com/plone/volto/pull/3537), I guess that using the robots.txt would not be that hard too.

Meanwhile I found a bug in plone.app.layout that does not correctly compute the navigation root title for the Plone Portal Object, and I am handling that there.

erral avatar Aug 02 '22 13:08 erral

@jenkins-plone-org please run jobs

erral avatar Aug 02 '22 14:08 erral

@jenkins-plone-org please run jobs

erral avatar Aug 03 '22 08:08 erral

cool. I can improve it with logo miniatures (the only missing thing) but i don't know if it's better to add it to this pr or wait to close this and add e new one.

cekk avatar Aug 04 '22 08:08 cekk

cool. I can improve it with logo miniatures (the only missing thing) but i don't know if it's better to add it to this pr or wait to close this and add e new one.

You can push to this branch if you want, no problem with that.

erral avatar Aug 04 '22 13:08 erral

Ok, my changes are more complexes than i remembered. I need to register some adapters and customize @@images view to work on the site root and logo field. I don't think that these could be changes that should be in restapi package, right? I should split them in several packages and i don't know if it will be ok.

Maybe the easiest way could be let this pr as is and customize @site endpoint in plone.volto

cekk avatar Aug 05 '22 08:08 cekk

That's fine for me then.

erral avatar Aug 05 '22 08:08 erral

Thanks for your documentation review @stevepiercy it was really useful!

erral avatar Aug 21 '22 11:08 erral

@jenkins-plone-org please run jobs

erral avatar Aug 21 '22 13:08 erral

@jenkins-plone-org please run jobs

erral avatar Aug 29 '22 10:08 erral

@jenkins-plone-org please run jobs

erral avatar Sep 01 '22 10:09 erral

I don't dare to rebase. Would you, @erral

ksuess avatar Sep 07 '22 06:09 ksuess

I will do.

erral avatar Sep 07 '22 06:09 erral

@jenkins-plone-org please run jobs

erral avatar Sep 13 '22 15:09 erral

@erral I just merged a reorganization of docs PR. See https://github.com/plone/plone.restapi/pull/1490 for a complete description, and https://github.com/plone/plone.restapi/pull/1490/files#diff-b1ac7029db5750e88b86b3cb22ffeb9a839080d7759471090d8c1eea349a9a02 for an example of necessary changes.

  • The two new endpoints docs files need to be moved into docs/src/endpoints
  • The paths to their tests need to be adjusted with another ../.
  • The meta HTML in the new endpoint docs needs to be tweaked.
  • The relevant index.md files need to be updated.

Please let me know. Thank you!

stevepiercy avatar Sep 14 '22 14:09 stevepiercy

ok i will have a look. I see that I have something to fix in one tests because of unpredictable UIDs, so I will look at it together

erral avatar Sep 14 '22 14:09 erral

I had to do some changes to the test setup to try to get the tests pass, I would like a review from someone who understands how the component registry stuff works.

We had a StaticUUIDGenerator that was pushed into the component registry in the setUp method of the documentation tests in order to have always predictable UUIDs to be dumped to the response files.

I had to move that registration into the layer configuration. The reason is that when showing the tests of this PR in the documetnation, I needed to show the UUID of a LRF in a multilingual site, and this LRF was created before the StaticUUIDGenerator was being registered, so each time I run the tests I got different UIDs for the LRF objects.

The changes are here:

Previous: https://github.com/plone/plone.restapi/pull/1465/files#diff-702e9e8621c4eb2b19904313c62308cdbf458b8290e0ff261b779ceaa9101b90)https://github.com/plone/plone.restapi/pull/1465/files#diff-702e9e8621c4eb2b19904313c62308cdbf458b8290e0ff261b779ceaa9101b90

My changes: https://github.com/plone/plone.restapi/pull/1465/files#diff-89c6e068b94d1fadf3e6d6da1706e489800b7ba147946fc647ed9ae1c093799c

This has the drawback that I had to recreate all the response files to reflect the new UIDs there.

Moreover I have one testing failure in local_roles serializer: https://github.com/plone/plone.restapi/blob/site-endpoint/src/plone/restapi/tests/test_content_local_roles.py#L583

This is somehow expected, according to the docstring of that test, because the test manipulates de global component registry unregistering an adapter and then re-registering it. I don't know how this works and why it fails.

I think that either @lukasgraf or @buchi wrote that StaticUUIDGenerator and its pushing to the component registry, but I haven't see them lately here... Perhaps @davisagli has played with something like that in the past?

@stevepiercy sorry, I need to look again to the docs and your reviews, do not review them again. After the merging of the new navigation I may be missing stuff or may have missed some of your comments.

erral avatar Sep 15 '22 14:09 erral

@stevepiercy sorry, I need to look again to the docs and your reviews, do not review them again. After the merging of the new navigation I may be missing stuff or may have missed some of your comments.

OK, please ping me when you are ready for me to review. Thank you!

stevepiercy avatar Sep 15 '22 18:09 stevepiercy

@jenkins-plone-org please run jobs

erral avatar Oct 10 '22 15:10 erral

I have reverted the changes on the testing setup, and commented the code that tests the endpoint in the LRF.

I think we should check the testing setup to produce stable UUIDs at all times in some other PR.

I saved the code in another branch, and try to push and test it in a separated PR.

erral avatar Oct 10 '22 15:10 erral

@jenkins-plone-org please run jobs

erral avatar Oct 11 '22 07:10 erral

@jenkins-plone-org please run jobs

erral avatar Oct 20 '22 10:10 erral

@jenkins-plone-org please run jobs

erral avatar Nov 27 '22 17:11 erral