Skip to content
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

Merged
merged 1 commit into from May 6, 2017

Conversation

rohanpai
Copy link
Contributor

@rohanpai rohanpai commented Nov 4, 2016

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:

PORT=8083 node server
http://localhost:8083/sourcegraph/rrc/github.com/gorilla/mux.svg

@rohanpai rohanpai closed this Nov 4, 2016
@rohanpai rohanpai reopened this Nov 4, 2016
@rohanpai rohanpai changed the title [new badge] added Sourcegraph.com badge [wip] [new badge] added Sourcegraph.com badge Nov 4, 2016
@rohanpai
Copy link
Contributor Author

give it a shot! http://localhost/sourcegraph/github.com/gorilla/mux.svg

@rohanpai rohanpai changed the title [wip] [new badge] added Sourcegraph.com badge [ready for review] [new badge] added Sourcegraph.com badge Jan 12, 2017
@rohanpai
Copy link
Contributor Author

Could I get a review ? @PeterDaveHello @espadrine Thanks in advance!

@PeterDaveHello
Copy link
Contributor

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 😄

Copy link
Member

@espadrine espadrine left a 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)
Copy link
Member

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>
Copy link
Member

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.

<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>
Copy link
Member

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) {

Copy link
Member

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)$/,
Copy link
Member

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);
Copy link
Member

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) {
Copy link
Member

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'];
Copy link
Member

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"
Copy link
Member

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?

Copy link
Member

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>
Copy link
Member

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.

@rohanpai rohanpai force-pushed the master branch 3 times, most recently from aff0c34 to 2281c3d Compare January 15, 2017 02:13
@rohanpai
Copy link
Contributor Author

@espadrine let me know what you think!

server.js Outdated
return;
}
try {
badgeData.text[0] = "Used by";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this line still needs to be removed and change Line 2997 to var badgeData = getBadgeData('used by', data);

or leave Line 2997 as is, but badgeData.text[0] is set via the first parameter when you call getBadgeData();

@rohanpai
Copy link
Contributor Author

Made requested changes cc @RedSparr0w @espadrine

Thank you!

@rohanpai
Copy link
Contributor Author

@espadrine does this look ready to merge? Thanks!

@rohanpai
Copy link
Contributor Author

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.

@RedSparr0w
Copy link
Member

@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.
Although i'm sure it wont be too long before it gets merged. [=

@paulmelnikow paulmelnikow added the service-badge Accepted and actionable changes, features, and bugs label Mar 27, 2017
@Daniel15
Copy link
Member

Daniel15 commented May 6, 2017

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!

@Daniel15 Daniel15 merged commit f97d5a6 into badges:master May 6, 2017
@Daniel15 Daniel15 added this to the Next Deploy milestone May 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants