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

Missing Folder class in asset_compressor.php #43

Closed
rynop opened this issue Apr 27, 2011 · 16 comments
Closed

Missing Folder class in asset_compressor.php #43

rynop opened this issue Apr 27, 2011 · 16 comments

Comments

@rynop
Copy link
Contributor

rynop commented Apr 27, 2011

Just starting to use this plugin - looks very promising, nice work. Js is working fine for me, but when the css_files controller is getting hit, I get:

Fatal error: Class 'Folder' not found in <myapp>/app/plugins/asset_compress/models/asset_compressor.php on line 89 

Do you just need to do a App::import('Core', 'Folder'); before Making a Folder obj on line 89? or is my app not including this core library for some reason, when it should be?

When I add the import line to line 89, and re-run I get:

Failed to load source for: https://<mylocalhostdomain>/cache_css/be2b2b82466d97e351dc2a17c872742d.css?file[]=pages/home&file[]=common/custom&file[]=common/jquery.qtip

Here is the HTML:

<link href="/cache_css/be2b2b82466d97e351dc2a17c872742d.css?file[]=pages/home&amp;file[]=common/custom&amp;file[]=common/jquery.qtip" type="text/css" rel="stylesheet">

Here is my ini. My routes are copy/paste from the wiki.

[Javascript]
searchPaths[] = WEBROOT/js/
searchPaths[] = WEBROOT/js/common/
searchPaths[] = WEBROOT/js/plugins/
stripComments = true
cacheFilePath = WEBROOT/cache_js/
cacheFiles = true
filters[] = JsMin
timestamp = true
stripComments = true

[Css]
searchPaths[] = WEBROOT/css/
searchPaths[] = WEBROOT/css/common/
searchPaths[] = WEBROOT/css/pages/
stripComments = true
cacheFilePath = WEBROOT/cache_css/
cacheFiles = true
filters[] = CssMin
timestamp = true
stripComments = true

I've tried removing CssMin filter, but run into same problem.

1 more piece of info that may help, my web user has write permissions to app/webroot/cache_js and app/webroot/cache_css but I dont see any files written into them.

I'm ubuntu 10.10 64bit, PHP 5.3.3.

any ideas? thx in advance.

@markstory
Copy link
Owner

I've not run into this before. However, the cache files will only be written if debug = 0 and the cacheFiles config setting is true.

Normally if AssetCompress can't find a source file it tries to log a message. If the issue is coming from a missing file, check your app's logs, there might be something there. I can add the extra folder import though, it won't hurt anything.

@rynop
Copy link
Contributor Author

rynop commented Apr 28, 2011

thanks for the quick reply. I figured it out.

So turns out I do need to add the import of Folder to 89, otherwise I always get that error.

The reason why my css was not rendering was because the CssStripCommentsFilter seems to not like some comments in one of my css files, and it was regexing out all my css files. I tried for a while to figure out what exactly in the comment was causing problems - its actually a 3rd party library I use called qtip2, here is the comment block that is causing it to fail - i narrowed it down to the 3 lines beginning with 'Dual licensed...'. From a quick look at ur regex i dont see why that would be causing problems...

/*
* qTip2 - Pretty powerful tooltips
* http://craigsworks.com/projects/qtip2/
*
* Version: 2.0.0pre
* Copyright 2009-2010 Craig Michael Thompson - http://craigsworks.com
*
* Dual licensed under MIT or GPLv2 licenses
*   http://en.wikipedia.org/wiki/MIT_License
*   http://en.wikipedia.org/wiki/GNU_General_Public_License
*
* Date: Sat Jan 15 15:15:02 2011 +0000
*/

I'm cool with leaving comments in there, not that big of a deal given what i'm really looking for is to use your build shell as part of my production build scripts, to make my css/js files so i can upload em to my CDN.

yea duh I shoulda known the debug has to be 0 to write the file.

@Phally
Copy link
Contributor

Phally commented Apr 28, 2011

I'll have a look at that comment block later. In the mean time you could just disable the strip comments feature. Your config file shows you are using CssMin and that should remove comments as well.

Phally added a commit to Phally/asset_compress that referenced this issue Apr 28, 2011
@Phally
Copy link
Contributor

Phally commented Apr 28, 2011

I can't reproduce this in any way. I added it to a file and it was stripped correctly. Changed the committed version a bit so there aren't any weird copyright issues, but I tried with exactly the one you pasted.

-Mark, you could merge it in for next time.

@rynop
Copy link
Contributor Author

rynop commented Apr 28, 2011

I wonder if there is some strange encoding or something in the file. I can send you the file Phally if you want (email?). CssMin handles it just fine.

Mark - can you also add the App::import('Core', 'Folder'); in models/asset_compressor.php on line 89 when your in there?

thanks.

@Phally
Copy link
Contributor

Phally commented Apr 28, 2011

Yeah, i am one step ahead.. I got it failing on windows line endings, I am trying to fix it now.

Phally added a commit to Phally/asset_compress that referenced this issue Apr 28, 2011
@Phally
Copy link
Contributor

Phally commented Apr 28, 2011

Can you try my fork? I think it fixes it. However I don't have test cases for it, because making everything have windows line ending would screw up the test case. So your script is my test case hehe.

@rynop
Copy link
Contributor Author

rynop commented Apr 28, 2011

Yup that fixed it - stupid windows. You'll probably want to make a similar change to JsStripCommentsFilter obj.

Phally added a commit to Phally/asset_compress that referenced this issue Apr 28, 2011
@Phally
Copy link
Contributor

Phally commented Apr 28, 2011

Yes, you are right, forgot about that one. Those things are all fixed now. And yes, stupid Windows! The person who thought different types of line endings was a good idea needs a bitchslap.

@rynop
Copy link
Contributor Author

rynop commented Apr 28, 2011

coo man thanks. Once you guys put in the 'App::import('Core', 'Folder');' change I'll close. Or would u prefer I open another issue for that?

@Phally
Copy link
Contributor

Phally commented Apr 28, 2011

Nay keep this one open, it has the right title. I was holding back on that one for Mark, not sure if he added the line locally.

@rynop
Copy link
Contributor Author

rynop commented Apr 28, 2011

ok thanks. keep it up, this plugin freaking rocks.

@markstory
Copy link
Owner

Thanks for the patches Phally! I've merged them in and added the missing import.

@Phally
Copy link
Contributor

Phally commented Apr 29, 2011

Its the least I could do, since it is my fault it wasn't working in the first place hehe. Thanks for merging.

@rynop
Copy link
Contributor Author

rynop commented Apr 29, 2011

I don't see the App::import('Core', 'Folder'); added in the latest source ( https://github.com/markstory/asset_compress/blob/master/models/asset_compressor.php line 89). Is it in some other branch or something?

@markstory
Copy link
Owner

No I forgot to both commit and push the change :( It should be there now though.

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