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

[eluser]Nicholas Hanks[/eluser]
I must say this community is very active tnanks to Loops and a&w. Finally I figured out this issue somewhat but I am still struggling to get group functionality where I can put certain js and css in group. I first tried class sent to me by a&w but it had bugs. So, I gave second shot to AssetLibPro and this time I solved some part.

This is what I did!!!

Here what you have to change first in csstidy folder change name class.csstidy.php to csstidy.php (Weird huh!!!)

Secondly give write and read access to compressed folder and read access to plugin folder (especially CSSTIDY FOLDER, this might not be necessary but in my case it was)

This is how I setup my directory structure

DemoApp
css
js
compressed
css
js
system
libraries
Assetlibpro.php
........
application
config
assetlibpro.php

Now you have to change Assetlibpro.php little bit (Library)

in __construct() function add $this->CI->config->load('assetlibpro'); //thanks to Michael aka a&w

in output function whereever it says base_url() replace that with $this->CI->config->item('base_url')

in private function _load_css_config() change
$csstidy = BASEPATH.$this->CI->config->item('alp_csstidy_basepath')."class.csstidy.php";
to
$csstidy = BASEPATH.$this->CI->config->item('alp_csstidy_basepath')."csstidy.php";

Now in config file
$config['alp_asset_dir'] = '/';//TRAILING SLASH!
$config['alp_cache_dir_css'] = '/compressed/css/';//TRAILING SLASH!
$config['alp_cache_dir_js'] = '/compressed/js/';//TRAILING SLASH!

But you can change this configuration however you like it I suppose

Finally this is how you can add CSS and JS

$this->load->library('Assetlibpro');
$this->assetlibpro->add_css('css/test.css');
$this->assetlibpro->add_css('js/test.js');

-------------------------------------------------------------------
Now my question and mission is how can I add CSS and JS in groups and how can I call those groups in views. Instruction mentions something about group but it is not clear enough for me. Any suggestion Undecided
#42

[eluser]bjora857[/eluser]
Is it prossible to use with php4?

jsmin seems to require php5
#43

[eluser]sofbas[/eluser]
I like using this library, and have had success using it, but when I attempted to use it on the server I will eventually use for my website, the CSS and JS files weren't loading.

After confirming the files were being created in the assets/compressed directory and the contents what I expected, and the appropriate files linked in the html, I attempted to view the URL directly and I get the following error:
Code:
http://host/assets/compressed/js_default_6d0671a3_2359bbe0_0acb0beb.php
produces
[an error occurred while processing this directive]

Anyone know how to solve this problem?

Thanks
#44

[eluser]rbdc[/eluser]
[quote author="louis w" date="1217632776"]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;[/quote]

I just downloaded CI, installed and up and running... first thing i wanted was something exactly like you have here with AssetLibPro. After a good number of hours, this post is the other thing i wanted. an option for ungrouped/uncompressed css/js. i dont think thats possible yet with this library but just checking.

i see the dev_server part in the config file but dont think there is a way to display ungrouped/uncompressed
#45

[eluser]a&w[/eluser]
I have a variation of this library that will do that.

You can PM me if you're interested in it.
#46

[eluser]demogar[/eluser]
Can I attach the assets from an external domain, I mean amazon s3, google code or something like that?? If it's possible, how can I do that?
#47

[eluser]tonydewan[/eluser]
Quote: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.

I just released a similar library called Carabiner. It allows for exactly this kind of scenario. You can either define a pre-built production version of a script/stylesheet, or let Carabiner minify it automatically. If there are other things you'd like to see in Carabiner, let me know.
#48

[eluser]phazei[/eluser]
I added a new method to your Assetlibpro class. For the very lazy:

output_all()

Takes the same parameters output() takes, but it does not require add_css or add_js anywhere at all. It looks in the directory and adds ALL css and/or js files it finds.

In exchange for simplicity you lose the ability to select the order you want stuff added. Only get alphabetical. You also don't get the chance to select a group or module.
But if you're willing to make those sacrifices:

Code:
function output_all($type = 'all'){
        if ($type == 'all') {
            $css = $this->output_all('css');
            $js = $this->output_all('js');
            return "$css$js";
        }
        if (in_array($type,array('css','js'))) {
            $dir = $this->_asset_loc('', NULL, $type);
            $dir = realpath(trim($dir, "/"));
            $dh = scandir($dir);
            foreach ($dh as $file) {
                if (substr($file,-1*strlen($type)) == $type) {
                    $add_what = "add_".$type;
                    $this->$add_what($file);
                }
            }
            return($this->output($type));
        }
    }



EDITED: This function used to use opendir and readdir. I found out the natural filesystem file order isn't necessarily alphabetical. Caused some issues. (loading plugins before jquery)
I switched it to use scandir which is PHP5 only (there are PHP4 alternatives if you look at the php scandir help page).
Now it works much better Smile
#49

[eluser]ammonkc[/eluser]
Is there a way to autoload common assets? For example, if I know that all my pages will have layout.css and global.js, autoload (auto-add) it to minimize redundancy in the controller's constructor?
#50

[eluser]phazei[/eluser]
Uh, did you read the last post?
That's exactly what it's about.




Theme © iAndrew 2016 - Forum software by © MyBB