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

Enable overriding the message of a json endpoint through the query string in the URL #6815

Open
HannesWell opened this issue Jul 24, 2021 · 9 comments
Labels
question Support questions, usage questions, unconfirmed bugs, discussions, ideas

Comments

@HannesWell
Copy link

HannesWell commented Jul 24, 2021

📋 Description

It is possible to override for example the label of a JSON endpoint in the query string like this:
https://img.shields.io/endpoint?label=another%20label&url=<URL-to-my-endpoint>.json

But it does not seem to be possible to override the message of a JSON endpoint through the query string like this:
https://img.shields.io/endpoint?message=another%20message&url=<URL-to-my-endpoint>.json
It would be great if overriding the message trough the query string would be possible, too.

We consider to provide a unified badge template by using a JSON endpoint, that can be used by multiple Eclipse projects and where each project only overrides the message with its name in the URL. This way all projects use similar badges with an individual message.

@paulmelnikow
Copy link
Member

Possibly related to this use case: #6786

@paulmelnikow paulmelnikow added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Jul 24, 2021
@HannesWell
Copy link
Author

Thanks for the reference, but I have to admit that I'm new to badges and not familiar with the deep details and therefore don't fully understand the conversation.

Our intention why we consider to use an own JSON endpoint is to be able to configure the entire badge, except for the message, at one location. Each Eclipse-project using that badge should only have an individual message, that is expected to be the project name.
In case the badge should change one day (e.g. because Eclipse changes its branding colours) it would only be necessary to modify the JSON file at one location and all badges that use it should change accordingly.

Do you think another approach would be more suitable in our situation?

If you are interested in some more details, you can find them here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=574646

@paulmelnikow
Copy link
Member

It sounds like the ask is to be able to specify a collection of static badges whose formatting is specified in a JSON file and the message in a query parameter.

I could imagine this being solved with a new endpoint for a collection of static badges, along the lines of the proposal I described in #6786 (comment). That would require adding an entry for each project into the JSON file.

However for your use case, I think a better solution would be to check in a script which fetches a list of the projects, generates the static SVGs, and dumps them onto a CDN somewhere – probably in the same place you were thinking of putting that endpoint JSON file.

@calebcartwright
Copy link
Member

It sounds like the ask is to be able to specify a collection of static badges whose formatting is specified in a JSON file and the message in a query parameter.

That was my sense as well, with the underlying motivating use case being the desire to be able to centrally manage/bulk update a set of similar-but-not-identical static badges used in different repositories.

@HannesWell - I can understand the desire to automate/simplify the process of updating a bunch of images, but I personally think that capability is outside the remit of Shields; the Endpoint badge is definitely not geared towards that type of use case.

I was going to suggest something very similar to what Paul suggested, with the option of just using GitHub to host the svg files (so the aforementioned script could just check them into source) and then using <img> with the respective githubusercontent urls to add the badges to the respective projects.

@paulmelnikow
Copy link
Member

with the underlying motivating use case being the desire to be able to centrally manage/bulk update a set of similar-but-not-identical static badges used in different repositories.

👍

@HannesWell
Copy link
Author

It sounds like the ask is to be able to specify a collection of static badges whose formatting is specified in a JSON file and the message in a query parameter.

Yes, we would like to generate badges that all have the same formatting, colour and label and only have an individual message-text.

Thanks for your suggestions.
In principle there is a list of relevant projects that could use the badges and it probably would be possible to generate the entries for a collection of static badges from that list or to generate and store the static svg-files directly.
However being able to modify the message from the query string would just make thinks a lot more easy, but of course the scope of shields is not all-embracing.

I just wonder why it is possible to override the label from the query string, but it is not possible to override the message? From my naive perspective the difference is only that the label is the text on the left and the message the text on the right of a badge.
Naively spoken, if we have decided to put the individual text on the left, it were already possible to accomplish our goal. Or is this only by chance.

@paulmelnikow
Copy link
Member

paulmelnikow commented Jul 26, 2021

The use case for customizing the label is when you want to display two CI badges, and need to differentiate them (i.e. they can't both be labeled "build"). In that case there's no need to override the right text.

I think the reason you're finding this mismatch in capabilities surprising is that you're using Shields in a way more like what was requested in #2824, for making a custom action button, whereas Shields is primarily designed for rendering status badges. We of course don't mind that you use Shields for these buttons, but at the same time, well, it isn't the primary use case for which Shields was intended.

Thinking more about #2824 and how these buttons have been used in the wild, another design suggestion would be to exclude the package name from the button entirely:

https://img.shields.io/static/v1?logo=eclipseide&label&color=orange&message=Create+Development+Environment&style=for-the-badge&logoColor=white

Then they're all the same and you can generate it once and pop it on a CDN somewhere.

@HannesWell
Copy link
Author

Thanks for the explanation. I expected a reason pointing in that direction.

Your design suggestion would be another option. However it would be nicer to 'personalize' the buttons for each project.
But I will see how we will handle this problem in the end.
Anyway, thanks again.

@JP-Ellis
Copy link
Contributor

I stumbled on this issue as I was running into the same issue myself.

I was wanting to create a badge that is similar to a lot of status badges where the left side shows the category, and the right side shows information about the category. For example:

Pypi

In my specific case, I want a family of badges such as:

  • Pact Badge
  • Pact Badge
  • Pact Badge
  • Pact Badge
Screenshot of above if links change in the future image

I clearly don't want to create every iteration of the right hand side.

Is this something that endpoints aren't intended to support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Support questions, usage questions, unconfirmed bugs, discussions, ideas
Projects
None yet
Development

No branches or pull requests

4 participants