Welcome Guest, Not a member yet? Register   Sign In
AssetLibPro - An advanced CI Asset Library
#21

[eluser]TheLoops[/eluser]
[quote author="Ignacio" date="1212473431"]
Code:
private function _add($file, $group = NULL) {
    //. . .
    if (file_exists($file) && is_readable($file)) {
        //. . .
    }else{
        echo "file doesn't exists or isn't readable";
    }
}
I spent an hour!! Why you don't put a little validation there!

Thanks[/quote]
I'm very sorry for this. :red: I will add an error log in the next update.
[quote author="Ignacio" date="1212480331"]Why this?
Code:
echo $this->cache_dir_css.'/'.$this->cache_file_css[$group];
[/quote]What's the problem here? Undecided

[quote author="Ignacio" date="1212480331"]What about ie6 & ie7 sytles?[/quote]What do you mean exactly?

[quote author="Ignacio" date="1212480331"]
Code:
$this->csstidy_loaded = TRUE;echo 'ss';

??????[/quote]Well, I have no idea what this was meant for during initial development and especially: why it's still in there. Confusedhut:
Damn, didn't I check the code twice? I did.
#22

[eluser]fgrehm[/eluser]
Sorry guys, it was my bad.

Code:
$this->csstidy_loaded = TRUE;echo 'ss';

I was debuging and forgot to remove this line before sending it to TheLoops
#23

[eluser]TheLoops[/eluser]
[quote author="fgrehm" date="1212512414"]Sorry guys, it was my bad.

Code:
$this->csstidy_loaded = TRUE;echo 'ss';

I was debuging and forgot to remove this line before sending it to TheLoops[/quote]Ah, right. I couldn't remember that line Undecided %-P
#24

[eluser]louis w[/eluser]
It would be nice if there was an option to tell the library to output ungrouped and not compressed js/css tags. An example of this would be for a development site, where you do not want it to compress the assets.

e.g.
$this->assetlibpro->development_site = TRUE;
#25

[eluser]a&w[/eluser]
Just discovered your library and am playing with it. A few very minor comments:

1. The downloaded config file has version 1.0, not sure if you want to coincide that with 1.0.4 or maybe it hasn't changed and it's still at 1.0.0.

2. As of 1.0.4 the 'ss' is still in there, you probably know that of course.

3. The instructions are easy to follow. One thing you might note though is that you also need to load/autoload the url helper.

4. Currently there is this (around line 550):

Code:
//if (strstr($HTTP_SERVER_VARS["HTTP_ACCEPT_ENCODING"], "gzip"))

When I have error reporting set to E_ALL that generates warnings visible in the head section. I think that syntax is depracated in favor of the following line (if I change to the following the warnings go away):

