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
[ready for review] [new badge] added Sourcegraph.com badge #828
Conversation
give it a shot! |
Could I get a review ? @PeterDaveHello @espadrine Thanks in advance! |
Hi @rohanpai, actually I'm not an active contributor or even maintainer here, I think you'll need somebody else to approve your pull request 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the patch!
Could you squash your commits together please?
README.md
Outdated
@@ -84,6 +84,7 @@ What kind of metadata can you convey using badges? | |||
* [ruby-gem-downloads-badge](https://github.com/bogdanRada/ruby-gem-downloads-badge/) | |||
* [Scrutinizer](https://scrutinizer-ci.com/) | |||
* [Semaphore](https://semaphoreapp.com) | |||
* [Sourcegraph](https://sourcegraph.com) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a list of integrations that the website supports. It is a list of third-parties that attempt to have an implementation conforming to the standard look. I believe that Sourcegraph does not have its own implementation of badges. If that is correct, could you remove this line?
index.html
Outdated
@@ -232,6 +232,10 @@ <h3 id="build"> Build </h3> | |||
</tbody></table> | |||
<h3 id="downloads"> Downloads </h3> | |||
<table class='badge'><tbody> | |||
<tr><th data-keywords='sourcegraph' data-doc='sourcegraphDoc'> Sourcegraph (# references other repos): </th> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you are not using documentation, so data-doc='sourcegraphDoc
does not reference a DOM object with id="sourcegraphDoc"
. Additionally, you do not need to put data-keywords='sourcegraph'
, since that word is already in the text of the th
.
Also, this badge is unrelated to downloads. Could you put it at the bottom of the miscellaneous section, please?
Finally, perhaps you can simplify the title to make it shorter? What matters most is that people can understand what it does; hopefully the badge is enough, so that the part in parentheses is not necessary.
logo/sourcegraph.svg
Outdated
<path fill="#FFFFFF" d="M69.087,56.734c-0.798,0-1.597-0.2-2.596-0.399l-60.9-19.968C1.398,34.97-0.998,30.377,0.4,26.184 | ||
c1.397-4.193,5.99-6.589,10.183-5.191l60.9,19.967c4.193,1.397,6.59,5.99,5.191,10.184C75.677,54.538,72.682,56.734,69.087,56.734z" | ||
/> | ||
</svg> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you pass this file through SVGo to make it shorter?
server.js
Outdated
@@ -2989,6 +2989,39 @@ cache(function(data, match, sendBadge, request) { | |||
}); | |||
})); | |||
|
|||
camp.route(/^\/sourcegraph\/([\s\S]+)\.(svg|png|gif|jpg|json)$/, | |||
cache(function (data, match, sendBadge, request) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this empty line please?
server.js
Outdated
@@ -2989,6 +2989,39 @@ cache(function(data, match, sendBadge, request) { | |||
}); | |||
})); | |||
|
|||
camp.route(/^\/sourcegraph\/([\s\S]+)\.(svg|png|gif|jpg|json)$/, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We wish to allow for vendor URLs to support extending it as vendors support more pieces of information. Could you add a part related to this particular piece of information offered by Sourcegraph? Perhaps /sourcegraph/rrc/…
, for "repository reference count"?
server.js
Outdated
var repo = match[1]; // eg, `prismic` or `foo/bar`. | ||
var format = match[2]; | ||
var apiUrl = "https://sourcegraph.com/.api/repos/"+repo+"/-/shield" | ||
var badgeData = getBadgeData('build', data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that "build" is the best left-hand-side description of what the badge does? I feel like "dependents" or "used by" would be more appropriate, if I understand this badge correctly.
server.js
Outdated
var badgeData = getBadgeData('build', data); | ||
request(apiUrl, function(err, res, buffer) { | ||
console.log("err" + err) | ||
if (err !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err != null
, to also work if err
is undefined.
server.js
Outdated
} | ||
badgeData.text[0] = "Used by" | ||
badgeData.colorscheme = 'brightgreen'; | ||
badgeData.logo = logos['sourcegraph']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logos.sourcegraph
server.js
Outdated
sendBadge(format, badgeData); | ||
return; | ||
} | ||
badgeData.text[0] = "Used by" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you start the try {…}
before this line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you can remove that line, since it is already taken care of by line 2998.
(Also, the left-hand-side almost always starts with a lowercase.)
try.html
Outdated
<tr><th data-keywords='sourcegraph' data-doc='sourcegraphDoc'> Sourcegraph (# references other repos): </th> | ||
<td><img src='/sourcegraph/github.com/gorilla/mux.svg' alt=''/></td> | ||
<td><code>https://img.shields.io/sourcegraph/github.com/gorilla/mux.svg</code></td> | ||
</tr> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as the comments in index.html. By the way, you should remove the changes you made in index.html; I generate that file automatically, as hinted at the top of index.html.
aff0c34
to
2281c3d
Compare
@espadrine let me know what you think! |
server.js
Outdated
return; | ||
} | ||
try { | ||
badgeData.text[0] = "Used by"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made requested changes cc @RedSparr0w @espadrine Thank you! |
@espadrine does this look ready to merge? Thanks! |
Hi @RedSparr0w @espadrine ! Any update on this? We've got a bunch of users who are really excited about using this :) All feedback has been addressed & I've updated the PR description. |
@rohanpai Hey, sorry i don't actually have any permissions in this repo, just thought i should mention the change so it would have a better chance of getting merged sooner than later. |
This looks pretty good to me! Sorry for the delay in getting back to you. As a followup, could you please add an automated test for this badge? You can find the documentation to do so here: https://github.com/badges/shields/blob/master/service-tests/README.md Thank you for your contribution! |
Sourcegraph is how developers discover and understand code. As part of this, we can answer questions like "How many repositories use my library?" easily. We'd like to propose this as a badge:
This badge lets anyone with a Go repository list how many people are actually using their library in their repository. (languages other than Go are coming soon)
To try this badge out locally: