From 970f17c63c8e8b8aab95bcd3524aa2d60dc9a446 Mon Sep 17 00:00:00 2001 From: Fernando Ontiveros Date: Wed, 12 Mar 2014 13:08:01 -0400 Subject: [PATCH] production mode, now is using a hash based in vendor commits --- build-vendor.php | 17 +++++++-- workflow/engine/controllers/designer.php | 7 ++++ workflow/engine/templates/designer/index.html | 37 +------------------ 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/build-vendor.php b/build-vendor.php index d391f103e..f083bc1f7 100644 --- a/build-vendor.php +++ b/build-vendor.php @@ -52,12 +52,16 @@ out("generating files for ", 'purple', false); out( $debug ? 'debug' : 'production', 'success', false); out(" mode", 'purple'); +$hashVendors = ''; +$hashes = array(); foreach ($projects as $project) { echo PHP_EOL; out("=> Building project: ", 'info', false); $output = array(); echo $project.' '.PHP_EOL; chdir($vendorDir.DS.$project); + exec ('git rev-parse --short HEAD', $hashes); + if ($debug) { exec ('rake pmBuildDebug', $output, $exitCode ); } else { @@ -80,6 +84,8 @@ foreach ($projects as $project) { } } +//get the hash for all vendor projects +$hashVendors = implode ('-', $hashes ); //the script is completed if the option is Debug = 1 if ($debug) { @@ -152,14 +158,16 @@ $jsFiles = array ( "gulliver/js/codemirror/mode/clike/clike.js", "gulliver/js/codemirror/mode/php/php.js", ); -$bigHandler = fopen ("{$rootPath}/workflow/public_html/lib/js/big.js", "w"); + + +$bigHandler = fopen ("{$rootPath}/workflow/public_html/lib/js/mafe-{$hashVendors}.js", "w"); foreach ($jsFiles as $jsFile) { $fileContent = file_get_contents("{$rootPath}/$jsFile"); fprintf($bigHandler, "%s\n\n", $fileContent); printf (" - File %s added to big.js\n", basename($jsFile)); } fclose ($bigHandler); -printf ( "big.js file has %d bytes\n", filesize("{$rootPath}/workflow/public_html/lib/js/big.js")); +printf ( "mafe-{$hashVendors}.js file has %d bytes\n", filesize("{$rootPath}/workflow/public_html/lib/js/mafe-{$hashVendors}.js")); @@ -175,15 +183,16 @@ $cssFiles = array ( "gulliver/js/tinymce/jscripts/tiny_mce/plugins/inlinepopups/skins/clearlooks2/window.css", "gulliver/js/tinymce/jscripts/tiny_mce/themes/advanced/skins/o2k7/content.css" ); -$bigHandler = fopen ("{$rootPath}/workflow/public_html/lib/css/big.css", "w"); +$bigHandler = fopen ("{$rootPath}/workflow/public_html/lib/css/mafe-{$hashVendors}.css", "w"); foreach ($cssFiles as $cssFile) { $fileContent = file_get_contents("{$rootPath}/$cssFile"); fprintf($bigHandler, "%s\n\n", $fileContent); printf (" - File %s added to big.css\n", basename($cssFile)); } fclose ($bigHandler); -printf ( "big.css file has %d bytes\n", filesize("{$rootPath}/workflow/public_html/lib/css/big.css")); +printf ( "mafe-{$hashVendors}.css file has %d bytes\n", filesize("{$rootPath}/workflow/public_html/lib/css/mafe-{$hashVendors}.css")); +file_put_contents("{$rootPath}/workflow/public_html/lib/buildhash", $hashVendors); echo PHP_EOL; diff --git a/workflow/engine/controllers/designer.php b/workflow/engine/controllers/designer.php index 1a82fa861..af0a5750c 100644 --- a/workflow/engine/controllers/designer.php +++ b/workflow/engine/controllers/designer.php @@ -63,6 +63,13 @@ class Designer extends Controller $this->setVar('designerCacheFile', file(PATH_HTML . "lib-dev/mafe/applications.cache", FILE_IGNORE_NEW_LINES)); $this->setVar('mafeJsFiles', $mafeJsFiles); $this->setVar('mafeCssFiles', $mafeCssFiles); + } else { + $buildhashFile = PATH_HTML . "lib/buildhash"; + if (! file_exists($buildhashFile)) { + throw new RuntimeException("CSS and JS Files were are not generated!.\nPlease review install process"); + } + $buildhash = file_get_contents($buildhashFile); + $this->setVar('buildhash', $buildhash); } $this->setView('designer/index'); diff --git a/workflow/engine/templates/designer/index.html b/workflow/engine/templates/designer/index.html index e5ca195fc..acdf5f1d6 100644 --- a/workflow/engine/templates/designer/index.html +++ b/workflow/engine/templates/designer/index.html @@ -56,45 +56,12 @@ {else} - - - - + - - + {/if}