Skip to content
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

GIF Block: Replace source with Tumblr GIF Search #39896

Open
wants to merge 13 commits into
base: trunk
Choose a base branch
from

Conversation

justinshreve
Copy link
Contributor

@justinshreve justinshreve commented Oct 24, 2024

Proposed changes:

  • Updated the GIF block to use Tumblr's GIF search API, replacing the current Giphy-powered block.
  • Added WP.com proxy endpoints for /v2/gif/search/{query} and /v2/gif/popular to retrieve Tumblr GIFs.
  • Adds backwards compatibility so if a giphyUrl attribute is still detected, we honor those embeds.
  • Updated tests.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

  • pg1lMq-7O-p2
  • pg1lMq-80-p2

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

Testing an existing GIPHY GIF

  • Before switching to this branch, create a new post or edit an existing post when running trunk
  • Add the GIF block and insert it into the post.
  • Enter a search term in the "Search" field.
  • Select a GIF from GIPHY.
  • Save or update the post.
  • Switch Jetpack to use this branch.
  • View the post on the frontend site.
  • Check that the GIPHY GIF still displays correctly.

Creating a new GIF

  • Run bin/jetpack-downloader test jetpack tumblr-gif-block to apply the endpoints to your sandbox.
  • Set JETPACK__SANDBOX_DOMAIN to point at your sandbox.
  • Create a new post or edit an existing post.
  • Add the GIF block and insert it into the post.
  • Enter a search term in the "Search" field.
  • Select a GIF from Tumblr.
  • Add a caption to the GIF (optional).
  • Save or update the post.
  • View the post on the frontend site.
  • Check that the GIF displays correctly with the caption and attribution.

Demo:

gif_demo.mov

