2013-07-25 23:33:04 +02:00
|
|
|
<?php
|
|
|
|
use Assetic\Asset\AssetCollection;
|
|
|
|
use Assetic\Asset\FileAsset;
|
|
|
|
use Assetic\Asset\GlobAsset;
|
|
|
|
use Assetic\Filter\CoffeeScriptFilter;
|
|
|
|
|
|
|
|
class Assets {
|
|
|
|
public static function scriptIncludes($area = 'app') {
|
|
|
|
$js = self::scriptAssetCollection($area);
|
|
|
|
|
|
|
|
if (Config::get('app.debug')) {
|
|
|
|
$retVal = '';
|
|
|
|
|
|
|
|
foreach ($js as $script) {
|
|
|
|
$retVal .= '<script src="/' . $script->getSourceRoot() . '/' . $script->getSourcePath() . '?' . gmdate($js->getLastModified()) . '"></script>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
return '<script src="/asset.php?area=' . $area . '&type=coffee&' . gmdate($js->getLastModified()) . '"></script>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function styleIncludes($area = 'app') {
|
|
|
|
$css = self::styleAssetCollection($area);
|
|
|
|
|
|
|
|
if (Config::get('app.debug')) {
|
|
|
|
$retVal = '';
|
|
|
|
|
|
|
|
foreach ($css as $style) {
|
|
|
|
if ($style instanceof CacheBusterAsset)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
$retVal .= '<link rel="stylesheet" href="/' . $style->getSourceRoot() . '/' . $style->getSourcePath() . '?' . gmdate($css->getLastModified()) . '" />';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
return '<link rel="stylesheet" href="asset.php?area=' . $area . '&type=less&' . gmdate($css->getLastModified()) . '" />';
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function scriptAssetCollection($area) {
|
2013-08-21 04:40:11 +02:00
|
|
|
if ($area == 'app') {
|
|
|
|
$collection = new AssetCollection([
|
2013-07-25 23:33:04 +02:00
|
|
|
new FileAsset('scripts/base/jquery-2.0.2.js'),
|
2013-07-26 11:20:34 +02:00
|
|
|
new FileAsset('scripts/base/jquery-ui.js'),
|
2013-08-01 10:57:08 +02:00
|
|
|
new FileAsset('scripts/base/jquery.cookie.js'),
|
2013-07-27 02:15:07 +02:00
|
|
|
new FileAsset('scripts/base/jquery.colorbox.js'),
|
2013-08-16 01:49:20 +02:00
|
|
|
new FileAsset('scripts/base/jquery.viewport.js'),
|
2013-07-25 23:33:04 +02:00
|
|
|
new FileAsset('scripts/base/underscore.js'),
|
2013-07-28 23:51:35 +02:00
|
|
|
new FileAsset('scripts/base/moment.js'),
|
2013-08-01 10:57:08 +02:00
|
|
|
new FileAsset('scripts/base/soundmanager2-nodebug.js'),
|
2013-07-25 23:33:04 +02:00
|
|
|
new FileAsset('scripts/base/angular.js'),
|
2013-08-23 02:48:40 +02:00
|
|
|
new FileAsset('scripts/base/bindonce.js'),
|
2013-07-25 23:33:04 +02:00
|
|
|
new FileAsset('scripts/base/ui-bootstrap-tpls-0.4.0.js'),
|
2013-07-28 19:45:21 +02:00
|
|
|
new FileAsset('scripts/base/angular-ui-sortable.js'),
|
2013-07-26 11:20:34 +02:00
|
|
|
new FileAsset('scripts/base/angular-ui-date.js'),
|
2013-07-25 23:33:04 +02:00
|
|
|
new FileAsset('scripts/base/angular-ui-router.js'),
|
2013-08-31 04:46:28 +02:00
|
|
|
new FileAsset('scripts/base/angularytics.js'),
|
2013-07-25 23:33:04 +02:00
|
|
|
new AssetCollection([
|
|
|
|
new GlobAsset('scripts/shared/*.coffee'),
|
2013-07-28 19:45:21 +02:00
|
|
|
new GlobAsset('scripts/shared/*.js'),
|
2013-07-25 23:33:04 +02:00
|
|
|
new GlobAsset('scripts/app/*.coffee'),
|
|
|
|
new GlobAsset('scripts/app/services/*.coffee'),
|
|
|
|
new GlobAsset('scripts/app/filters/*.coffee'),
|
|
|
|
new GlobAsset('scripts/app/filters/*.js'),
|
|
|
|
new GlobAsset('scripts/app/directives/*.coffee'),
|
|
|
|
new GlobAsset('scripts/app/controllers/*.coffee'),
|
|
|
|
], [
|
|
|
|
new CoffeeScriptFilter(Config::get('app.coffee'))
|
|
|
|
])
|
|
|
|
]);
|
|
|
|
|
2013-08-21 04:40:11 +02:00
|
|
|
if (Config::get('app.debug')) {
|
|
|
|
$collection->add(new GlobAsset('scripts/debug/*.js'));
|
|
|
|
|
|
|
|
$collection->add(new AssetCollection([
|
|
|
|
new GlobAsset('scripts/debug/*.coffee'),
|
|
|
|
], [
|
|
|
|
new CoffeeScriptFilter(Config::get('app.coffee'))
|
|
|
|
]));
|
|
|
|
}
|
|
|
|
|
2013-09-01 04:20:48 +02:00
|
|
|
return $collection;
|
|
|
|
} else if ($area == 'embed') {
|
|
|
|
$collection = new AssetCollection([
|
|
|
|
new FileAsset('scripts/base/jquery-2.0.2.js'),
|
|
|
|
new FileAsset('scripts/base/jquery.viewport.js'),
|
|
|
|
new FileAsset('scripts/base/underscore.js'),
|
|
|
|
new FileAsset('scripts/base/moment.js'),
|
|
|
|
new FileAsset('scripts/base/jquery.timeago.js'),
|
|
|
|
new FileAsset('scripts/base/soundmanager2-nodebug.js'),
|
|
|
|
new AssetCollection([
|
|
|
|
new GlobAsset('scripts/embed/*.coffee'),
|
|
|
|
], [
|
|
|
|
new CoffeeScriptFilter(Config::get('app.coffee'))
|
|
|
|
])
|
|
|
|
]);
|
|
|
|
|
2013-08-21 04:40:11 +02:00
|
|
|
return $collection;
|
|
|
|
}
|
|
|
|
|
2013-07-25 23:33:04 +02:00
|
|
|
throw new Exception();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function styleAssetCollection($area) {
|
|
|
|
if ($area == 'app') {
|
|
|
|
$lastModifiedCollection = new AssetCollection([new GlobAsset("styles/*.less")]);
|
|
|
|
|
|
|
|
$css = new AssetCollection([
|
2013-07-26 11:20:34 +02:00
|
|
|
new FileAsset('styles/base/jquery-ui.css'),
|
2013-07-27 02:15:07 +02:00
|
|
|
new FileAsset('styles/base/colorbox.css'),
|
2013-07-25 23:33:04 +02:00
|
|
|
new FileAsset('styles/app.less'),
|
|
|
|
new CacheBusterAsset($lastModifiedCollection->getLastModified())
|
|
|
|
], [new \Assetic\Filter\LessFilter('node')]);
|
|
|
|
|
2013-08-21 04:40:11 +02:00
|
|
|
if (Config::get('app.debug')) {
|
|
|
|
$css->add(new FileAsset('styles/profiler.less'));
|
|
|
|
$css->add(new FileAsset('styles/prettify.css'));
|
|
|
|
}
|
|
|
|
|
2013-09-01 04:20:48 +02:00
|
|
|
return $css;
|
|
|
|
} else if ($area == 'embed') {
|
|
|
|
$css = new AssetCollection([
|
|
|
|
new FileAsset('styles/embed.less'),
|
|
|
|
], [new \Assetic\Filter\LessFilter('node')]);
|
|
|
|
|
2013-07-25 23:33:04 +02:00
|
|
|
return $css;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Exception();
|
|
|
|
}
|
|
|
|
}
|