Cersei Lannister: I shall wear this as a badge of honor.
Robert Barathon: Wear it in silence or I’ll honor you again.
– George R. R. Martin
Have a project called fizzbuzz that you deploy on MELPA? Add the following snippet to your README.md in order to add a download count badge:
[](http://melpa.org/#/fizzbuzz)
or if org-mode is your poison:
[[https://melpa.org/#/fizzbuzz][https://melpastats-2761cf.gitlab.io/badges/fizzbuzz-badge.svg]]
It looks like this (taken from my own project plantuml-mode):
I was recently busy with some cleanup and improvements of my open source projects, which resulted into deflate, a pure elisp implementation of the Deflate compression algorithm. After a few day that the package was published on MELPA, I was curious to check whether it was being downloaded (mostly as a sidecar to plantuml-mode, which is the only thing in the world that depends on it currently).
Fortunately enough, MELPA publishes your download counts and – oh boy! The tears in my eyes when I did see some downloads action there! I needed to boast about it and showcase the download count prominently in the project README.org. I needed badges.
I’m sure there are million ways to make a badge / shield happen. Heck, maybe someone else already did it and I haven’t found it (spoiler: I haven’t searched 😱). Anyways I was craving some custom coding and so it was decided: I’ll make a new project called melpastats. What it offers:
.svg badges with the download countI went for a simple babashka script, which uses svg-clj to render the actual image from Hiccup syntax. For the uninitiated, here’s how it looks like:
[:svg {:xmlns "http://www.w3.org/2000/svg"
:width full-width
:height height
:role "img"
:aria-label (str "MELPA: " package-name)}
[:title (str "MELPA: " package-name)]
;; ...
]
You can see the full hiccup stuff in the sources of course. The overall process is intentionally dumb as a rock, namely:
SVG file using its download countIt took just a few hours of non-continuous work to make that happen. Now it’s live for a month or two and I’m confident enough with it that it’s time for this post to happen. Hope it’s of any use for anyone out there.
Bye bye 🇬🇧 / tot ziens 🇳🇱 / a si biri (alas, no emoji for Sardinian :sadface:)