@justinshreve justinshreve self-assigned this Oct 24, 2024
@github-actions github-actions bot added [Block] GIF [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests Docs labels Oct 24, 2024
Copy link
Contributor

github-actions bot commented Oct 24, 2024

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen semi-continuously (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for none scheduled (scheduled code freeze on undefined).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Oct 24, 2024
Copy link
Contributor

github-actions bot commented Oct 24, 2024

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the tumblr-gif-block branch.

  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack tumblr-gif-block
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@justinshreve justinshreve removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Oct 24, 2024
@justinshreve justinshreve changed the title [WIP] GIF Block: Replace source with Tumblr GIF Search GIF Block: Replace source with Tumblr GIF Search Oct 24, 2024
@justinshreve justinshreve requested a review from a team October 29, 2024 13:11
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gave it a quick try, and left a few notes below.

<Path d="M4.6 5.9H0v10h1.6v-3.1h3c4.8 0 4.8-6.9 0-6.9zm0 5.4h-3v-4h3c2.6.1 2.6 4 0 4zM51.2 12.3c2-.3 2.7-1.7 2.7-3.1 0-1.7-1.2-3.3-3.5-3.3h-4.6v10h1.6v-3.4h2.1l3 3.4h1.9l-.2-.3-3-3.3zM47.4 11V7.4h3c1.3 0 1.9.9 1.9 1.8s-.6 1.8-1.9 1.8h-3zM30.6 13.6L28 5.9h-1.1l-2.5 7.7-2.6-7.7H20l3.7 10H25l1.4-3.5L27.5 9l1.1 3.4 1.3 3.5h1.4l3.5-10h-1.7z" />
<Path d="M14.4 5.7c-3 0-5.1 2.2-5.1 5.2 0 2.6 1.6 5.1 5.1 5.1 3.5 0 5.1-2.5 5.1-5.2-.1-2.6-1.7-5.1-5.1-5.1zm-.1 8.9c-2.5 0-3.5-1.9-3.5-3.7 0-2.2 1.2-3.8 3.5-3.8 2.4 0 3.5 2 3.5 3.8.1 2-1 3.7-3.5 3.7zM57.7 11.6h5.5v-1.5h-5.5V7.4h5.7V5.9h-7.3v10h7.3v-1.6h-5.7zM38 14.3v-2.7h5.5v-1.5H38V7.4h5.7V5.9h-7.3v10h7.3v-1.6zM93 10.3l-2.7-4.4h-1.9V6l3.8 5.8v4.1h1.6v-4.1l4-5.8v-.1h-2zM69.3 5.9h-3.8v10h3.8c3.5 0 5.1-2.5 5-5.1-.1-2.5-1.6-4.9-5-4.9zm0 8.4h-2.2V7.4h2.2c2.3 0 3.4 1.7 3.4 3.4s-1 3.5-3.4 3.5zM86.3 10.7c.9-.4 1.4-1.1 1.4-2 0-2-1.5-2.8-3.4-2.8h-4.6v10h4.6c2 0 3.7-.7 3.7-2.8 0-.8-.5-2-1.7-2.4zm-5-3.4h3c1.2 0 1.8.7 1.8 1.4 0 .8-.6 1.3-1.8 1.3h-3V7.3zm3 7.1h-3v-2.9h3c.9 0 2.1.5 2.1 1.6 0 1-1.2 1.3-2.1 1.3zM113.9 13.3h5.3V16c-1.2.9-2.9 1.1-4 1.1-4.2 0-5.6-3.3-5.6-6 0-4.1 2.2-6.1 5.6-6.1 1.4 0 3.2.4 4.8 1.8l3.4-3.4C120.7.6 118.1 0 115.2 0c-7.8 0-11.4 5.6-11.4 11s3.1 10.9 11.4 10.9c4 0 7.6-1.4 8.9-4.1V8.6h-10.2v4.7zM171.9 8.5h-7.4V.6h-5.9v20.8h5.9v-7.8h7.4v7.8h5.9V.6h-5.9zM195.1.6l-4.5 7.1-4.3-7.1h-6.6v.2l7.9 12.3v8.3h5.9v-8.3L201.8.9V.6zM127.4.6h5.9v20.8h-5.9zM147.6.6h-10.1v20.8h5.9v-5.6h4.2c5.6-.1 8.3-3.4 8.3-7.6.1-4.1-2.7-7.6-8.3-7.6zm0 10.2h-4.2V5.6h4.2c1.6 0 2.5 1.2 2.5 2.6 0 1.4-.9 2.6-2.5 2.6z" />
</SVG>
<p className="gif-branding-text">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should only display the tagline for new blocks, and not for existing blocks where the gifs are powered by Giphy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text is only show in the sidebar of the admin, so I think it's OK because it only shows up when managing GIFs.

Existing Giphy blocks do not get the att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zM147.6.6h-10.1v20.8h5.9v-5.6h4.2c5.6-.1 8.3-3.4 8.3-7.6.1-4.1-2.7-7.6-8.3-7.6zm0 10.2h-4.2V5.6h4.2c1.6 0 2.5 1.2 2.5 2.6 0 1.4-.9 2.6-2.5 2.6z" />
</SVG>
<p className="gif-branding-text">
<a href="https://www.tumblr.com" target="_blank" rel="noopener noreferrer">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using ExternalLink here, to clearly indicate that the link opens a new window?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Comment on lines 28 to 29
$this->wpcom_is_site_specific_endpoint = false;
$this->wpcom_is_wpcom_only_endpoint = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this will need to be set to true if we want the block to be usable outside of WordPress.com simple.

I think you could look at existing endpoints in projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/ for some existing work on this. The Blogging prompts endpoint for example, would be a good example:
projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v3-endpoint-blogging-prompts.php

It is an endpoint that is used in a similar way to the tumblr search. It can also be used by contributors and above. Admins shouldn't be the only ones to be able to insert GIF blocks in a post, as long as the site is connected to WordPress.com you should be able to make a request.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I fixed up a few things here following the writing block as an example!

* @return void
*/
public function register_routes() {
register_rest_route(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the extra routes meant to be used in a future version of the block? I'm asking to know if it's worth adding them now, or if it may be worth waiting until we really need them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future I think we would like to use the Popular GIFs endpoint, but I agree we can remove it for now.

@justinshreve
Copy link
Contributor Author

Thank you for the review @jeherve! I've pushed a few changes to address the feedback, especially around the auth/proxying part. I also updated the testing instructions since the WP.com portion of this (the key) is now deployed.

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on those changes!

Things are working well on WordPress.com Simple, but not on WoA or self-hosted yet since there no endpoint to respond to https://public-api.wordpress.com/wpcom/v2/sites/%blog_id%/tumblr-gifs/search/%keyword% yet, as far as I can tell. Is there a Phab diff with that endpoint, that I could use to test this on Atomic and self-hosted?

}
},
"example": {
"attributes": {
"align": "center",
"giphyUrl": "https://giphy.com/embed/fxKWgoOG9hzPPkE1oc",
"gifUrl": "https://64.media.tumblr.com/3131b9d2a05485e7ae7838a8b1314ab2/2d72fb0f707ea67a-5f/s500x750/d45e10288e4ff6a775c879978f52c87d3318ff8d.gif",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you could find an image with a different aspect ratio? It doesn't look great right now:

image

@justinshreve
Copy link
Contributor Author

justinshreve commented Nov 5, 2024

Things are working well on WordPress.com Simple, but not on WoA or self-hosted yet since there no endpoint to respond to https://public-api.wordpress.com/wpcom/v2/sites/%blog_id%/tumblr-gifs/search/%keyword% yet, as far as I can tell. Is there a Phab diff with that endpoint, that I could use to test this on Atomic and self-hosted?

Not at the moment, as that would require adding the endpoints in Moon/Sun myself. The way I've been testing this is by running bin/jetpack-downloader test jetpack tumblr-gif-block on my sandbox, and then pointing the Jetpack install to it with JETPACK__SANDBOX_DOMAIN.

I did already deploy code that will load the endpoints from Jetpack; it just needs the files to exist. I can build a Phab diff, but I think it might just be easier to use the jetpack-downloader script.

--

Also, we might be changing the way the GIF is embedded, so I'll follow up on that shortly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] GIF Docs [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] Needs Team Review [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants