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

Replace Shields.io with locally rendered data/badges #591

Merged
merged 12 commits into from
Jan 25, 2025

Conversation

17cupsofcoffee
Copy link
Collaborator

@17cupsofcoffee 17cupsofcoffee commented Jan 13, 2025

Currently, data like download counts and licenses is displayed by embedding Shields.io badges as image tags. This PR (which is an extension of #589) replaces these entirely with data fetched directly from Crates.io/GitHub/GitLab.

There's two pretty big benefits to doing this:

  • It makes the data more accessible to people who are using screen readers (we have no way of providing any meaningful alt text for the existing badges, as Shields.io doesn't provide any way of accessing the underlying data).
  • It unlocks the possibillity of adding (client-side) sorting functionality later down the line.

However, there are also some tradeoffs:

  • The data will no longer be 100% up to date, as it'll only get fetched when the site re-renders.
    • This is done once a week, as well as when PRs are merged, though - so it should never get too stale.
  • The site now takes a bit longer to build (1 minute on CI, as opposed to 30 seconds).
  • Due to the extra requests to GitHub, we now have to provide a token to avoid getting rate-limited.
    • In fairness, this would have started happening as soon as we had more than 60 items with source = "github" anyway - the unauthenticated rate limit is very low!
    • GitHub Actions provides a token for every CI build anyway, but you'd have to provide one yourself if you're building locally.

I personally think these trade-offs are worth it (assuming I can get around to implementing the sorting functionality later!), but I'd be interested to get some feedback from the community on whether they think this is the right direction.

Here's what the new UI looks like (see the live page for comparison):

image

(the top three items there use the crates source, the last one uses the github source)

@ZimboPro
Copy link
Contributor

What you could is keep the shields.io badges and just use the API calls to Github, Gitlab etc to power the alt data. This will allow that visually, it will be still up-to-date. The screen readers will be out of sync but just making a note somewhere on the page should help inform the users.

@17cupsofcoffee
Copy link
Collaborator Author

17cupsofcoffee commented Jan 14, 2025

What you could is keep the shields.io badges and just use the API calls to Github, Gitlab etc to power the alt data. This will allow that visually, it will be still up-to-date. The screen readers will be out of sync but just making a note somewhere on the page should help inform the users.

That's what I was originally intending to do - I feel like that approach could make things confusing when I come to add the sorting functionality, though (as that would have to be driven by the local data). I'll give it some thought.

@17cupsofcoffee 17cupsofcoffee marked this pull request as ready for review January 16, 2025 17:38
@17cupsofcoffee
Copy link
Collaborator Author

17cupsofcoffee commented Jan 25, 2025

The feedback I've gotten on this approach from Discord has been positive, and I'm fairly close to having a branch ready for the sort functionality, so I think I am going to go ahead with merging this.

If stale data becomes a problem, I can look into increasing the frequency of rebuilds (I think daily would be fine now that we're using a GitHub token, tbh) and/or reintroducing the badges as an overlay for this data. We'll see how it goes.

Thank you @ZimboPro for your contributions towards the repo stats part, your branch/comments pointed me in the right direction to get that working 🙂

@17cupsofcoffee 17cupsofcoffee merged commit 7df2373 into master Jan 25, 2025
4 checks passed
@17cupsofcoffee 17cupsofcoffee deleted the badge-accessibility branch January 25, 2025 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants