Summarizing and continuing the discussion brought up today on IRC/Matrix.
Problem
Currently the badge name is used as a slug for the badge URL. The Trust me, I know what I am doing badge has the following URL: https://badges.fedoraproject.org/badge/trust-me%2C-i-know-what-i-am-doing
(the slug is the final part after /badge/
). It is derived from the badge name. That name contains a character (,
) that needs to be URL-encoded[1]. That results in a URL that looks odd and is less appealing to humans.
On the backend, when referencing the same badge, as I had today, the name of the badge is retained with the special characters. So, I had to run a command like: edit-badge --badge 'trust-me,-i-know-what-i-am-doing' --tags community,infrastructure
.
All that is making things needlessly complicated.
Proposed Solutions
Human readable slugs
One option is to make sure special characters, the set that needs to be URL-encoded, are dropped when composing name and slug for the badge.
Staying with the example above and the current modus operandi of replacing spaces with dashes and converting to lower case, given the badge name, the resulting slug should be trust-me-i-know-what-i-am-doing
. That slug should then also become the internal name of the badge.
What if
What if a badge needs to be renamed after it has been released and possibly already awarded?
While this does not happen very often, it should be possible without breaking anything and/or needing intervention of a sysadmin. One possible solution would be to redirect from the old URL to the new URL. Since the name is changed in the database, no action is required on the backend, referencing the badge by its new name.
Use UUIDs
Another option is to use UUIDs[2] for the badges. As the name suggests, these are unique identifiers. Therefore they cannot cause conflicts and renaming a badge will retain its UUID and the URL will not change. The URL may look something like: https://badges.fedoraproject.org/badge?id=a2b3fdde7
.
Use numeric IDs
This option is similar to UUIDs. It would make use of the badge ID as recorded in the database. Since the ID is an increment field in the database, the IDs are unique and IDs from deleted badges are not re-used. Similarly, renaming a badge, will not change its ID, nor will its URL change. It may look something like: https://badges.fedoraproject.org/badge?id=424242
.
Bottom Line
We need to find a solution that is user friendly as well as manageable for developers and admins, taking into account the desire to be able to modify badge details as we see fit, without breaking things or requiring manual intervention.
HTML URL Encoding Reference (for all the gory details: https://www.ietf.org/rfc/rfc3986.txt) ↩︎