Welcome Guest, Not a member yet? Register   Sign In
Carabiner 1.2: Asset Management Library
#21

[eluser]tonydewan[/eluser]
@J. Brenne / umefarooq : The only difference in the internal _cache function between Carabiner 1 and 1.2 is the use of realpath(). To verify that this is in fact the problem, change this:

Code:
$filepath = realpath($this->cache_path . $filename);

To this:

Code:
$filepath = $this->cache_path . $filename;

In the _cache function (around line 615) in Carabiner 1.2. Let me know if that fixes your problem.


@12vunion Thanks for the tip. I'll include that change in the next release.
#22

[eluser]12vunion[/eluser]
Changed mine to:
Code:
$filepath = $this->cache_path . $filename;
if( !file_exists($this->cache_path) ){
    $filepath = realpath($this->cache_path . $filename);
}

It's not a proper way, but it gets around the problem of going between my local dev and my live server.
#23

[eluser]msch[/eluser]
This looks like an issue with certain versions of PHP where the Suhosin Patch was included.

realpath used to return false if the file did not exist, but will return true with the Suhosin patch as I understand it.

http://us2.php.net/realpath

Also, it looks like in version 1.2, this is all a non-starter because in the _cache() function that writes the cache files:

Code:
$filepath = realpath($this->cache_path . $filename);

will only ever return true or false, and thus no new file will ever get written.

I've simply removed the realpath() from that line to get things working for me.
#24

[eluser]msch[/eluser]
There appear to be quite a number of issues with 1.2. Passing arrays of css files doesn't seem to work, something with the 'dev' prepending.

Are you working on a newer version? I'm trying to decide if I'm going to fix this up for my purposes or just wait for 1.3.

I appreciate the effort you've already put in, thanks!
#25

[eluser]tonydewan[/eluser]
@msch I am working a new version. I can't say when it will be released. I'm sorry you're having so many issues with 1.2. Can you list any new ones not yet posted?

Quote:...will only ever return true or false, and thus no new file will ever get written.

That's not quite true. Realpath "returns the canonicalized absolute pathname on success." That's from the PHP manual. I recommended the fix you mentioned on Windows earlier in the thread. Are you on Windows?

Quote:Passing arrays of css files doesn’t seem to work.

That one is new to me. It all tested correctly before I released it. Perhaps your arrays aren't correctly formed? I'll look into it more for the next release. Also, does passing arrays of JS files work?

One final note, Feel free to send changes/fixes to me, and I'll include them in a future update.
#26

[eluser]msch[/eluser]
Thanks for the reply. Unless I'm missing something (which is totally possible, I've been writing a lot more ruby than php these days!), realpath() will always return true or false if the file/path does not exist. From my reading of the php manual:

realpath() returns FALSE on failure, e.g. if the file does not exist.

Therefore, trying to write to a file that doesn't exist using realpath() to pass the path shouldn't work. But as I said, I might be missing something. Smile

I was alluding to the fact that whether or not it returns false in this situation is dependent on if you're running the Suhosin patch or not (but that might be entirely unrelated.)

I'm running Apache/2.2.11 PHP/5.2.6-3 with Suhosin-Patch on Debian testing/unstable.

I'll follow up with some testing on the array passing. Though I did try passing things as both an array, array of array, with and without the 'screen','print' etc.

I'll dig in and try and put something more coherent together later today.

Thanks again.
#27

[eluser]msch[/eluser]
Surprise, surprise, I read the doc wrong. I am able to pass arrays of css files as long as i do it correctly with the pattern:
array( array(devfile.css, type, prodfile.css), array(devfile2.css, type, prodfile2.css) ).

Thanks for the lib.
#28

[eluser]tonydewan[/eluser]
I'm working on a new version of Carabiner, and I'm not sure what the best syntax for grouping should be. I'm interested in what other users thoughts are.

Here are a few of the options I've come up with:

Code:
// A whole new function called group
$js_assets = array(
    array('dev/prototype.js'),
    array('dev/prototype2.js'),
    array('dev/prototype3.js')
)

$css_assets = array(
    array('dev/prototype.css', 'screen'),
    array('dev/prototype_print.css', 'print'),
    array('dev/prototype_handheld.css', 'handheld')
)
$this->carabiner->group('prototype', array('js' => $js_assets, 'css' => $css_assets) );

Code:
// A parameter in the js/css functions
$this->carabiner->js( 'dev/prototype.js', 'prototype', 'prod/prototype.js' );
$this->carabiner->css( 'dev/reset.css', 'screen', 'main', 'prod/reset.css' );

I'm also wondering if perhaps there's room for two levels of grouping. For example, one might be called a package, and would contain mixed assets. An example would be a jQuery plugin that has a css file as well as a js file. The other might be called group, and contain only assets of the same type. Or perhaps this is an unnecessary abstraction...

Either way, you would be able to select a specific grouping in the display function. Here is an example. If you have a group called 'ie6', you could display it something like this:

Code:
$this->carabiner->display('ie6');

Let me know what you guys think.

Also, in my current development version, I've fixed several issues and added some functionality. I'm currently testing it, and it will be released soon.
#29

[eluser]Tom Schlick[/eluser]
hmm i like it. the grouping is very nice. i havnt tried this yet but does this provide a unique file name for each cached version? does it know when the file has changed and changes the cache? or does it just go by whenever the cache expires? what im trying to do is sort of version my css and js files if that makes any sense. kind of like facebook does where each file has a new generated cache hash for the name and every save it changes that. this is so you can set a far away cache date but have it update when you make changes because technically its a different file...
#30

[eluser]tonydewan[/eluser]
Quote:does this provide a unique file name for each cached version? does it know when the file has changed and changes the cache?

Yep. If you aren't doing any combination, but are minifying, each individual file will have a new cache file created whenever it changes. If you are combining, the cache will be updated whenever any of the files is updated. You could then use an .htaccess rule to set far future expiration headers for those cache files. Just know that Carabiner (currently) won't automatically remove old caches. You'll have to clean 'em out manually every once in awhile.

Beware that there is a bug in the current release affecting some people. It'll be fixed in the new release. See earlier in the thread for the fix.




Theme © iAndrew 2016 - Forum software by © MyBB