Comments (22)
Hey @amio,
Thanks for your feedback!
I would not be in favor or returning all sizes at once as it would put load on the server and involve code changes specifically for this case. The vast majority of the time, people only advertise one kind of size. I would consider displaying several kind of sizes at once as an edge case that the user would have to deal with like: simply issue several requests Β―_(γ)_/Β―
For the options, I was thinking of a scenario where the end user was not passing the query string parameters himself (ie. badgesize
behind a proxy) but wanted to get the initial options back for some reason. But I guess that's redundant in most cases. So let's strip them for now!
Let's go with a simple:
{
size: string,
color: string
}
from badge-size.
That's a very good idea! I'm gonna alias shields named colors to hex colors, so other services can just rely on that.
from badge-size.
It works seamlessly π
USAGE
https://badgen.net/https/badgesize-u29v2mhdzfej.runkit.sh/:compression/:filepath...
EXAMPLES
- https://badgen.net/https/badgesize-u29v2mhdzfej.runkit.sh/normal/amio/badgen/master/README.md
- https://badgen.net/https/badgesize-u29v2mhdzfej.runkit.sh/brotli/amio/badgen/master/README.md
- https://badgen.net/https/badgesize-u29v2mhdzfej.runkit.sh/gzip/amio/badgen/master/README.md
RUNKIT NOTEBOOK
https://runkit.com/amio/badgesize
from badge-size.
It's live now https://badgen.net/#badgesize
from badge-size.
I think that should do it π
I would image the style
would be irrelevant for the purposes of Badgen since it will get overridden, but might as well leave it in there in case someone else wants to use it.
@amio Any other thoughts on this?
from badge-size.
@amio It works the same as the current one, except you have to append .json
.
from badge-size.
π @amio, sorry for the late answer. It's now live at http://next.badgesize.io/. Would you mind giving it a try? If everything is ok, I'll deploy it to http://img.badgesize.io/.
from badge-size.
It's live now! π
from badge-size.
@styfle Oh that's a very interesting idea, I like it!
So I guess I could support the .json
extension and return a JSON object like this:
{
size: string,
compression: 'gzip' | 'brotli' | null,
label: string,
color: string,
style: 'flat' | 'flat-square' | 'plastic',
max: number?,
softmax: number?
}
from badge-size.
I would image the style would be irrelevant for the purposes of Badgen since it will get overridden, but might as well leave it in there in case someone else wants to use it.
Yup agree with that statement. I'm just reflecting query string parameters just in case the consumer wants them. I could also group all them like this:
{
size: string,
color: string, // can be dynamically modified with max/softmax
options: {
compression: 'gzip' | 'brotli' | null,
label: string,
color: string,
style: 'flat' | 'flat-square' | 'plastic',
max: number?,
softmax: number?
}
}
from badge-size.
Return all size in a single endpoint would be more handy π€ e.g.:
https://api.badgesize.io/json/ngryman/badge-size/master/index.js
returns:
{
size: string,
gzippedSize: string,
brotliSize: string,
color: string
}
About the options, I think the query params could be omitted. If the querier pass the params in, they would not need to get those params from results, right? :D
from badge-size.
That would be good enough πͺ
from badge-size.
Hey guys,
It's live here: http://next.badgesize.io/.
Could you give it a spin to validate that it works correctly for you?
I ended up fixing the API to:
{
// Prettified size (ie. 14 KB)
prettySize: string,
// Original size in bytes (ie. 14000)
originalSize: number,
// Computed size with compression (ie. 2000).
// If no compression is specified it has the same value as `originalSize`
size: number,
// Computed color if size constraints are specified
// If no constraint is specified it will be equal to the input / default color
color: string
}
from badge-size.
Great, what's the endpoint for this api?
from badge-size.
Hi @ngryman, what about offering color
as RGB? Would be more compatible with other clients which don't have Shields's color schema.
from badge-size.
@amio Awesome, closing this. Thanks again for the suggestion!
from badge-size.
@ngryman Is this deployed to production? img.badgesize.io
from badge-size.
@amio Should this be added to Badgen as a proper endpoint instead of relying on runkit?
from badge-size.
@styfle Yep, that runkit endpoint are for handy testing :D
from badge-size.
Nice! But it looks like it only works for GitHub urls? However, I often use badge size for build output which doesnβt get checked into GitHub.
For example, see https://GitHub.com/styfle/copee
from badge-size.
Seems badgesize only support GitHub repo. For non-github use case, badgesize support a url, so does badgen's equivalent:
https://badgen.net/badgesize/normal/https://unpkg.com/snarkdown/dist/snarkdown.js
from badge-size.
Oops, not sure how I missed that last example! Thanks! π
from badge-size.
Related Issues (20)
- Badges with softmax never turn red
- Registry for img.badgesize.io has expired! HOT 7
- Still caching HOT 3
- Feature Request: Accept the bundle size as a parameter HOT 1
- Support reference style HOT 1
- Not working for non-GitHub file? HOT 2
- Consider adding optional threshold parameters for pass/fail HOT 1
- Update site to use https HOT 11
- Support brotli compression?
- support uglify HOT 2
- Strip sourcemap comment before calculating size? HOT 4
- Can It use for total repo size? HOT 2
- QUESTION: gzip size calculation HOT 2
- Borken? undefined-undefined-undefined.undefined HOT 3
- This deployment is not available anymore. HOT 1
- No longer working HOT 8
- Absolute URLs are not served anymore HOT 2
- Absolute URL cannot be displayed
- Absolute url no longer supported? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from badge-size.