librariesio / libraries.io

:books: The Open Source Discovery Service
https://libraries.io
GNU Affero General Public License v3.0
1.11k stars 202 forks source link

Embeddable badges #2077

Open andrew opened 6 years ago

andrew commented 6 years ago

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:

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

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 commented 6 years ago

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
brainwane commented 6 years ago

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.

andrew commented 6 years ago

@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

simplexidev commented 6 years ago

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

havocp commented 6 years ago

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

simplexidev commented 6 years ago

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)