Code:
if (strstr($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip"))

I noticed you're using __construct, so presumably you're using php 5 so I'd think go with the preferred way?

5. I think I might second a toggle to disable caching/concatenating/minifying etc. for a development site, unless you have another suggestion (I was deleting the 'compressed' directory manually). I could always augment the config file like I do for error_reporting I guess:
Code:
// Determine whether we're working on development or production server:
define('IS_PRODUCTION', ($_SERVER['SERVER_NAME'] != 'localhost'));

/*
|---------------------------------------------------------------
| PHP ERROR REPORTING LEVEL
|---------------------------------------------------------------
|
*/
IS_PRODUCTION ?  error_reporting(0) : error_reporting(E_ALL) ;
but if you have an effective way to implement could just as well do something like:
Code:
$this->assetlibpro->development_site = IS_PRODUCTION;
#26

[eluser]a&w[/eluser]
Couple more:

1. I get an "Uninitialized string offset" error from csstidy when error report is set to E_ALL. I'm just pointing this out here since csstidy is apparently no longer maintained and thought it might help someone here. As far as I can tell, when the first line of my first css file begins with "/*"
Code:
/*
* Some comment here
*/
the index (i) the first time csstidy's escape function is entered is zero instead of 1. Zero throws the warning. There is an error suppression operator, but it appears to not work even though php.net appears to claim that bug was fixed a couple of years ago. So anyway, problem is resolved if you don't have error notices or if you don't have "/*" as the first line (I just added a blank line and all is well).

2. Back to this library. Why is line 285 in the code?
Code:
echo $this->cache_dir_css.'/'.$this->cache_file_css[$group];

I commented it out and things work ok. Otherwise the path for the file is echo'd to the browser if that line is left active.
#27

[eluser]TheLoops[/eluser]
Thanks a&w;, I'll fix all that stuff and post an update.
Damn, I really should enable E_ALL when debugging O_o
#28

[eluser]a&w[/eluser]
One other thought/observation.

Had you considered including the ability Rick Ellis's asset_helper includes whereby you can optionally specify a 'module'?

So in controller:
Code:
//current code would do:
$this->assetlibpro->add_js('/assets/js/base.js');
$this->assetlibpro->add_js('/assets/modules/module1/js/spiffy.js');

//with 'helper' could do:
$this->assetlibpro->add_js('base.js');
$this->assetlibpro->add_js('spiffy.js','','module1');//empty string for backward
                                                     //compatibility for 'group'

To do that add this method to library:
Code:
/**
    * Get location of asset
    * @access  private
    * @param   string    the name of the file or asset relative to configured assets folder
    * @param   string    optional, module name
    * @param   string    the asset type (name of folder within module name)
    * @return  string    relative path to asset
    **/
    private function _asset_loc($asset_name, $module_name = NULL, $asset_type = NULL)
    {
        $asset_location = $this->asset_dir;//new config

        if(!empty($module_name)):
            $asset_location .= 'modules/'.$module_name.'/';
        endif;

        $asset_location .= $asset_type.'/'.$asset_name;

        return $asset_location;
    }

And then modify the existing methods slightly:
Code:
//  function add_js($file, $group = '') {
/*mod*/        
    function add_js($file, $group = '', $module_name = NULL) {
/*mod*/        
        if (empty($group))
           $group = $this->default_group_js;
            
        if (!is_string($group))
           return FALSE;
/*new*/        
        $file_loc = $this->_asset_loc($file, $module_name, 'js');
/*new*/        
/*mod*/        
        $this->_add($file_loc, $group);
/*mod*/        
        //$this->_add($file, $group);
    }

Assumed new config property:
Code:
/*
|--------------------------------------------------------------------------
| Asset storage
|--------------------------------------------------------------------------
|
| The path to where to storage the joined assets.
| alp_cache_dir_css = "/assets/compressed/" (as example)
|
*/
$config['alp_asset_dir'] = '/assets/';//TRAILING SLASH! <----------------new
$config['alp_cache_dir_css'] = '/assets/compressed/';//TRAILING SLASH!

And just modify the beginning of the class as so:
Code:
/*new*/        
    var $asset_dir = '';
/*new*/        

    var $cache_dir_css = '/';
    var $cache_dir_js = '/';
    
    var $cache_file_css = '';
    var $cache_file_js = '';
        
    var $gzip_compress_css = TRUE;
    var $gzip_compress_js = TRUE;
    
    var $force_cache_css = TRUE;
    var $force_cache_js = TRUE;
    
    function __construct() {
        $this->CI = get_instance();
        
        log_message('debug', 'Assetlibpro library loaded');
        
        $this->default_group_css = $this->CI->config->item('alp_default_group_css');
        $this->default_group_js = $this->CI->config->item('alp_default_group_js');
/*new*/        
        $this->asset_dir = $this->CI->config->item('alp_asset_dir');
/*new*/
Similar modification for add_css...

Seems like there would be a way to use the 'module' might be a way to provide a quick mechanism for switching (css) 'themes'. Probably more to it since I guess there may need to be folders for assets/compressed/themeName/.

Anyway, just sharing the thought...
#29

[eluser]TheLoops[/eluser]
I just posted an update (v1.0.5) that should cover all issues.
#30

[eluser]a&w[/eluser]
My assumed setup may be different than yours, so I needed to modify the commented out line.

Code:
/**
    * Get location of asset
    * @access  private
    * @param   string    the name of the file or asset relative to configured assets folder
    * @param   string    optional, module name
    * @param   string    the asset type (name of folder within module name)
    * @return  string    relative path to asset
    **/
    private function _asset_loc($asset_name, $module_name = NULL, $asset_type = NULL)
    {
        $asset_location = $this->asset_dir;//new config

        if(!empty($module_name)):
            $asset_location .= 'modules/'.$module_name.'/';
        endif;

//        $asset_location .= $asset_name;
        $asset_location .= $asset_type.'/'.$asset_name;
        return $asset_location;
    }
}

Do you do anything with htaccess (or any other means) to alter the header of the base (html) page or any images used? I tried fiddling around with htaccess to do the far future stuff with images but apparently did it wrong since Yslow didn't detect any changes I was doing.




Theme © iAndrew 2016 - Forum software by © MyBB