X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Asset.php;h=3e49f8ebb5f23a95a024aa7cd122d9b6b00ab6c1;hb=refs%2Fheads%2Fmaster;hp=8e18ea3173edc6d8a539ad35b009ab5c65d45c1e;hpb=f938af99ae2144d95ab0cf1ec2cb2e9bbc11fc72;p=Pman.Core diff --git a/Asset.php b/Asset.php index 8e18ea31..5fca1b61 100644 --- a/Asset.php +++ b/Asset.php @@ -26,6 +26,7 @@ class Pman_Core_Asset extends Pman { var $types = array( 'css' => 'text/css', 'js' => 'text/javascript', + 'map' => 'application/json' ); function getAuth() @@ -36,28 +37,31 @@ class Pman_Core_Asset extends Pman { function get($s='', $opts = Array()) { - - $this->sessionState(0); $bits = explode('/', $s); if (empty($bits[0]) || empty($bits[1]) || !isset($this->types[$bits[0]])) { - $this->jerr("invalid url"); + $this->jnotice("invalid url"); + } + + $ext = $bits[0]; + if (preg_match('/\.map$/',$_SERVER['REQUEST_URI'])) { + $ext = 'map'; } $s = str_replace('/', '-', $bits[1]); + $ui = posix_getpwuid(posix_geteuid()); $ff = HTML_FlexyFramework::get(); - $compile = session_save_path() . '/' . - $ui['name'] . '-' . $ff->project . '-' . $ff->version . '-'. $bits[0] . 'compile'; - - $fn = $compile . '/'. $s .'.'. $bits[0]; + $compile = self::getCompileDir($bits[0], '', false); + + $fn = $compile . '/'. $s .'.'. $ext; if (!file_exists($fn)) { - header('Content-Type: '. $this->types[$bits[0]]); + header('Content-Type: '. $this->types[$ext]); echo "// compiled file not found = $fn"; exit; @@ -108,7 +112,7 @@ class Pman_Core_Asset extends Pman { $fh = fopen($fn,'r'); fpassthru($fh); fclose($fh); - $content = $data; + } @@ -133,11 +137,15 @@ class Pman_Core_Asset extends Pman { $compile_dir = session_save_path() . "/"; - $module = (empty($module)) ? $ff->project : $module; + if (empty($module)) { + $module = $ff->project . (isset($ff->appNameShort) ? '_' . $ff->appNameShort : ''); + } + switch($type) { case 'js': case 'css': + case 'scss': $compile_dir .= implode("-", array( $ui['name'], $module, @@ -150,6 +158,7 @@ class Pman_Core_Asset extends Pman { return false; } + if (file_exists($compile_dir)) { return $compile_dir; } @@ -173,18 +182,22 @@ class Pman_Core_Asset extends Pman { } require_once 'System.php'; + $ff = HTML_FlexyFramework::get(); $mods = $this->modulesList(); + $mods[] = $ff->project; // Pman - this was the old format... + $mods[] = ''; // Pman + appshortname.. + foreach ($mods as $module) { $compile_dir = $this->getCompileDir('js', $module, false); if(!empty($compile_dir)) { - System::rm(array('-r', $compiledir)); + System::rm(array('-r', $compile_dir)); } $compile_dir = $this->getCompileDir('css', $module, false); if(!empty($compile_dir)) { - System::rm(array('-r', $compiledir)); + System::rm(array('-r', $compile_dir)); } }