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

Generate fontawesome icons #6

Open
stephan-strate opened this issue Feb 26, 2021 · 5 comments
Open

Generate fontawesome icons #6

stephan-strate opened this issue Feb 26, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@stephan-strate
Copy link

Fontawesome provides a json file, what contains all icons as svg. Would you be interested in me integrating a functionality, that downloads the json file and generates svg files from it? This would be optional of course.

Tell me what you think about that :)

@N-Parsons
Copy link
Owner

That could be useful, so I'd happy for you to integrate it. Looking at the linked JSON, it seems that you would need to put the attribution comment back in for compliance with the Font Awesome Free license, because it's not included in "raw".

<!-- Font Awesome Free 5.15.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) -->

There's also a corresponding JSON file for the Pro license, but it's in a private repo, so it requires an access token to be appended to the address. I'm not sure if there's a convenient way of getting such a token within a Grav site, so I wouldn't consider this a requirement for inclusion.

https://raw.githubusercontent.com/FortAwesome/Font-Awesome-Pro/master/metadata/icons.json?token=ASTRINGOFLETTERSANDNUMBERS

An alternative

Alternatively, you could query the GitHub API to get the latest release, get the asset URL for the web version, then download it, unzip and just keep the SVGs. I'm not sure that piecing files back together from a JSON makes much sense when we can already get the files directly?

GET https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest

It might also be useful to have the option to upload a zip file and have the plugin automatically unzip it and move the SVGs to the right place.

@N-Parsons N-Parsons added the enhancement New feature or request label Mar 2, 2021
@stephan-strate
Copy link
Author

Thanks for your thoughts! I will think about it again and create a pull request draft for you to review.

@stephan-strate
Copy link
Author

stephan-strate commented Mar 7, 2021

After some more thoughts about this topic, this is my conclusion:

Requirements:

  • License compliance
  • Zero maintenance
  • Pro & free integration
  • Easy to use from admin

The only way I found to get access to the pro icons automatically is using npm. Fontawesome serves an official npm registry, where you can authenticate using the provided access token.
You can not only use the npm registry through npm cli, but also through rest api calls.
Example: GET https://registry.npmjs.org/@fortawesome/fontawesome-free/latest for the free version.
From there, you can download the tarball and extract the svg icons into the user/data/ folder. You were definitely right about your concerns regarding the creation from the json file. So I am going to use the tarball.

These are my planned features:

  • Enable/disable automatic download of the svg icons to the user/data/ folder
  • Switching between free and pro using the auth token
  • Regenerate the icons (latest version) using a button in admin (we could also provide a cli command for that)
  • Show the latest and "installed" version number in admin
  • Upload a specific zip/tar file to get extracted to user/data/

Let me know what you think about this.

@N-Parsons
Copy link
Owner

Looks like a good plan. I shall look forward to your pull request.

If you don't have Font Awesome Pro and need help testing it, just give me a shout.

@stephan-strate
Copy link
Author

@stephan-strate @N-Parsons

What is here now actually?

I created a merge request a while ago. This should still work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants