ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Carabiner 1.4: Asset Management Library

June 01, 2009 3:30pm

Subscribe [76]
  • #151 / Aug 05, 2010 11:51am

    eedfwChris

    54 posts

    You can create the group in the config file just like the other predefined frameworks. Then call display(‘group’).

    And that would “echo” the js/css code in the view which is useless. Or am I mistaken?

    The idea here is to queue it so that you only have one display() in your layout/template/whatever.

    Edit
    One work around would be to pass the config variable back into the group() method (thus redefining the group).

    Not sure if tony is still maintaining this library but I’d like to fork it and change it up a bit. The method names alone are confusing to me at least (group(‘group) should just queue a group and then maybe there should be something like a set_group() or add_group() method for manipulating groups or go the other way and have a use_group() method to queue the group for display()). Otherwise this is a great library.

  • #152 / Aug 06, 2010 6:09am

    chefnelone

    157 posts

    Hello,

    The wiki says that base_uri is set by defaults to the CI config value for base_url.
    But that is not working fine for me:

    in application/config/config.php

    $config['base_url'] = "http://190.169.3.33/mySite/";


    It ONLY works fine if I do:

    $carabiner_config = array(
        'script_dir' => 'mySite/assets/scripts/', 
        'style_dir'  => 'mySite/assets/styles/',
        'cache_dir'  => 'mySite/assets/cache/',
        'base_uri'   => 'http://190.169.3.33/'
    );                
    $this->carabiner->config($carabiner_config);

    ...but I’like to remove ‘mySite’ from ‘script_dir’, ‘style_dir’ and ‘cache_dir’. And remove base_uri from the array also

    I tried with: (get a path error)

    $carabiner_config = array(
        'script_dir' => 'assets/scripts/', 
        'style_dir'  => 'assets/styles/',
        'cache_dir'  => 'assets/cache/',
        'base_uri'   => 'http://190.169.3.33/mySite/'
    );                
    $this->carabiner->config($carabiner_config);

    ... and also removing base_uri from the array (get a path error)

    $carabiner_config = array(
        'script_dir' => 'assets/scripts/', 
        'style_dir'  => 'assets/styles/',
        'cache_dir'  => 'assets/cache/'
    );                
    $this->carabiner->config($carabiner_config);


    The path error says:

    Message: file_put_contents(/Applications/MAMP/htdocs/assets/cache/0000000000d41d8cd98f00b204e9800998ecf8427e.js) [function.file-put-contents]: failed to open stream: No such file or directory
    Filename: libraries/carabiner.php

    anyone to help me??

  • #153 / Aug 06, 2010 7:56am

    chefnelone

    157 posts

    SOLVED updating to version 1.45

    Hello,

    The wiki says that base_uri is set by defaults to the CI config value for base_url.
    But that is not working fine for me:

    in application/config/config.php

    $config['base_url'] = "http://190.169.3.33/mySite/";


    It ONLY works fine if I do:

    $carabiner_config = array(
        'script_dir' => 'mySite/assets/scripts/', 
        'style_dir'  => 'mySite/assets/styles/',
        'cache_dir'  => 'mySite/assets/cache/',
        'base_uri'   => 'http://190.169.3.33/'
    );                
    $this->carabiner->config($carabiner_config);

    ...but I’like to remove ‘mySite’ from ‘script_dir’, ‘style_dir’ and ‘cache_dir’. And remove base_uri from the array also

    I tried with: (get a path error)

    $carabiner_config = array(
        'script_dir' => 'assets/scripts/', 
        'style_dir'  => 'assets/styles/',
        'cache_dir'  => 'assets/cache/',
        'base_uri'   => 'http://190.169.3.33/mySite/'
    );                
    $this->carabiner->config($carabiner_config);

    ... and also removing base_uri from the array (get a path error)

    $carabiner_config = array(
        'script_dir' => 'assets/scripts/', 
        'style_dir'  => 'assets/styles/',
        'cache_dir'  => 'assets/cache/'
    );                
    $this->carabiner->config($carabiner_config);


    The path error says:

    Message: file_put_contents(/Applications/MAMP/htdocs/assets/cache/0000000000d41d8cd98f00b204e9800998ecf8427e.js) [function.file-put-contents]: failed to open stream: No such file or directory
    Filename: libraries/carabiner.php

    anyone to help me??

  • #154 / Aug 09, 2010 10:07pm

    TigerWolf

    15 posts

    I got this error when turning on Carabiner to production mode:

    <h4>A PHP Error was encountered</h4>
    
    <p>Severity: Warning<br />
    Message:  file_get_contents() [<a href="http://function.file-get-contents">function.file-get-contents</a>]: Filename cannot be empty<br />
    Filename: libraries/carabiner.php</p>
    
    <p>Line Number: 942

    Did I mess something up or is this a bug?

    After refreshing the error goes away but then the site has two JS files from the cache folder in the top of the page and one of them is empty. If I comment out $this->carabiner->display(); then only one appears. I have not set any JS in the controller but want the ability to.

  • #155 / Aug 09, 2010 10:16pm

    TigerWolf

    15 posts

    Is it possible to call a group from the config:

    $this->carabiner->js(‘groupname’);

    Instead of:

    $this->carabiner->display(‘groupname’);

    So that this can be called?

    $this->carabiner->display();

  • #156 / Aug 10, 2010 11:48am

    eedfwChris

    54 posts

    Is it possible to call a group from the config:

    $this->carabiner->js(‘groupname’);

    Instead of:

    $this->carabiner->display(‘groupname’);

    So that this can be called?

    $this->carabiner->display();

    I’ve asked the same thing a few threads up. I haven’t been able to find a way to do this. I even tried to load it from the config itself with not luck. I don’t think it’s possible so I stopped using groups for the most part.

  • #157 / Sep 20, 2010 11:06pm

    billdami

    3 posts

    Sorry if this was already asked, but I am very interested in this library but I was wondering if it would handle loading of javascript that was actually contained in a .php view file and wrapped in script tags? Reason why I am doing this is that I have a localization library that gets the correct translation for a phrase/word from a database table based on the user’s language preference. (i.e. alert(’<?=$this->localize->getline(‘some_text’);?>’);).

    It would be awesome if Carabiner would run this script and then treat it as a normal JS file and perform the minification, caching ect.

  • #158 / Sep 20, 2010 11:16pm

    pickupman

    1317 posts

    What I do is treat all of files like jquery plugins and such to be handled by carabiner. Then for page specific js or php files I want to include, I use in my master view/template

    //In master templat/view
    if(isset($jquery)){
      echo $jquery;
    }
    
    //In controller
    $data['jquery'] = $this->load->view('js_php_file.php', $data, TRUE); //return view and store in variable
    
    $this->load->view('master_template', $data);
  • #159 / Sep 21, 2010 7:39pm

    tonydewan

    100 posts

    Sorry if it seems like I’ve abandoned this thread. I haven’t been getting notified about the replies. :(

    Let me first say: I haven’t touched Carabiner in a long time. My life is pretty much all Ruby and JavaScript at this point, and I haven’t used CI for some time. Having said that, I’m still more than happy provide support in these forums. Having said that, I still see Carabiner as pretty much feature complete. The last thing I wanted to add (support for adding “extensions” to Carabiner) has been completed and in the codebase (in the extend branch in GitHub) since November of last year. I haven’t released it, as I haven’t had the time or motivation to adequately test it. Anyone can feel free to clone, fork, test or submit code. I’d be happy to give anyone an overview of the current extension philosophy, though it should be pretty well commented in the code. I do still plan to get to it at some point, I just can’t say when.

    Now, I’ll try to answer all the questions I missed from the past several months. Anything older than that is probably not worth answering.

    @zombaya and @mikedfunk Those are solid additions. If you want, fork me on github and submit pull requests with the changes.

    @vertmonkee Not with Carabiner. As mentioned, there are other ways.

    @webPragmatist You had a bunch of questions that didn’t really get answered. I’ll answer them in reverse: First, feel free to fork: http://github.com/tonydewan/Carabiner. I’d be happy to still maintain the codebase if you want to submit Pull requests. In terms of “queueing” groups, I think what you want is the display_string method. It will return a string of the display result, rather than just echoing. The display method is meant to be used in views, which is why it works the way it does. display_string will allow you to call it in controllers and use the resulting string as you see fit. Third, your best bet is to use the parent folder as the config value, and just deal with longer paths.

    @TigerWolf I’m not totally sure what you mean. Are you saying you want to add a group as an item in another group? If so, then no, that won’t work.

    @Bulletz I haven’t ever tried this, but it should work. You might have issues with the caching conflicting with the internationalization output. However, as long as the “filenames” you reference are unique (for example “internationalize.php?lang=en” versus just “internationalize.php”) it should work okay. You’ll probably run into issues if the php files are running through the whole CI stack, rather than just bare php. Let us know if it works.

    I hope that helps people. Thanks everyone for using Carabiner! I’m glad it’s been useful.

  • #160 / Oct 28, 2010 1:31pm

    msteudel

    36 posts

    One optimization that is often recommended is to load the css first, that way the user starts to see styles sooner making their user experience better. Looking at the way Carabiner loads in the jS and css it loads the css last, even if I declare it first. Any reasons on this? Note that I’m loading css first then js second, does it happen to load things in first in last out?

  • #161 / Oct 28, 2010 5:16pm

    tonydewan

    100 posts

    Interesting point. Are you calling the display() method without any parameters? You could probably do $this->carabiner->display(‘css’); and $this->carabiner->display(‘js’); and load them wherever and whenever you want.

  • #162 / Oct 28, 2010 5:36pm

    msteudel

    36 posts

    Yeah I was loading without any params. I’ll try loading the groups individually first ...

  • #163 / Nov 24, 2010 9:18am

    Maglok

    402 posts

    Greetings,

    I am trying to work this library. So far it is promising, but I am having a problem. It seems to use the full FCPATH with index.php attached, while it needs to not use that. I saw some references to that in this thread, but most say it is fixed in 1.45.

    I have DLed 1.45 though, from the start.

    So it outputs this: /home/content/85/5336885/html/test/index.php
    While it should use: /home/content/85/5336885/html/test/

    My setup vars are simple:
    js: scripts/
    css: css/
    cache: cache/

    So I end with this as a url: /home/content/85/5336885/html/test/index.phpcache

    That doesn’t work. 😊

    I am quite unfamiliar with FCPATH to begin with, so where am I going wrong?

  • #164 / Nov 24, 2010 9:38am

    pickupman

    1317 posts

    FCPATH in defined in index.php. You can check to see if you have edited anything from there. Here’s what mine looks like:

    // Path to the front controller (this file)
        define('FCPATH', str_replace(SELF, '', __FILE__));
        
        // Name of the "system folder"
        define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));        
    
    
        // The path to the "application" folder
        if (is_dir($application_folder))
        {
            define('APPPATH', $application_folder.'/');
        }
  • #165 / Nov 24, 2010 9:43am

    Maglok

    402 posts

    According to my index.php

    /*
    |---------------------------------------------------------------
    | DEFINE APPLICATION CONSTANTS
    |---------------------------------------------------------------
    |
    | EXT        - The file extension.  Typically ".php"
    | FCPATH    - The full server path to THIS file
    | SELF        - The name of THIS file (typically "index.php")
    | BASEPATH    - The full server path to the "system" folder
    | APPPATH    - The full server path to the "application" folder
    |
    */
    define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
    define('FCPATH', __FILE__);
    define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
    define('BASEPATH', $system_folder.'/');

    The comment is saying the full server PATH to this file. That seems to suggest it includes index.php. If that is so though, isn’t the code in Carabiner (it uses FCPATH) ‘wrong’?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases