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

[eluser]Johan André[/eluser]
Hey!

Is there anyway to check (and exclude) for duplicate js & css?

Also, is there a way to include resources (like googlemaps js) and serve it uncompressed even though the rest of the js is minified and combined?
#92

[eluser]tonydewan[/eluser]
@johan Currently, Carabiner does not check for duplicates. That's a good idea though. I'll add it to the list.

To prevent a resource from being combined/compressed, do this:

Code:
$this->carabiner->js('/path/or/url/to/file.js','path/or/url/to/production/file.js', FALSE, FALSE);

The first FALSE tells Carabiner not to combine the file, and the second one tells it not to compress (preprocess) it. Also, note that the second parameter should be passed as NULL if you don't have a pre-built production version, like this:

Code:
$this->carabiner->js('/path/or/url/to/file.js', NULL, FALSE, FALSE);
#93

[eluser]Mark Croxton[/eluser]
Thanks so much for this very useful library! I'm using the latest beta for a form automation framework but came across a small bug: when you don't have any of your included assets combined or minified a link to a non-existent cache file is still output.

The problem is around line 606-608 of the library file for js:
Code:
if( !file_exists($this->cache_path.$filename) )    $this->_combine('js', $files, $filename);

echo $this->_tag('js', $filename, TRUE);

For CSS around lines 752 - 758:
Code:
if( !file_exists($this->cache_path.$filename) ) $this->_combine('css', $files, $filename);

echo $this->_tag('css',  $filename, TRUE, $media);

Your code is not checking that a cache file was actually created before echoing a link to it... maybe you could have _combine() return true or false and check this before outputting the link? Or even better, check if _combine() needs to be run at all.
#94

[eluser]tonydewan[/eluser]
Thanks for the heads up, Mark! I've worked up a fix, and will be rolling it into the newest version.
#95

[eluser]demogar[/eluser]
I tried to make it work with an application I've been developing some weeks ago but I can't get it work. Also I tried the AssetLibPro (which I used before for some applications but wanted to give your lib a try) and same result.

This is what I get while trying to make it work with Carabiner:
Code:
Code:
$this->carabiner->css('style.js');
$this->carabiner->display('css');
---------------------------------
Error:
A PHP Error was encountered
Severity: Warning
Message: file_get_contents() [function.file-get-contents]: Filename cannot be empty
Filename: libraries/carabiner.php
Line Number: 942

The file generated by Carabiner is totally empty. I'm using within the app also:
- HMVC or Modular Extensions (I really don't remember what I decided to use)
- i18n library
- Zend trough CodeIgniter (so I can use Zend Lucene).

I think one of those libraries is maybe affecting the Carabiner Lib (for example i18 and HMVC modified the Router and Config Lib and maybe they cannot find the css files).

Could you give me any help for this? Thank you in advance! Smile
#96

[eluser]tonydewan[/eluser]
I would love to help. What version of Carabiner are you using?
#97

[eluser]demogar[/eluser]
Last (1.45). I tried before the 1.43 but I got more errors (almost all of them concerning the path to the files, it never found the correct files).
#98

[eluser]tonydewan[/eluser]
Is style.css at the location FCPATH/$script_dir/style.css? Are you on a Windows/IIS box?

Also, the only reason I can think of that any of those libs would affect Carabiner being able to find assets is if they messed with the FCPATH constant. That being said, I've never tested it with an HMVC tool, so I can't be sure that's not the problem. AssetLibPro having the same error tells me there is something bigger going on.

You could try setting the force_curl option to true, though based on that error message, I would guess that wouldn't work.

In trying to route out the issue, I would first verify that the _get_contents() method is actually getting a real reference. Test that by adding an
Code:
echo $ref;
at line 934. If that path is right, then there is something wrong with the file_get_contents() function in your PHP install. Changing force_curl to true should fix that.

If the path is wrong or empty, the next place to check is either the _minify() or _combine() methods, depending on your config settings. These are at line 893 and 855, respectively. These are called by the _display_css(), most probably in the conditional block starting at 725. I would print_r($this->css[$group]) around line 726 to make sure the list is correct.

That's as far as I can advise without more info from what your seeing after doing the above.

Good luck!
#99

[eluser]demogar[/eluser]
Update: tony you are great. It seems its working propperly.

Thank you for all your support Smile Great library and great support.

[eluser]tonydewan[/eluser]
No problem. Glad it's working!




Theme © iAndrew 2016 - Forum software by © MyBB