-
Notifications
You must be signed in to change notification settings - Fork 275
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
Add puzzle API #1372
Add puzzle API #1372
Conversation
- SiteGround | ||
- Yoast | ||
If the text is invalid, don't return it. | ||
If you do not see puzzle pieces of paper with valid text on them, simply output 'NO'", |
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.
Will the "NO" be seen by humans, or is it a value for an app to interpret? If it will be seen by people, perhaps something like "Unrecognized" would sound more gentle.
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.
No, this is internal. We only show a message if a piece was successfully recognized.
@@ -229,6 +229,30 @@ function playground_maybe_set_environment( $requested_path ) { | |||
return true; | |||
} | |||
|
|||
if (str_ends_with($requested_path, 'puzzle.php')) { |
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.
if (str_ends_with($requested_path, 'puzzle.php')) { | |
if (str_ends_with($requested_path, '/puzzle.php')) { |
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.
I agree with this change. The rest in this function ought to have been given preceding slashes as well. I think there was a reason for omitting them like an impression I got from one of the htaccess files. But it probably matches our intent to give them all preceding slashes.
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.
LGTM. What do you think @brandonpayton ?
It moves the [Playground puzzle app](https://github.com/bgrgicak/playground-puzzle) into a Playground package. ## What problem is it solving? It enables us to deploy the puzzle app to the Playground server. ## How is the problem addressed? By creating a new Playground package and updating the code to work with Vite. ## Testing Instructions - Follow the readme instructions to start a dev server - Setup the [puzzle API using these instructions](#1372) - [Update this line ](https://github.com/WordPress/wordpress-playground/pull/1385/files#diff-36e03a13c2f651337a0595e14c5aacbcd9e41ed263b271d973d0b0ef6425016fR1)to point to your development API - Open the app and click on _Build your site_ - Write [one of the action keys](https://github.com/WordPress/wordpress-playground/pull/1385/files#diff-ea60a008cc4118065c2be0703f529a8f2176ad4b38504f94fd68d25550892177R21) like _multisite_ on a piece of paper (text should be clear and bold) - Scan it - Confirm that an action was added - Click on _Take me to my site_ - Confirm that the site load and the actions were applied **Note let's address design feedback and improvements in separate PRs to unblock sponsors from updating their blueprints**
|
||
$secrets = new Atomic_Persistent_Data; | ||
if (isset( | ||
$secrets->OPEN_AI_API_KEY, |
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.
@bgrgicak I can help set the secrets until we can get a hosting dashboard that is available to the whole team. Please just ping me when you want to set them.
if (!isset($_POST["api_key"])) { | ||
response("error", "Please provide an API key."); | ||
} | ||
if ($_POST["api_key"] !== $api_key) { |
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.
Where will our users be getting this API key? I apologize if I've missed discussion about this elsewhere.
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.
It's hardcoded here.
It's only purpose is to allow us to disable the API in case we start having problems.
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.
Thanks! I will send you the details.
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.
I have not tested this, but in reading the code, I don't have any concerns except for one question asked as a "single comment".
What is this PR doing?
It adds an API for the Playground puzzle app.
What problem is it solving?
It allows the Playground puzzle app to communicate with OpenAI.
How is the problem addressed?
By creating a PHP API.
Testing Instructions