Skip to content
Browse files

initial attempt to make it work with plugin assets

  • Loading branch information...
1 parent c2f13dd commit cdca73dd6ffb8b2b97724925c591432eacd6683e @rchavik committed Jun 8, 2012
Showing with 18 additions and 5 deletions.
  1. +18 −5 View/Helper/MinifyHelper.php
View
23 View/Helper/MinifyHelper.php
@@ -29,20 +29,33 @@ public function script($scripts, $options = array()) {
$path = APP;
if (!empty($theme)) {
$path = App::themePath($theme);
- } elseif (!empty($plugin)) {
- $path = CakePlugin::pluginPath($plugin);
+ }
+ if (!empty($plugin)) {
+ $path = CakePlugin::path($plugin);
+ }
+ if ($subdir && $subdir[strlen($subdir) - 1] != DS) {
+ $subdir .= DS;
}
- $targetDirectory = $path .DS. 'webroot' .DS. 'js' .DS;
- $outputfile = $targetDirectory . $subdir .DS. 'minified-' . sha1(join(':', $scripts)) . '.js';
+ $targetDirectory = $path . 'webroot' . DS . 'js' . DS;
+ $outputfile = $targetDirectory . $subdir . 'minified-' . sha1(join(':', $scripts)) . '.js';
if (file_exists($outputfile)) {
- $outputfile = str_replace($targetDirectory, '', $outputfile);
+ if ($plugin) {
+ $outputfile = '/' . $plugin . '/js/' . basename($outputfile);
+ } else {
+ $outputfile = str_replace($targetDirectory, '', $outputfile);
+ }
return $this->Html->script($outputfile);
}
$contents = '';
+ $loaded = CakePlugin::loaded();
foreach ($scripts as $script) {
+ $scriptE = explode('.', $script, 2);
+ if (in_array($scriptE[0], $loaded)) {
+ $script = $scriptE[1];
+ }
$file = $targetDirectory . $script;
if (!preg_match('/\.js$/', $file)) {
$file .= '.js';

0 comments on commit cdca73d

Please sign in to comment.
Something went wrong with that request. Please try again.