1
0
mirror of https://github.com/pattern-lab/patternlab-php.git synced 2025-01-17 14:18:30 +01:00

can use the flag -n to turn off cacheBuster

This commit is contained in:
Dave Olsen 2014-03-07 12:44:43 -05:00
parent 6aadb16e16
commit b62b40aa78
3 changed files with 15 additions and 6 deletions

View File

@ -56,7 +56,7 @@ if (php_sapi_name() != 'cli') {
} }
// grab the arguments from the command line // grab the arguments from the command line
$args = getopt("gwcrvp"); $args = getopt("gwcrvpn");
// load Pattern Lab's config, if first time set-up move files appropriately too // load Pattern Lab's config, if first time set-up move files appropriately too
$co = new PatternLab\Configurer; $co = new PatternLab\Configurer;
@ -74,8 +74,9 @@ if (isset($args["g"]) || isset($args["w"])) {
$g = new PatternLab\Generator($config); $g = new PatternLab\Generator($config);
// set some default values // set some default values
$enableCSS = false; $enableCSS = false;
$moveStatic = true; $moveStatic = true;
$noCacheBuster = false;
// check to see if CSS for patterns should be parsed & outputted // check to see if CSS for patterns should be parsed & outputted
if (isset($args["c"]) && !isset($args["w"])) { if (isset($args["c"]) && !isset($args["w"])) {
@ -87,7 +88,12 @@ if (isset($args["g"]) || isset($args["w"])) {
$moveStatic = false; $moveStatic = false;
} }
$g->generate($enableCSS,$moveStatic); // check to see if we should turn off the cachebuster value
if (isset($args["n"])) {
$noCacheBuster = true;
}
$g->generate($enableCSS,$moveStatic,$noCacheBuster);
// have some fun // have some fun
if (!isset($args["w"])) { if (!isset($args["w"])) {

View File

@ -44,6 +44,7 @@ class Builder {
protected $patternCSS; // an array to hold the CSS generated for patterns protected $patternCSS; // an array to hold the CSS generated for patterns
protected $cssRuleSaver; // where css rule saver will be initialized protected $cssRuleSaver; // where css rule saver will be initialized
protected $cacheBuster; // a timestamp used to bust the cache for static assets like CSS and JS protected $cacheBuster; // a timestamp used to bust the cache for static assets like CSS and JS
protected $noCacheBuster; // should we turn the cache buster on or off?
protected $patternHead; // the header to be included on patterns protected $patternHead; // the header to be included on patterns
protected $patternFoot; // the footer to be included on patterns protected $patternFoot; // the footer to be included on patterns
protected $mainPageHead; // the header to be included on main pages protected $mainPageHead; // the header to be included on main pages
@ -390,7 +391,7 @@ class Builder {
protected function gatherData() { protected function gatherData() {
// set the cacheBuster // set the cacheBuster
$this->cacheBuster = time(); $this->cacheBuster = $this->noCacheBuster ? 0 : time();
// gather the data from the main source data.json // gather the data from the main source data.json
if (file_exists($this->sd."/_data/_data.json")) { if (file_exists($this->sd."/_data/_data.json")) {

View File

@ -30,7 +30,7 @@ class Generator extends Builder {
* @param {Boolean} decide if CSS should be parsed and saved. performance hog. * @param {Boolean} decide if CSS should be parsed and saved. performance hog.
* @param {Boolean} decide if static files like CSS and JS should be moved * @param {Boolean} decide if static files like CSS and JS should be moved
*/ */
public function generate($enableCSS = false, $moveStatic = true) { public function generate($enableCSS = false, $moveStatic = true, $noCacheBuster = false) {
$timePL = true; // track how long it takes to generate a PL site $timePL = true; // track how long it takes to generate a PL site
@ -41,6 +41,8 @@ class Generator extends Builder {
$starttime = $mtime; $starttime = $mtime;
} }
$this->noCacheBuster = $noCacheBuster;
if ($enableCSS) { if ($enableCSS) {
// enable CSS globally throughout PL // enable CSS globally throughout PL