-
-
Notifications
You must be signed in to change notification settings - Fork 186
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
Reviewer Badges :) #1389
base: main
Are you sure you want to change the base?
Reviewer Badges :) #1389
Conversation
Hey! Thanks for getting going on this @sneakers-the-rat ⚡. This is definitely the sort of thing I'm thinking about. One thought, do you think as part of this we might want to consider consolidating the other SVG rendering (e.g., joss/app/controllers/papers_controller.rb Lines 307 to 321 in c447b2a
|
I think it would make sense to do that, but didnt want to change it all until I got a nod to go ahead :) |
reviewing my open PRs and thought i'd ping on this? The only outstanding question i think is caching, and from what I can tell from the docs, rails should automatically cache rendering of the template for a given set of parameters. since the parameters given to the template are all generic across reviewer identity (i.e. they just have the text of the badge and the numbers) that should kick in. Ideally we would also cache the badge per reviewer so we don't need to do a db query at all, but doing that would require us to add reviewers to the schema so we can do cache invalidation when a reviewer does another review, and that should probably be a different PR. Another approach would be to make the badge endpoint totally generic, someting like I also think swapping the existing badges to this controller should probably be another PR. Anything blocking this? |
Fix: #1385
here she is:
review_badge.mp4
and on mobile:
review_badge_mobile.mp4
OK this was more complicated than i thought because it turns out you need to like calculate the widths of all the characters for a given font to make an SVG badge, but i did it because i have wanted to have something like this in my own websites without having to use shields.io or w/e. Elsewhere the SVGs are just hardcoded, but I thought it would be nice to generate them for any key and color because we might want to use them for other things :)
I basically transcribed and simplified shields.io's code, it's mostly self explanatory except don't ask me what's going on with those scaling parameters. I grabbed an array of codepoint widths and made it a constant, use that to calculate the width, and the rest is in the controller.
I tried to reuse as much as i could from the rest of the site, but it looks like we're not using sass variables so i just hunted out values that seemed like they were the right ones to use.
The badges will be at
joss.theoj.org/badges/reviewed_by/:username
. I imagine re-rendering them from scratch every time is pointlessly expensive, so plz lmk how caching works here because they should only rarely change, but it's hard to detect the review count being stale because we don't have aReviewer
model.I am holding off on tests for now until i get signoff on the basic approach, and then i'll write em!