Giter Club home page Giter Club logo

Comments (22)

ngryman avatar ngryman commented on August 21, 2024 2

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.

ngryman avatar ngryman commented on August 21, 2024 2

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.

amio avatar amio commented on August 21, 2024 2

It works seamlessly πŸ‘

USAGE

https://badgen.net/https/badgesize-u29v2mhdzfej.runkit.sh/:compression/:filepath...

EXAMPLES

RUNKIT NOTEBOOK

https://runkit.com/amio/badgesize

from badge-size.

amio avatar amio commented on August 21, 2024 2

It's live now https://badgen.net/#badgesize

from badge-size.

styfle avatar styfle commented on August 21, 2024 1

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.

ngryman avatar ngryman commented on August 21, 2024 1

@amio It works the same as the current one, except you have to append .json.

from badge-size.

ngryman avatar ngryman commented on August 21, 2024 1

πŸ‘‹ @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.

ngryman avatar ngryman commented on August 21, 2024 1

It's live now! πŸŽ‰

from badge-size.

ngryman avatar ngryman commented on August 21, 2024

@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.

ngryman avatar ngryman commented on August 21, 2024

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.

amio avatar amio commented on August 21, 2024

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.

amio avatar amio commented on August 21, 2024

That would be good enough πŸ’ͺ

from badge-size.

ngryman avatar ngryman commented on August 21, 2024

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.

amio avatar amio commented on August 21, 2024

Great, what's the endpoint for this api?

from badge-size.

amio avatar amio commented on August 21, 2024

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.

ngryman avatar ngryman commented on August 21, 2024

@amio Awesome, closing this. Thanks again for the suggestion!

from badge-size.

styfle avatar styfle commented on August 21, 2024

@ngryman Is this deployed to production? img.badgesize.io

from badge-size.

styfle avatar styfle commented on August 21, 2024

@amio Should this be added to Badgen as a proper endpoint instead of relying on runkit?

from badge-size.

amio avatar amio commented on August 21, 2024

@styfle Yep, that runkit endpoint are for handy testing :D

from badge-size.

styfle avatar styfle commented on August 21, 2024

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.

amio avatar amio commented on August 21, 2024

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.

styfle avatar styfle commented on August 21, 2024

Oops, not sure how I missed that last example! Thanks! πŸŽ‰

from badge-size.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.