-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Support .JSON output #264
Comments
Is this David-specific? I'm not sure how you would expect all badges to do that, especially considering the fact that each badge gets wildly different information from each vendor. |
That said, what is easy is to provide exactly the data that is written on the badge, including its color. |
maybe you could simply return the data retrieved from the vendor in some json format (dont need to be a similar pattern) or the simple/quick way would be your |
For many vendors, we don't simply receive some data; we compute data from multiple files. Sometimes we don't even get that data from files, but from HTTP headers. Many of the files we receive are not JSON. Having to maintain that would be a pretty hefty burden, let alone implement it. However, just like we have different badge styles, we could have a new "badge" which is actually JSON. The templates for those badge styles are in |
This is exactly what I need as well. Over at the @thephpleague we're looking to implement a more custom badge design, and having a JSON version would be awesome. Actually, a JSONP version would be better, to avoid any cross origin request issues. @espadrine With these templates, is it possible to set a different header than SVG? |
You can set up a different header by using a distinct extension. Much like there is |
Cool. I'm thinking it would be handy to have both |
Just taking this a little further, I propose the shields_io_callback({
name: "Build",
value: "Passing"
}) Adding the values in: shields_io_callback({
name: '{{=it.text[0]}}',
value: '{{=it.text[0]}}'
}) Ideally, since JSONP normally accepts a callback, it would look something more like this. Although, I have no idea how difficult adding a callback like this is.
{{=it.callback}}({
name: '{{=it.text[0]}}',
value: '{{=it.text[0]}}'
}) And with {
name: "{{=it.text[0]}}",
value: "{{=it.text[1]}}"
} The reason I see JSONP as more valuable than JSON is because JSONP allows sites to consume this data using JavaScript, avoiding any server side code. Consider this example: $.ajax({
dataType: 'jsonp',
jsonpCallback: 'shields_io_callback',
url: 'http://img.shields.io/travis/thephpleague/plates.jsonp',
success: function (info) {
console.log(info.name);
console.log(info.value);
}
}); |
I disagree with the use of JSONP. I feel like this would be the perfect place to use CORS. I see no reason to restrain access from XHR, so having the following header is probably fine:
|
Of course, for some reason I keep thinking you're using GitHub Pages, which doesn't allow you to use CORS. Which clearly makes no sense, since this is a node app. |
The image delivery system is hosted on Heroku, so it should work. |
The PR is closed, but I'd like to let this issue linger on. I am not sure how to convey the information about this feature on the main page. |
it would be perfect to get the resulting information in a
json
format to use this service from the CLI.one can write a svg parser for that, but it would be great if i can do the following:
http://img.shields.io/david/gulpjs/gulp.svg
workshttp://img.shields.io/david/gulpjs/gulp.json
should work, and give me something like that:maybe even with more detailed information:
or maybe simply add an extra http header for that, e.g.
X-Shields-Dependencies=up-to-date
The text was updated successfully, but these errors were encountered: