Welcome Guest, Not a member yet? Register   Sign In
Carabiner 1.2: Asset Management Library
#1

[eluser]tonydewan[/eluser]
NOTE: Carabiner has been updated to version 1.42. See the new thread for more info and to download.

This is a quick update to Carabiner. See the original thread or the wiki entry for background information.

This update fixes a few bugs, plus adds media type association for CSS assets. Therefore, adding CSS assets has changed slightly. The second parameter is now a string of the media type. Here are some examples:

Code:
// add a css file with a mediatype
$this->carabiner->css('admin/print.css','print');

// add a css file with prebuilt production version
$this->carabiner->css('framework/type.css', 'screen', 'framework/type.pack.css');

// add a css file with prebuilt production version, don't combine it
$this->carabiner->css('framework/type.css', 'screen', 'framework/type.pack.css', FALSE);

This changes the logic of caching slightly. CSS files are now combined by mediatype. Here is an example:

Code:
// add some print stylesheets
$this->carabiner->css('assets/print/base.css','print');
$this->carabiner->css('assets/print/type.css','print');

// add some screen stylesheets
$this->carabiner->css('assets/screen/base.css','screen');
$this->carabiner->css('assets/screen/type.css','screen');

// This will output something like the following:
<link type="text/css" rel="stylesheet" href="http://domain.com/assets/cache/123317257958f25df188aec75c4d0c74b6f82b9523.css" media="screen" />
<link type="text/css" rel="stylesheet" href="http://domain.com/assets/cache/123317257953944861ed3c4e9f92752f3d5f99ec95.css" media="print" />


Everything else should work exactly the same as before. Next on my list is asset grouping.
#2

[eluser]Johan André[/eluser]
Great lib! Thanks for sharing!
Is it ok to include it in my custombuilt cms?
#3

[eluser]tonydewan[/eluser]
@Johan: Absolutely! I only ask that you retain the copyright/license notice, as per the BSD license:

Quote:Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

I'm actually using Carabiner in a proprietary CMS at work, and I built it with that context in mind. I hope it works the way you want it to.
#4

[eluser]Johan André[/eluser]
Nice!
#5

[eluser]freshface[/eluser]
Cool you implemented the media type
#6

[eluser]freshface[/eluser]
Why dont you use a config file? Now i always need to set the config params.
#7

[eluser]phused[/eluser]
Thanks for sharing this library, it's great!
#8

[eluser]tonydewan[/eluser]
@freshface- I tend to think that a separate config file is a little overkill in this instance. I also foresee instances where config values could vary across a site. For instance, you might have a different style/script/cache directory for a backend controller.

Is your problem that you have to run the config in multiple controllers? If so, you could extend the base controller, and set the config there.

That being said, I'll definitely put it on the list of things to look at. I could see an implementation that checks for a config file, but also allows configuration directly (like it is now.)

If there is anyone else that would prefer to a config file, let me know.
#9

[eluser]J. Brenne[/eluser]
The cache file on my xampp (windows) dont exist. The folder exist so, any other have a problem? The file dont get created.

greetings
#10

[eluser]tonydewan[/eluser]
@Brenne I'm pretty unfamiliar with PHP on a Windows server. Is the folder writable? I'm not sure how that needs to happen on Windows, but that's the first step. Otherwise, the path the script is writing might be incorrect. Are you getting any errors, or is it just silently not working?




Theme © iAndrew 2016 - Forum software by © MyBB