Skip to content

kusmayadi/kollapse

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kollapse

Kollapse is an asset packaging module for Kohana 3, inspired by Jammit, that can combine and compress groups of Javascript and CSS files on-the-fly, or ahead of time.

Features

  • Caching & compression of Javascript and CSS assets,
  • Filters for parsing assets (LESS & SASS) before they're compressed,
  • Multiple compression drivers (Minify, Google Closure, or YUI Compressor),
  • and the extensiblity of Kohana we all know and love.

Installation

Clone the Git repository into your modules directory:

$ git clone git://github.com/gevans/kollapse.git modules/kollapse

Or, clone the repository as a submodule (if you're using Git for your current project):

$ git submodule add git://github.com/gevans/kollapse.git modules/kollapse

As usual, enable the module in your application's bootstrap.php:

<?php
Kohana::modules(array(
    // ...
    'kollapse' => MODPATH.'kollapse', // Asset packaging
    // ...
));

Configuration

Copy config/kollapse.php to your application/config/ directory. You can then set groups of assets and tweak the configuration to your liking.

Usage

Embedding

To embed your scripts and styles, use the Kollapse helper in your views:

<?php
// Include the 'common' group
echo Kollapse::scripts('common');

// Specify multiple groups and attributes
echo Kollapse::styles(array('common', 'workspace'), array('media' => 'screen'));

This will create HTML tags to include the specified groups, as well as allowing you to assign specific attributes in the generated HTML. Timestamps are appended to the URL, allowing you to send expiration dates far in the future, while causing browsers to fetch the latest copy of your packaged assets when they're updated:

<link href="/styles/common.css?1291393143" media="screen" rel="stylesheet "type="text/css" />

Command-line Precaching & Packaging

To immediately package and cache all of your assets, you can use the command-line to call Kollapse:

$ php /path/to/index.php --uri=kollapse

The above command will read your configured groups and save them all at your package paths.

Further Reading

For more documentation, enable the userguide module and visit http://localhost/guide/kollapse.getting_started.

Releases

No releases published

Packages

No packages published