-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Enable `latest-version.json' endpoint #315
Conversation
(defn make-latest-version-json [group-id artifact-id] | ||
"Return the latest version of a JAR as JSON" | ||
(let [jar (find-jar group-id artifact-id)] | ||
(str "{\"version\":\"" (:version jar) "\"}"))) |
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.
I'm creating this JSON string here manually, as I figured that it doesn't justify pulling in cheshire into this namespace just for this.
This looks good to me so far. I'll take a closer look and merge before the next release. |
(= file-format "svg") (-> (response/response (view/make-latest-version-svg artifact-id artifact-id)) | ||
(response/header "Cache-Control" "no-cache") | ||
(response/content-type "image/svg+xml")))) | ||
|
||
(GET ["/:group-id/:artifact-id/latest-version.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.
Would you mind adding .json to this route as well? This route is used when the group doesn't match the artifact name (/org.clojure/clojure/latest-version.json
, for example). It might be worthwhile to extract the cond
out to a fn that you call from both routes.
My motivation for creating this is to be able to retreive the latest version of a given clojar as JSON in the format of: {"version": "x.y.z"} I'd like to have that option so that I can use it with the options as provided by http://shields.io/.
When the group is known but doesn't match the artifact name, so that it can be viewed as JSON or SVG e.g. /:group-id/:artifact-id/latest-version.:file-format
45c4154
to
a19d001
Compare
@tobias what do you think of this last change? Does it feel right to you? Thanks |
Enable `latest-version.json' endpoint
Looks good, thanks! |
This is now in production. |
Thank you @tobias :) |
The change for this to be used by http://shields.io/ is now live. Which is great. See how it looks: Should I change it so it looks more like: Thanks |
I think I prefer a combination of the two - I like showing the full coordinates in the badge, but prefer just "clojars", especially since the coordinates can be pretty long if a long group is included, and/or the version is long: |
OK, so what I've done is keep the 'clojars' only, omitting the '.org' part. But I'm leaving the full name & version, as I figure, that it would be practical to just cut & paste the name to be able to add it to project.clj. Created a pull request: badges/shields#431 |
That sounds good to me. Thanks! |
Enable `latest-version.json' endpoint
My motivation for creating this is to be able to retreive the latest
version of a given clojar as JSON in the format of:
{"version": "0.1.3"}
So that we can have pretty badges like this:
as provided by http://shields.io/.
I'm well aware that /some-clojar/latest-version.svg endpoint exists, and it renders the badge already. But isn't in the same format as all the badges provided by GitHub et la.
With this PR you get the uniform look of the badges handled for you by this third party service, should the users want to. All you've got to provide them with is JSON. Which, if we're going to split hairs, would consume less bandwidth than the XML currently generated.
Also, somebody already created a PR on the shields repo: badges/shields#388 where they would use the /search end point. Which isn't going to be very efficient, since it won't try to look up a particular clojar's version, but it'll search through all the clojars first, only to return the latest version of one clojar. Which isn't optimal.