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

Allow to set the file size limit of image inlining to zero to inline all files #789

Merged
merged 1 commit into from
Aug 13, 2012

Conversation

cpojer
Copy link
Contributor

@cpojer cpojer commented Aug 13, 2012

See the title :)

{limit: 0} will now inline all images.

@geddski
Copy link
Contributor

geddski commented Aug 13, 2012

why u no tests?

@cpojer
Copy link
Contributor Author

cpojer commented Aug 13, 2012

There doesn't seem to be an appropriate framework to do this kind of test and I have no interest in adjusting the test framework for this very minor change. All the existing tests pass. Feel free to add tests or reject this pull request based on this response.

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

He's right, I think we only have diff based testing in place atm. We should change that :D

@@ -51,24 +51,23 @@ var mimes = {
module.exports = function(options) {
options = options || {};

var sizeLimit = options.limit || 30000
var sizeLimit = (options.limit != null) ? options.limit : 30000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unneeded parens

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

You could pass Infinity though.

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

I think in that case intent would be more clear.

@geddski
Copy link
Contributor

geddski commented Aug 13, 2012

makes sense. The diff testing is pretty slick though.

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

@GEDDesign I wouldn't get rid of diff testing at all

@cpojer
Copy link
Contributor Author

cpojer commented Aug 13, 2012

Amended my commit, I forgot you guys don't like readable code so much :P

-Infinity won't work when using the plugin from the command line as it is not valid JSON. I'm ok with -1, just say the word. I think 0 is pretty clear though (as in: "zero file size limit").

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

I do like the url definition improvements though in this patch

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

But to be honest if we are gonna special case 0 might as well consider false to disable the limit.

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

Oh nevermind we got that. We should document it then, and I'm down to merge it

@geddski
Copy link
Contributor

geddski commented Aug 13, 2012

limit: 0 could be interpreted as "limit it to zero". What about limit: false?

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

Yep, in that regard limitting to zero is same as limiting to -1 (or -Infinity but that's overkill for file sizes). But the intent of limiting to zero in this case is to disable it, which is what confused me haha

@cpojer
Copy link
Contributor Author

cpojer commented Aug 13, 2012

Pick one now.

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

So I guess the optimal solution would be:

if ('number' == typeof options.limit && buf.length > options.limit)

0 doesn't get special treatment, you can still disable limits with false or Infinity

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

Although you could also disable limits with true haha, but yeah, that's why we need docs.

… all files. Also fix some var-redeclarations.
@cpojer
Copy link
Contributor Author

cpojer commented Aug 13, 2012

done.

@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

Now it's not defaulting to 30000. I meant sizeLimit in my comment above, sorry about that.

rauchg added a commit that referenced this pull request Aug 13, 2012
Allow to set the file size limit of image inlining to zero to inline all files
@rauchg rauchg merged commit bb7d086 into stylus:master Aug 13, 2012
@rauchg
Copy link
Contributor

rauchg commented Aug 13, 2012

Fixed in master

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

Successfully merging this pull request may close these issues.

3 participants