Part of the EllisLab Network
   
3 of 6
3
AssetLibPro - An advanced CI Asset Library
Posted: 03 June 2008 08:00 AM   [ Ignore ]   [ # 21 ]  
Summer Student
Total Posts:  9
Joined  10-17-2007

Sorry guys, it was my bad.

$this->csstidy_loaded TRUE;echo 'ss'

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

Profile
 
 
Posted: 03 June 2008 10:11 AM   [ Ignore ]   [ # 22 ]  
Grad Student
Avatar
Rank
Total Posts:  66
Joined  03-17-2008
fgrehm - 03 June 2008 12:00 PM

Sorry guys, it was my bad.

$this->csstidy_loaded TRUE;echo 'ss'

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

Ah, right. I couldn’t remember that line hmmm tongue rolleye

Profile
 
 
Posted: 01 August 2008 02:19 PM   [ Ignore ]   [ # 23 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  593
Joined  02-04-2008

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;

Profile
 
 
Posted: 01 August 2008 09:19 PM   [ Ignore ]   [ # 24 ]  
Lab Assistant
RankRank
Total Posts:  122
Joined  04-03-2007

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):

//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):

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:

// 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:

$this->assetlibpro->development_site IS_PRODUCTION
Profile
 
 
Posted: 01 August 2008 11:21 PM   [ Ignore ]   [ # 25 ]  
Lab Assistant
RankRank
Total Posts:  122
Joined  04-03-2007

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 “/*”

/*
 * 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?

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.

Profile
 
 
Posted: 02 August 2008 04:41 AM   [ Ignore ]   [ # 26 ]  
Grad Student
Avatar
Rank
Total Posts:  66
Joined  03-17-2008

Thanks a&w;, I’ll fix all that stuff and post an update.
Damn, I really should enable E_ALL when debugging O_o

Profile
 
 
Posted: 02 August 2008 07:44 PM   [ Ignore ]   [ # 27 ]  
Lab Assistant
RankRank
Total Posts:  122
Joined  04-03-2007

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:

//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:

/**
    * 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:

//  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:

/*
|--------------------------------------------------------------------------
| 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:

/*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…

Profile
 
 
Posted: 05 August 2008 11:38 AM   [ Ignore ]   [ # 28 ]  
Grad Student
Avatar
Rank
Total Posts:  66
Joined  03-17-2008

I just posted an update (v1.0.5) that should cover all issues.

Profile
 
 
Posted: 05 August 2008 06:12 PM   [ Ignore ]   [ # 29 ]  
Lab Assistant
RankRank
Total Posts:  122
Joined  04-03-2007

My assumed setup may be different than yours, so I needed to modify the commented out line.

/**
    * 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.

Profile
 
 
Posted: 06 November 2008 01:24 AM   [ Ignore ]   [ # 30 ]  
Summer Student
Total Posts:  26
Joined  11-05-2008

I am new when it comes to AssetLib Pro. Do you have any knowledge of how implement this library. I followed instruction but nothing showed up in View file. Where Regular CSS and compress CSS needs to go. I have same question regarding Javascript as well. Please help me out.

Profile
 
 
   
3 of 6
3