-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Pattern Directory: Create endpoints to proxy api.w.org/patterns. #26578
Pattern Directory: Create endpoints to proxy api.w.org/patterns. #26578
Conversation
051ac57
to
196765f
Compare
@TimothyBJacobs , heads up about this, in case you have any early feedback or thoughts. |
The phpunit-watcher stuff is just cherry-picked from #27058, for convenience. I'll remove it before publishing the PR. |
What's the difference between |
The "get" endpoint is for browsing, like https://api.wordpress.org/patterns/1.0/?action=get_patterns or https://api.wordpress.org/patterns/1.0/?action=get_patterns&category=2. The response format is different; the The api.w.org code is at https://meta.trac.wordpress.org/browser/sites/trunk/api.wordpress.org/public_html/patterns/1.0/index.php?rev=10414 I imagined that |
Ah, gotcha.
That'd be great! |
The Core endpoint expects it, so that search and browse responses have identical schemas. See WordPress/gutenberg#26578 git-svn-id: https://meta.svn.wordpress.org/sites/trunk@10459 74240141-8908-4e6f-9713-ba540dce6ec7
766b544
to
45c7dec
Compare
The e2e test failure looks unrelated. |
Should this go behind a feature flag or experimental namespace until the other parts of the pattern directory are implemented? |
From a REST API perspective, I think it should have an experimental namespace. Whether it also needs to be behind a feature flag, I'm not sure. Maybe @youknowriad has thoughts about which features warrant that behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor bits of feedback.
Is there a bit more context of how the patterns structure is setup on .org? Looking just at |
Thanks for the review!
👍🏻 That, and all the line-specific comments should be addressed in a45327f9f540356ce7b5f6ce402b9694a9704fd2.
Ah, that makes sense, I'll work on simplifying that. Thanks! |
Only one post type is being searched, so this is much simpler. See WordPress/gutenberg#26578 (comment) git-svn-id: https://meta.svn.wordpress.org/sites/trunk@10572 74240141-8908-4e6f-9713-ba540dce6ec7
I updated api.w.org to no longer use |
Do we still need two separate endpoints in Gutenberg at this point? |
This seems good to me. |
Ah, 👍🏻 The schemas will need to match. Local patterns have Locally, |
There really isn't a local install flow, the block code is just inserted when you click the pattern. (there has been some discussion about saving/favoriting patterns on wp.org, but we don't have that wp.org user connection on local WP sites, so the idea's been pushed off to later iterations) You make a good point about categories though, we'll need some way of getting the categories list off wp.org + the local site to populate the category dropdown here: On the wp.org side I've been assuming that's a static list of categories, but I don't think we want to make that assumption in the editor - that way we can add categories to wp.org without having to change Gutenberg. |
👍🏻 , I think that'd be best scoped to a separate PR. I opened #28204 to track it. |
In light of that, I think we might want to go back to |
Do you mean renaming the current |
Renaming the current |
👍🏻 , I'll do that, and normalize the local/remote schemas. I don't think we should combine the local/remote patterns in this PR, though, since it opens a can of worms. I added #28248 for that. I think we should merge this once any final requests are done, and do the rest in separate PRs. |
That latest batch of commits depends on some updates to w.org/patterns and api.w.org that I haven't finished & deployed yet. the test fixtures are updates to reflect the upcoming changes, though. i'll leave a note when the w.org endpoints are updated. |
@TimothyBJacobs , is 5b92da59f52e91b847c2ea1312061472ea27855d the right way to do validation for the response? I dug through the docs, examples, etc, but just confused myself, and couldn't get |
Yeah, all the built in validation/sanitization handling is for request data. We don't apply that level of sanitization in the block directory, but 🤷. |
🤔 , it seems like a "better safe than sorry" situation to me. I wouldn't want Core to trust input any other remote APIs. |
@TimothyBJacobs, Do you feel like this is ready to merge from an API perspective? @youknowriad, would you like this behind a feature flag? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some small bits of feedback.
Since this is a PHP change that is only backported explicitly into Core. I don't think it should necessarily be behind a feature flag. We can include in Core when we think it's ready or when it's being used by the frontend. |
Thanks, that sounds good 👍🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me!
Similar to the Block Directory, the endpoints in Gutenberg proxy the api.wordpress.org endpoints, to prevent w.org from receiving the user's IP address. This will also be necessary in the future to combine locally-registered patterns with those hosted in the wordpress.org directory. Fixes WordPress#26577
cc5ad75
to
5303e4e
Compare
👍🏻 thanks for the review! I squashed all the WIP commits down, and rebased against |
Looks great, merged. |
Thanks! |
Awesome to see this progress :) |
Fixes #26577
Description
This adds API endpoints to browse and search for patterns. Similar to the Block Directory, the endpoints in Gutenberg proxy the api.wordpress.org endpoints, to prevent w.org from receiving the user's IP address.
How has this been tested?
Types of changes
New feature
Checklist: