Automatic expansion of user stats from links/badge

Description of your request or bug report: A use case that came up while talking with other people would be a way to access stats to make automatic “badges” showing how many books we have read this year, for instance. The idea is to have something to post on blogs or the like that we can use to keep track of yearly goal and the like (similar to this table but in a more automated way)
I am thinking about the kind of stuff you see on GitHub, such as

or maybe just a self expanding link, like the one for books, but instead showing the username and some stats.

Edit: what I came up with is this: test, with C the number of Character-based books read this year, M manga, and T for total.

I am aware that Discourse bakes in the values, but if anyone edit the table ocne in a while, everything would be automatically updated at once. (Actually, it seems to work anyway?) Additionally, other places, like blogs, would be fine.

Edit: it seems to work.

Trello link: (leave in blank)

Are you imagining an html widget where I generate code that you can put on your blog?

I don’t think that would work for using on Discourse though if that’s what you’re imagining.

1 Like

I read this discussion (didn’t follow super closely, admittedly) but I think the intention is for the ability to link something like

and have it contain more information like # of books read and such.

1 Like

Like cat said, I think the basics would be to have autoformating the same way that a book link turns into よつばと! 1 | L17 you would have Naphthalene's profile | Natively turn into Naphthalene (book read in 2023: 118) or something similar.

That being said, I thought having widgets would be more flexible, that’s why I mentioned them as well.

It should work, as in it would display. Example:

The only thing is that it would not automatically update but, again, for the use case mentioned above, that would be fine.

Edit: it could be in the box that expends when someone links their profile as well.


Where did you get that generated link? Did you simply copy an url and discourse converted it?

It’s a random widget I got from a github page I had open. I just inserted the code.
I assume the generation itself is done by github? I have no idea how widgets/badges/whatever you call that work in general.

1 Like

what do you mean you inserted the code? What code? Can you give me a step by step of what exactly you did? :slight_smile:


I went to Github, used random keywords until I found a repository with the thing I was looking for, right clicked on it, selected inspect element, control-c on the html code, then just control-v here.

Edit: You can see the code by using the quote full message, but just in case:

<img src="" alt="codecov" data-canonical-src="" style="max-width: 100%;">


I see. So that’s just an image, not a widget. I don’t think it’s possible to allow 3rd party widgets into discourse. I could potentially create a stats image for you, but not sure what we want.

As far as doing the simple link text conversion like Naphthalene's profile | Natively, i could generate urls with a different page title that includes your book count, sure. Although I’m guessing it will be of somewhat limited use, as everyone has different needs? :confused:

1 Like

Showing our body book count would be pretty fun just saying


Well, it is an image, but if the source change, then it would change too, right?
I feel like I could try myself once there’s a public API for the stats (that’s included in the API request, right?)

Right, in both cases, I feel like the user would want some degree of customization. As a start, though, the most common use case I see is how many books someone has read this year (as part of a yearly challenge). In some cases, people distinguish between manga and 活字 (character based) books.

Maybe something like Naphthalene (C51/M67/T118)
(Character-based/Manga/Total; although people will have to come to Natively to see the explanation, which seems like a good idea :crazy_face:)

Images can be server-generated, but the URL needs to be changed as well, to prevent caching. Or Discourse needs to reset its cache somehow, if to use the same image URL.

Isn’t the status text already changing based on Natively website? (Only that not so fancy.)

No, it gets baked in, apparently. Wait, then the profiles would also get baked in, so just editing the post might not work…

That plus your point about cache makes me feel like it might not be possible with Discourse at all :sweat_smile: That being said, it’s still a nice thing to have.

Edit: the link itself is untouched in the message and saving an edit does seem to regenerate the content, so there’s still

1 Like

AIUI they are server generated SVG images, served with either a fairly low cache lifetime or else instructions not to cache them at all; so whenever somebody loads a webpage that refers to one they’ll get an up to date image, not a stale one. GitHub - badges/awesome-badges: A curated collection of awesome things related to status badges seems like a good place to start if you’re interested in the technical details.


Okay, I am going to check if I can make this work with Discourse.

First, the badge should look like this: test then after a minute or so I’ll change the content.

Does this update?

Edit: it seems like it does not :frowning: I guess that’s because is cacheing the values?
It just takes a bit of time.


I see this… it is different?

Screen Shot 2023-11-07 at 10.43.09 AM


Oh! That’s what you are supposed to see!
And I see it too now!

Okay, so I guess it just takes a little bit of time, but that’s acceptable.

Edit: okay, then all you need to do on your side is to provide a json endpoint that returns a json with the following format:

{ "schemaVersion": 1, "label": username, "message": "(C[valueC]/M[valueM]/T[valueT])", "labelColor": "396086", "color": "f2e6df" }

(filling the username and the various values appropriately)
and then will just do its magic.


I have updated the first post and clarified what should be done. Hopefully that will help make the request acceptable :smile:

Edit: oh yeah, and many thanks to @pm215 for pointing me in the right direction.


I guess this could be part of the API commands.


That would make sense. At first I wanted to post in the API thread, to be honest.
That being said, I’m afraid that it would get buried and forgotten if I just add the request there (plus I feel like it might be easier AND a good test of the API framework to implement this first; I may be biased though :stuck_out_tongue:)

edit: the API isn’t even on the roadmap yet :sweat_smile: