Add width customization to Latest Release Badge
What does this MR do and why?
Adds the possibility to provide a parameter to the latest releases badge endpoint to customize the width of the value area of the badge.
When using date as a release value, date is not contained in the standard width of 54 px of the latest release badge.
One possibility would be implement a "calculation" of the text width and provide it to final badge, like they do in google/pybadges repo: https://github.com/google/pybadges/blob/c855208850e7cc5ee2973a9340b9449df4ab0bd5/pybadges/precalculate_text.py#L86
Or to give the possibility to the user to change the size as a parameter of the URL, how it is done to the customization of the badge title text and width. This is what this merge request tries to do.
Screenshots or screen recordings
Here is the comparison in the Gitpod instance:
How to set up and validate locally
- Create a new project, or use one where you have access to the project settings.
- Make sure there is at least one commit (the original commit made by gitlab with the README is enough)
- Make sure there is at least on release with a long name, for instance today's date:
2023-03-04
, otherwise create a tag2023-03-04
and then a release with the same name2023-03-04
- On the left side click on Settings -> General.
- Open the badges section
- Set
Latest Release
as Name - Set any link you prefer
- Set
https://example.gitlab.com/%{project_path}/badges/release.svg
as Badge image URL, you will notice that the release number is clamped - Set
https://example.gitlab.com/%{project_path}/badges/release.svg?value_width=85
instead of the previous one and you will have a centered text, easy to be read.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.