libraries.io icon indicating copy to clipboard operation
libraries.io copied to clipboard

Embeddable badges

Open andrew opened this issue 7 years ago • 6 comments

This has been something that's been mentioned on twitter and in person before but I don't think there's been an issue for it yet, would line up nicely with the launch of SourceRank 2.0 (https://github.com/librariesio/libraries.io/issues/1916) to provide a set of badges with Libraries statistics for people to put in their readmes/websites (such as pypi.org https://github.com/pypa/warehouse/issues/991#issuecomment-377250393)

We have some unique data like:

  • SourceRank score
  • Individual scores from SourceRank breakdown
  • Dependency status
  • Dependency count
  • Dependent repos
  • Dependent packages

We could also provide a standardized set of badges for packages that work across GitHub, GitLab and Bitbucket:

  • stars
  • forks
  • license
  • contributors
  • maintainers
  • status
  • latest release
  • first release
  • release count

I'd be tempted to make a badge controller and a route+action for each type of badge that returns a shields.io url like https://img.shields.io/badge/<SUBJECT>-<STATUS>-<COLOR>.svg:

andrew avatar Apr 03 '18 11:04 andrew

Here's an example badge controller action based on one that I wrote for Dependency CI last year:

  def badge
    response.headers["Cache-Control"] = "no-cache, no-store"
    response.headers["Pragma"] = "no-cache"
    response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
    @project = find_project
    style = params[:style] || 'flat'
    if @project
      redirect_to "https://img.shields.io/badge/SourceRank-#{project.rank}-brightgreen.svg?style=#{style}", status: 302
    else
      redirect_to "https://img.shields.io/badge/Dependency%20CI-unknown-lightgrey.svg?style=#{style}", status: 302
    end
  end

andrew avatar Apr 03 '18 12:04 andrew

I'm wary of putting a specific SourceRank number on a badge like this basically for all the metrics-wariness reasons you would expect. But I am sure there is some data that would be good to surface in a badge or set of badges, and would be interested to see what others' ideas are.

brainwane avatar Apr 03 '18 12:04 brainwane

@brainwane agreed, might not make sense for PyPI to use the sourcerank badge, I tried to make this issue a bit more broad but we can open a PyPI specific one if its helpful?

Bit of context, I created SourceRank because I couldn't find a good comparable metric that worked across ecosystems and avoided all the issues associated with GitHub stars

andrew avatar Apr 03 '18 13:04 andrew

Any update on this issue? I think this would be pretty useful.

simplexidev avatar Oct 10 '18 03:10 simplexidev

@tom-corwin does the PR from Andrew cover the badges you were looking for?

havocp avatar Oct 10 '18 15:10 havocp

It would work, yes, but id recommend using badgen.net rather than shields.io, sinces its quite a bit faster and reliable (plus has more features, such as icons)

EDIT:

Shields.io:
shields.io
![shields.io](https://img.shields.io/badge/badge-value-blue.svg)

Badgen.net badgen.net ![badgen.net](https://badgen.net/badge/badge/value/blue)

simplexidev avatar Oct 10 '18 15:10 simplexidev