-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 support for shields.io-based badges #28585
Conversation
I'm neutral to a more general badge implementation. If this PR is accepted, I will close my PR. |
It should be able to be at lest deactivatable as awhole, because of dataprotection roules |
Can do, no problem. |
Or even better: We let the user configure the badge generation URL (default: https://shields.io), and if it is blank, it is deactivated. |
But yeah, sounds like a good idea overall. |
The URL is already configurable in this PR, defaulting to |
TIL you can host your own shields.io 😁 I wonder if it would make sense to have a config URL with placeholders for In this case the default setting could be https://shields.io/badge/{label}-{text}-{color} but would allow someone to mix it however they wanted to. I just looked up an alternative as an example, https://badgen.net/static/{label}/{text}/{color} |
Yeah, that should be doable. There's existing code that does templated URLs (for |
I'm pondering about how to make the badges easy to use in the README... As things stand, you need a full URL, like On the other hand, a large part of the badges use case is when they're displayed elsewhere. In that case, we need the full URL anyway. So I guess that'll be the way. |
Cleaned up the code, made it possible to disable the feature, and change the badge generator URL template, added a bunch of tests (both positive and negative ones), and an example to I think this is now ready for review. |
TBH, I have strong preference to #28102 if the concerns there could be resolved. |
Adds a new `/{username}/{repo}/badges` family of routes, which redirect to various shields.io badges. The goal is to not reimplement badge generation, and delegate it to shields.io (or a similar service), which are already used by many. This way, we get all the goodies that come with it: different styles, colors, logos, you name it. So these routes are just thin wrappers around shields.io that make it easier to display the information we want. The URL is configurable via `app.ini`, and is templatable, allowing to use alternative badge generator services with slightly different URL patterns. Additionally, for compatibility with GitHub, there's an `/{username}/{repo}/actions/workflows/{workflow_file}/badge.svg` route that works much the same way as on GitHub. Change the hostname in the URL, and done. Fixes #5633 and #23688. Work sponsored by Codeberg e.V. Signed-off-by: Gergely Nagy <forgejo@gergo.csillger.hu>
Force-pushed an update, changing the route of the action badges: it's now |
As of approximately 2 weeks ago shields.io supports release/language badges for Gitea/Forgejo out of the box. More endpoints will be added soon, most likely next will be issues/stars once I get to it. Not sure if this information helps this PR or not but just wanted to share this. |
Sweet, that means that a lot of this PR will be unnecessary soon. I suppose only the Actions parts should remain then, because there is no API where the information could be collected from by shields.io to support them natively. In the longer run, perhaps the better action would be to add those APIs, and have shields.io support Build (Action) badges for Gitea/Forgejo out of the box, too. |
Adds a new
/{username}/{repo}/badges
family of routes, which redirect to various shields.io badges. The goal is to not reimplement badge generation, and delegate it to shields.io (or a similar service), which are already used by many. This way, we get all the goodies that come with it: different styles, colors, logos, you name it.So these routes are just thin wrappers around shields.io that make it easier to display the information we want. The URL is configurable via
app.ini
, and is templatable, allowing to use alternative badge generator services with slightly different URL patterns.Fixes #5633 and #23688.
Work sponsored by Codeberg e.V.
This is an alternative solution for #23688 (and #5633), doing things in a very different way than #28102.
Things left to do
app.ini
Sample screenshot