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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variable URL goto feature #5135

Open
mihaigalos opened this issue May 27, 2020 · 8 comments
Open

Variable URL goto feature #5135

mihaigalos opened this issue May 27, 2020 · 8 comments
Labels
service-badge Accepted and actionable changes, features, and bugs

Comments

@mihaigalos
Copy link

mihaigalos commented May 27, 2020

馃搵 Description

I am currently generating a variable url in a badge, by pushing data to an online clipboard (i.e. cl1p) and then reading it in the badge:
Custom badge
(snapshot in case the data gets deleted):
image

The data in question represents build stat information.
I would like to be able to click-go to the displayed URL.

馃敆 Data

The data displayed by the badge is a simple json with an url.

curl -X GET https://api.cl1p.net/my_clipboard                                                                       1,000s 
{"schemaVersion":1,"label":"logs","message":"https://app.buildbuddy.io/invocation/8edc9921-0848-4fd1-8441-552512cad509","color":"orange"}

馃帳 Motivation
This would be an awesome feature to have, since build logs outside of mainstream CI systems often change and typically contain a variable hash.

@mihaigalos mihaigalos added the service-badge Accepted and actionable changes, features, and bugs label May 27, 2020
@mihaigalos
Copy link
Author

The way I envision this is having a "follow_url=true" somewhere in the url of the badge.
This would guarantee that that which is displayed is the same as the pointed-to url endpoint.

The user can then judge by themselves if they trust going to that endpoint or not.

@paulmelnikow
Copy link
Member

Badges have a link feature. It鈥檚 not turned for Endpoint right now but could be if it helps your use case.

Could you try experimenting with a static badge with links and see if it works for you? In general for links to work, you need to embed the badge using <object>, not <img>. Also links won鈥檛 work on GitHub because of restrictions in camo, the proxy that serves images on GitHub.

The other thing we could possibly do is add a feature in Shields that would provide a link redirect for the endpoint badge. Although because of how caching works it might go to a newer or older link than the badge itself.

@mihaigalos
Copy link
Author

mihaigalos commented May 27, 2020

In general for links to work, you need to embed the badge using <object>, not <img>

this looks like html, whereas my usecase is plain old Markdown :
![Custom badge](https://img.shields.io/endpoint?style=social&url=https%3A%2F%2Fapi.cl1p.net%2Fmy_clipboard).

The other thing we could possibly do is add a feature in Shields that would provide a link redirect for the endpoint badge. Although because of how caching works it might go to a newer or older link than the badge itself.

That also sounds good.

Another ideea would be to just copy the endpoint url in the clipboard when clicking on the badge. I don't mind opening a tab by myself, as long as I have the url in the clipboard to fast-paste it in.

@paulmelnikow
Copy link
Member

The Markdown spec allows embedding HTML. Where are you serving the rendered Markdown?

@mihaigalos
Copy link
Author

I'll see if I have time to play around further, I suspect not a lot.
I'm hosting it here, functionality introduced with mihaigalos/osi-stack#11.

Thanks for the support! 馃憤

@paulmelnikow
Copy link
Member

paulmelnikow commented May 27, 2020

Yea, so on GitHub, links embedded into badges are not going to work.

It looks like cl1p has a redirect feature. What if you post just the link into a second clipboard, and then wrap your badge with a link to that?

By the way, is there anything that prevents other people from writing garbage to your clipboard? 馃

@mihaigalos
Copy link
Author

It looks like cl1p has a redirect feature.

This is precisely what I'm using to display the endpoint in the badge. The query goes to cl1p which redirects to my build logs.

By the way, is there anything that prevents other people from writing garbage to your clipboard? thinking

Yes. You can use basic auth to prevent unauthorized access, if need be.

@paulmelnikow
Copy link
Member

My suggestion is to post the link to a second cl1p and use that as your dynamic redirect target.

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

No branches or pull requests

2 participants