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

[eluser]Devon Lambert[/eluser]
No,

Actually the issue I was having was with the dynamic calling of files within a group, but once I played with it some more, I managed to resolve the issue on my own.

Great Library again!

Big Grin
#32

[eluser]tonydewan[/eluser]
Awesome! Thanks for the kind words.
#33

[eluser]Kim Wickell[/eluser]
Just noticed Carabiner and my first impressions are really good.
I have one question that i have been trying to find an answer to though...

Is there any way have assets used on every/most pages autoload or to declare groups of assets somewhere for easy access, without going into my controls?
I would like to keep as much of the design separate from logic as possible.

Thanks
/Kim
#34

[eluser]Devon Lambert[/eluser]
[quote author="Kwickell" date="1247595948"]Just noticed Carabiner and my first impressions are really good.
I have one question that i have been trying to find an answer to though...

Is there any way have assets used on every/most pages autoload or to declare groups of assets somewhere for easy access, without going into my controls?
I would like to keep as much of the design separate from logic as possible.

Thanks
/Kim[/quote]

Hi Kim,

I was having this exact same issue! I wanted an easy way to package up all the necessary css and js files that the site uses on the whole, but then also make use of some dynamic/on-the-fly scripts through out my site. Carabiner definitely handles this nicely with the groups feature.

Go the the carabiner.php file found in your config folder. look for the groups section.

The syntax you will need to use will look something like this:
Code:
//For Javascript
$config['groups']['site_js'] = array('js' => array(array('js_filename.js')));

// For CSS
$config['groups']['site_css'] = array('css' => array(array('css_filename.css')));

You could then reference these global groups wherever you need it with:
Code:
$this->carabiner->display('site_js');
$this->carabiner->display('site_css');
#35

[eluser]tonydewan[/eluser]
@dnyce You beat me to the reply. @Kwickell I'm glad you like it. @dnyce's answer is exactly what I was going to recommend. The other option would be to define groups/assets in a parent controller, like in a MY_controller class, but the config file option is the best.

Good luck!
#36

[eluser]ainstushar[/eluser]
Hi there, thanks for the amazing library. I think it's excellent Smile

(I am new at CI, so bear with me if I say something stupid.)

Your library looks for all of the css files in a css folder, so if you want to load a css file that is outside of your style_uri, then you are in bad luck.

Script folder: /assets/css
Want to include: /assets/js/asdf/asdf.css (the css is part of a js framework, so it's better if that css stays in that folder)


I got around this problem by changing how the $dir variable is created.

Code:
private function _tag($flag, $ref, $cache = FALSE, $media = 'screen')
    {

        switch($flag){
        
            case 'css':
                // Detect '/' at the beginning
                (strpos($ref, '/') === 0) ? ($dir = ( $this->isURL($ref) ) ? '' : ( ($cache) ? $this->cache_uri : $this->style_uri )) : $dir = '';
                
                return '<link type="text/css" rel="stylesheet" href="'.$dir.$ref.'" media="'.$media.'" />'."\r\n";
            
            break;

            case 'js':
                // Detect '/' at the beginning
                (strpos($ref, '/') === 0) ? ($dir = ( $this->isURL($ref) ) ? '' : ( ($cache) ? $this->cache_uri : $this->script_uri )) : $dir = '';
                
                return '[removed]CI->config->item('charset').'">[removed]'."\r\n";
            
            break;
        
        }
    
    }

You see, my addition looks for '/' at the beginning of the path. If it finds it, then it won't append the style_uri. That way, if I want to include a that css, I would just type in
Code:
$this->carabiner->css('/assets/js/asdf/asdf.css');

I think that addition gives the developers more flexibility and gives this library 1 more feature.

Then again, I could be way off since I am just starting out with CI.

What do you think? And btw, that change works with including javascript files that are not in script_uri folder.

I hope that you can incorporate my changes in the next version.
Thanks.
#37

[eluser]Kim Wickell[/eluser]
Thanks!
That was exactly what i was looking for.

So simple and yet so powerfull, i think im slowly falling in love yet again Tongue
#38

[eluser]tonydewan[/eluser]
@ainstushar I'm glad you like it! That's an interesting problem that I hadn't yet run into. Also, that's pretty close to how I would have solved it as well. Good solution! Another thing for people to consider if they don't want to change the lib themselves but need this functionality is to reference those assets via URL. For your example, you could do something like:

Code:
$this->carabiner->css(base_url().'assets/js/asdf/asdf.css');// you'll need the URL helper loaded for the base_url() function

Of course, that would be slightly less efficient, as PHP would be getting the contents via an HTTP request versus a file read, but it solves the problem in the short term. I'll definitely look at putting a solution for this in the next version.

@Kwickell I'm glad it's working well for you. If you have any other problems, let me know.
#39

[eluser]K.Brown[/eluser]
Hey, this seems like a great library!

I'm having a problem with my server config, I think...

Quote:Severity: Warning

Message: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration

Filename: libraries/carabiner.php

Line Number: 822
A PHP Error was encountered

Severity: Warning

Message: file_get_contents(http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found

Filename: libraries/carabiner.php

Line Number: 822

Is there a work around for this?

I have this in my head view file:

Code:
<?php
    $this->carabiner->display('jquery');
?>
#40

[eluser]K.Brown[/eluser]
Eh, strike that. Something funky happened, but it's all good now! GREAT LIBRARY...I'll say it again: GREAT LIBRARY!




Theme © iAndrew 2016 - Forum software by © MyBB