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

[PLUGIN] Keep Google Fonts Up to date #9

Closed
ravichdev opened this issue Apr 1, 2021 · 5 comments
Closed

[PLUGIN] Keep Google Fonts Up to date #9

ravichdev opened this issue Apr 1, 2021 · 5 comments
Projects
Milestone

Comments

@ravichdev
Copy link
Contributor

Issue by jauyong
Monday Dec 07, 2020 at 14:15 GMT
Originally opened as xwp/material-design-wp-plugin#460


Feature description

I want access to the latest Google Fonts.

Resources: https://developers.google.com/fonts/docs/developer_api
Related to #354
This ticket was split from #383


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  1. Fonts should be auto-updated (interval or auto-detection on when an update is available)
  2. Add an option to opt-out of auto-updates
  3. A plugin update is not required to receive Font updates
  4. Performance should be kept in mind (e.g. use caching, not cron job, look at how PWAs work) (nice to have)

Implementation brief

  • Updates should happen when the Selector comes into focus in the Customizer
  • An update constitutes checking a transient in the database. If an install has an object cache, core behavior stores transients as cached items and reduces reads on MySQL.
  • A transient should have a 24h expiry to avoid overloading the Fonts API
  • If a transient exists, bail and let existing behavior read from local stored JSON file in assets/fonts/google-fonts.json.
  • If transient does not exist, or is expired, request new list from the Google Fonts API. https://www.googleapis.com/webfonts/v1/webfonts?key={key}&fields=items(category,variants,family)
  • Because the JSON payload provided by Google does not match the format currently used, perform a simple transformation and write to the existing file. This is a small transform that moves the family property from the payload to the key. This will allow existing functionality to continue to work with no further compatibility layer.
  • Write the transformed JSON to assets/fonts/google-fonts.json for future use and npm.

Existing Format

{
	{
      "family": "Roboto",
      "variants": [
        "100",
        "100italic",
        "300",
        "300italic",
        "regular",
        "italic",
        "500",
        "500italic",
        "700",
        "700italic",
        "900",
        "900italic"
      ],
      "category": "sans-serif"
    }
}

Google JSON format

{
    "Roboto": {
        "variants": [
            "100",
            "100italic",
            "300",
            "300italic",
            "regular",
            "italic",
            "500",
            "500italic",
            "700",
            "700italic",
            "900",
            "900italic"
        ],
        "category": "sans-serif"
    }
}

QA testing instructions

Demo

Changelog entry

@ravichdev ravichdev added this to the 0.2.0 milestone Apr 1, 2021
@ravichdev
Copy link
Contributor Author

Comment by jauyong
Monday Dec 07, 2020 at 17:11 GMT


After the IB is written, please assign to Rody to review

@ravichdev
Copy link
Contributor Author

Comment by jauyong
Tuesday Dec 08, 2020 at 16:30 GMT


Assigning myself until Aaron is added to the project

@ravichdev
Copy link
Contributor Author

Comment by technosailor
Tuesday Dec 15, 2020 at 16:14 GMT


Hi @rodydavis-

I failed to assign this to you yesterday. So now I have.

Please review the updated implementation brief.

Thanks!

@ravichdev
Copy link
Contributor Author

Comment by rodydavis
Thursday Dec 17, 2020 at 17:06 GMT


Approved! Looks great to me. Similar to #461

@ravichdev ravichdev added this to Backlog in Execution Apr 1, 2021
@ravichdev ravichdev moved this from Backlog to Code Review in Execution Apr 1, 2021
@ravichdev ravichdev moved this from Code Review to QA in Execution Apr 8, 2021
@csossi
Copy link
Collaborator

csossi commented Apr 12, 2021

Verified in QA

@csossi csossi removed their assignment Apr 12, 2021
@ravichdev ravichdev moved this from QA to Demo in Execution Apr 12, 2021
Execution automation moved this from Demo to Done Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

2 participants