示例#1
0
$buildPath = "sencha-build/{$appName}/production";
// get temporary directory and set paths
$tmpPath = Emergence_FS::getTmpDir();
$workspaceConfigTmpPath = "{$tmpPath}/.sencha";
$frameworkTmpPath = "{$tmpPath}/{$framework}";
$packagesTmpPath = "{$tmpPath}/packages";
$appTmpPath = "{$tmpPath}/{$appName}";
$buildTmpPath = "{$tmpPath}/build/{$appName}/production";
Benchmark::mark("created tmp: {$tmpPath}");
// precache and write workspace config
$cachedFiles = Emergence_FS::cacheTree($workspaceConfigPath);
Benchmark::mark("precached {$cachedFiles} files in {$workspaceConfigPath}");
$exportResult = Emergence_FS::exportTree($workspaceConfigPath, $workspaceConfigTmpPath);
Benchmark::mark("exported {$workspaceConfigPath} to {$workspaceConfigTmpPath}: " . http_build_query($exportResult));
// ... packages
if (!($requiredPackages = $App->getAppCfg('requires')) || !is_array($requiredPackages)) {
    $requiredPackages = array();
}
if (($themeName = $App->getBuildCfg('app.theme')) && !in_array($themeName, $requiredPackages)) {
    $requiredPackages[] = $themeName;
}
foreach ($requiredPackages as $packageName) {
    $cachedFiles = Emergence_FS::cacheTree("{$packagesPath}/{$packageName}");
    Benchmark::mark("precached {$cachedFiles} files in {$packagesPath}/{$packageName}");
    $exportResult = Emergence_FS::exportTree("{$packagesPath}/{$packageName}", "{$packagesTmpPath}/{$packageName}");
    Benchmark::mark("exported {$packagesPath} to {$packagesTmpPath}/{$packageName}: " . http_build_query($exportResult));
}
// ... framework
$exportResult = Emergence_FS::exportTree($frameworkPath, $frameworkTmpPath);
Benchmark::mark("exported {$frameworkPath} to {$frameworkTmpPath}: " . http_build_query($exportResult));
// ... app
 public static function handleCacheManifestRequest(Sencha_App $App)
 {
     $templateNode = Emergence\Dwoo\Template::findNode($App->getFramework() . '.tpl');
     $cacheConfig = $App->getAppCfg('appCache');
     header('Content-Type: text/cache-manifest');
     echo "CACHE MANIFEST\n";
     echo "# {$templateNode->SHA1}\n";
     if (!empty($cacheConfig['cache']) && is_array($cacheConfig['cache'])) {
         foreach ($cacheConfig['cache'] as $path) {
             if ($path != 'index.html') {
                 $path = "build/production/{$path}";
                 echo "{$path}\n";
                 if ($assetNode = $App->getAsset($path)) {
                     echo "#{$assetNode->SHA1}\n";
                 }
             }
         }
     }
     if (!empty($_GET['platform']) && !empty($cacheConfig['platformCache']) && !empty($cacheConfig['platformCache'][$_GET['platform']]) && is_array($cacheConfig['platformCache'][$_GET['platform']])) {
         echo "\n# {$_GET['platform']}:\n";
         foreach ($cacheConfig['platformCache'][$_GET['platform']] as $path) {
             $path = "build/production/{$path}";
             if ($assetNode = $App->getAsset($path)) {
                 echo "{$path}\n";
                 echo "#{$assetNode->SHA1}\n";
             }
         }
     }
     echo "\nFALLBACK:\n";
     if (!empty($cacheConfig['fallback']) && is_array($cacheConfig['fallback'])) {
         foreach ($cacheConfig['fallback'] as $path) {
             echo "{$path}\n";
         }
     }
     echo "\nNETWORK:\n";
     if (!empty($cacheConfig['network']) && is_array($cacheConfig['network'])) {
         foreach ($cacheConfig['network'] as $path) {
             echo "{$path}\n";
         }
     }
     echo "\n# TRIGGERS:\n";
     $templateNode = Emergence\Dwoo\Template::findNode($App->getFramework() . '.tpl');
     echo "#template: {$templateNode->SHA1}\n";
     if (!empty($cacheConfig['triggers']) && is_array($cacheConfig['triggers'])) {
         foreach ($cacheConfig['triggers'] as $path) {
             $assetNode = $path[0] == '/' ? Site::resolvePath($path) : $App->getAsset($path);
             if ($assetNode) {
                 echo "#{$assetNode->SHA1}\n";
             }
         }
     }
     exit;
 }