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

Generated badge with port version #3

Open
AMDmi3 opened this issue Oct 1, 2015 · 53 comments
Open

Generated badge with port version #3

AMDmi3 opened this issue Oct 1, 2015 · 53 comments
Assignees

Comments

@AMDmi3
Copy link
Contributor

AMDmi3 commented Oct 1, 2015

Just a crazy idea. You've likely seen these badges used by many GitHub repos to report continous integration status and other stuff. Why not make FreshPorts generate a badge for a port by request? The badge should simply show DISTVERSION, like this:

FreeBSD port
FreeBSD port

This has numerous purposes among which is raising awareness of FreeBSD ports/Freshports among users, a convenient way to know the project is supported by FreeBSD and a way to know that the port is at latest version (or whether it falls behind).

The simplest way to implement this is just a make a per-port link (e.g. http://www.freshports.org/x11/xproto/badge or http://www.freshports.org/x11/xproto/?badge) which redirects to shields.io like https://img.shields.io/badge/FreeBSD_port-${DISTVERSION}-blue.svg. Or you could just generate the same .svg by yourself to not depend on third party site.

@dlangille
Copy link
Contributor

I do not recall seeing badges before.

Where would these badges appear?

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 1, 2015

@dlangille
Copy link
Contributor

I see what you mean now. It is a way for a given project to indicate that their software is available on FreeBSD.

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 1, 2015

Yes, however if you put it that way a project could just generate a badge themselves. With Freshports though, the badge will also show version which is a lot more useful. Just though that you can also indicate broken status with color.

FreeBSD port
FreeBSD port (BROKEN/IGNORE/DEPRECATED)
FreeBSD port (unknown port requested, e.g. the port was removed)

To catch removed ports it's looks better to be implemented as a separate script, e.g. freshports.org/badge.php?port=x11/xproto

@dlangille
Copy link
Contributor

Yes, the above is what I thought you were getting at. I suspect badges.freshports.org/x11/xproto sounds like fun.

@dlangille
Copy link
Contributor

I'd like commits.freshports.org instead of commit.php?message_id....

The goal being to make www.freshports.org 'cleaner'.

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 1, 2015

Yes, would be great!

You could also set up a script to generate markdown code suitable for inclusion in README.md, e.g.

[![FreeBSD port](http://badges.freshports.org/${CATEGORY}/${PORT})](http://freshports.org/${CATEGORY}/${PORT})

(this is badge image which links to port's page on freshports) and add link to that from

SVNWeb : Homepage : Distfiles Availability : PortsMon : Badge

line on a ports page.

@dlangille
Copy link
Contributor

After a short discussion at FreeBSD Developers summit in Stockholm, I think www.freshports.org/--/badges/ may be a better idea. Fewer certificates, host names, and web instances to maintain. It could also be used www.freshports.org/--/API/ (re https://duck.co/ideas/idea/936/grab-bsd-port-summary-from-freshports)

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 1, 2015

I'm good with either. Also 👍 to API, as with it FP could be also ingerdated with shields.io directly.

@dlangille
Copy link
Contributor

See http://dev.freshports.org/--/badges/?port=x11/xproto

Is this what you were expecting?

@dlangille
Copy link
Contributor

Proof of concept. There is no error handling yet (always returns 200).

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 21, 2015

Well not quite. It should either generate a redirect to badges.io link which it self shows a needed svg (example of such link is in the top post), or json with enough info for badges.io to generate it itself (which would be even better).

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 21, 2015

Actually badge can be generated from this as well, but i'd name it /version/ instead of /badge/ then, and JSON would still be more flexible.

@AMDmi3 AMDmi3 closed this as completed Oct 21, 2015
@AMDmi3 AMDmi3 reopened this Oct 21, 2015
@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 21, 2015

Oops, accidental close.

@dlangille
Copy link
Contributor

FYI badges.io is for sale.

@dlangille
Copy link
Contributor

@dlangille
Copy link
Contributor

Examples:

https://img.shields.io/badge/Bacula--Server-7.0.2_1-red.svg?style=plastic
https://img.shields.io/badge/bacula--server-7.0.2__1-red.svg

Next step: figure out JSON, which I'm not seeing a reference to on their website.

i.e. this does not work:

https://img.shields.io/badge/bacula--server-7.0.2__1-red.json

@dlangille
Copy link
Contributor

At present, http://dev.freshports.org/--/badges/?port=sysutils/bacula-client produces an IMG element if found, and a 404 otherwise.

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 22, 2015

  • It should produce link instead of img element as the latter cannot be embedded into markdown.
  • Version shouldn't include PORTREVISION and PORTEPOCH
  • Color should be blue by default (most packaging systems do so), and red if BROKEN/IGNORE is present
  • Instead of 404, it should produce a link to gray badge with "not found" text or something similar

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 22, 2015

  • Left-hand text should say "FreeBSD port" so it's apparent what the badge represents
  • This text should stay for `not found' case, e.g. FreeBSD port | not found

@dlangille
Copy link
Contributor

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 22, 2015

Apart from 2 items from my last comment, good.

@dlangille
Copy link
Contributor

Try now, not sure yet about the Not Found issue: http://dev.freshports.org/--/badges/?port=not/foundtest

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 22, 2015

Yes, almost good - I'd use lightgray instead of gray as it seems pretty common for other badges.

Also note that for not found case generated URL != generated img src (though img src is correct).

@dlangille
Copy link
Contributor

How's that?

@dlangille
Copy link
Contributor

Still to do: caching.

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 22, 2015

Absolutely perfect! Thank you!

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 23, 2015

Could you please remove now? I'd like to test this on one of my repos.

@dlangille
Copy link
Contributor

Done

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 23, 2015

Yeah, now it works:

https://github.com/AMDmi3/libSDL2pp/tree/ports-badge

Waiting for production state of this feature :)

Also not sure, but maybe s/Port/port/ would look a bit better.

@dlangille
Copy link
Contributor

I changed to lower case. Seems they are caching it.

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 23, 2015

Yep, github could. Direct link has lowercase port.

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 23, 2015

Although it is disturbing, seems like it's caching the redirect while it shouldn't - this means that even if the version is updated, GH will still show an old badge. According ti http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html, you should redirect with 303 (which is non cacheable) or provide corresponding Cache-Control / Expires headers.

@dlangille
Copy link
Contributor

Code was: header("Location: $badge");

now: header("Location: $badge", true, 303);

re http://php.net/manual/en/function.header.php

But it will take some time for that cache to wear off

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 23, 2015

Thank you! We'll see if it helps.

@dlangille
Copy link
Contributor

FYI, I am creating a branch, badges, so I can commit this work in progress without affecting production. Then I will checkout this code for use on http://beta.freshports.org/ and that will allow me to keep working on dev, which is my personal sandbox.

@dlangille
Copy link
Contributor

This should now work on http://beta.freshports.org/ :

Please update your URLs to point to beta, but anticipate that the URL / form may change after REST is implemented.

Expect dev to be broken for some time while I work on REST.

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Oct 26, 2015

Please update your URLs to point to beta, but anticipate that the URL / form may change after REST is implemented.

Done

@dlangille
Copy link
Contributor

I just pushed the badges branch. It's no longer just on my dev site.

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Mar 21, 2016

E.g. it should be available on freshports.org? It doesn't seem to (or is the url different?)

http://www.freshports.org/--/badges/?port=archivers/hlextract

 Sorry, but I don't know anything about that.

/--/badges/?port=archivers/hlextract

@dlangille
Copy link
Contributor

No, not yet. It is on the branch and needs to be merged into the main tree, but I want to configure caching before I do that.

@AMDmi3
Copy link
Contributor Author

AMDmi3 commented Sep 7, 2016

Any news on this?

@dlangille
Copy link
Contributor

It is sad isn't it?

I'm now busy with EuroBSDCon prep...

@dlangille
Copy link
Contributor

I managed to get this working in VMware on my laptop. I'm flying tomorrow.

@dlangille
Copy link
Contributor

dlangille commented Oct 22, 2016

I wonder what I need to cache here. It is just a redirect.

Here's the fetch:

[dan@dent:~] $ wget -S http://192.168.165.128/--/badges/?port=archivers/hlextract
--2016-10-21 21:42:18-- http://192.168.165.128/--/badges/?port=archivers/hlextract
Connecting to 192.168.165.128:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 303 See Other
Date: Thu, 20 Oct 2016 00:42:55 GMT
Server: Apache/2.2.31 (FreeBSD) PHP/5.5.32 mod_ssl/2.2.31 OpenSSL/1.0.2f DAV/2
X-Powered-By: PHP/5.5.32
Location: https://img.shields.io/badge/FreeBSD_port-2.4.4-red.png
Content-Length: 0
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html
Location: https://img.shields.io/badge/FreeBSD_port-2.4.4-red.png [following]
--2016-10-21 21:42:18-- https://img.shields.io/badge/FreeBSD_port-2.4.4-red.png
Resolving img.shields.io (img.shields.io)... 104.18.44.160, 104.18.45.160, 2400:cb00:2048:1::6812:2da0, ...
Connecting to img.shields.io (img.shields.io)|104.18.44.160|:443... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Sat, 22 Oct 2016 02:42:20 GMT
Content-Type: image/png
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=d47352fea27e152c5a71682f8bfc382501477104140; expires=Sun, 22-Oct-17 02:42:20 GMT; path=/; domain=.shields.io; HttpOnly
Cache-Control: max-age=86400
Last-Modified: Sat, 22 Oct 2016 00:29:12 GMT
Server: cloudflare-nginx
CF-RAY: 2f59986f8bb358af-DFW
Length: unspecified [image/png]
Saving to: ‘index.html?port=archivers%2Fhlextract’

index.html?port=archivers%2Fhlextract [ <=> ] 2.42K --.-KB/s in 0.001s

2016-10-21 21:42:21 (4.27 MB/s) - ‘index.html?port=archivers%2Fhlextract’ saved [2478]

[dan@dent:~]

@dlangille
Copy link
Contributor

Everything is just read from the DB. That should be fast for now. I'll see what I need to do to get this working on the plane tomorrow,

@dlangille
Copy link
Contributor

I do believe this has been merged from the badges branch to the master branch.

4e202da

I'll cleanup the files during the flight and this should be on dev.freshports.org later this weekend.

@dlangille
Copy link
Contributor

Reopening, until we are in production.

@dlangille dlangille reopened this Oct 22, 2016
@dlangille
Copy link
Contributor

I see we are in production. I missed that.

How's it looking?

@dlangille dlangille self-assigned this Nov 10, 2016
@dlangille
Copy link
Contributor

Still waiting to hear back from OP.

badges question raised again here: https://twitter.com/f0andrey/status/1049027503199858688

@grahamperrin
Copy link
Contributor

#3 (comment)

… for 'not found' case, …

See also:

Is there any overlap? (If not, I can delete this comment.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants