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
$args = getopt("gwcrvp");
$args = getopt("gwcrvpn");
// load Pattern Lab's config, if first time set-up move files appropriately too
$co = new PatternLab\Configurer;
@ -76,6 +76,7 @@ if (isset($args["g"]) || isset($args["w"])) {
// set some default values
$enableCSS = false;
$moveStatic = true;
$noCacheBuster = false;
// check to see if CSS for patterns should be parsed & outputted
if (isset($args["c"]) && !isset($args["w"])) {
@ -87,7 +88,12 @@ if (isset($args["g"]) || isset($args["w"])) {
$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
if (!isset($args["w"])) {

View File

@ -44,6 +44,7 @@ class Builder {
protected $patternCSS; // an array to hold the CSS generated for patterns
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 $noCacheBuster; // should we turn the cache buster on or off?
protected $patternHead; // the header to be included on patterns
protected $patternFoot; // the footer to be included on patterns
protected $mainPageHead; // the header to be included on main pages
@ -390,7 +391,7 @@ class Builder {
protected function gatherData() {
// set the cacheBuster
$this->cacheBuster = time();
$this->cacheBuster = $this->noCacheBuster ? 0 : time();
// gather the data from the main source 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 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
@ -41,6 +41,8 @@ class Generator extends Builder {
$starttime = $mtime;
}
$this->noCacheBuster = $noCacheBuster;
if ($enableCSS) {
// enable CSS globally throughout PL