Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 1c320c1

Browse files
committed
Remove unnecessary patterns, update naming structure of patterns, update template and page demos
2 parents 0327f75 + 7550895 commit 1c320c1

37 files changed

+175
-228
lines changed

core/builder.php

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@
1515
* php builder/builder.php -gc
1616
* In addition to the -g flag features it will also generate CSS for each pattern. Resource instensive.
1717
*
18+
* php builder.php -gp
19+
* Generates only the patterns a site. Does NOT clean public/ when generating the site.
20+
*
1821
* php builder.php -w
1922
* Generates the site like the -g flag and then watches for changes in the 'source' directories &
2023
* files. Will re-generate files if they've changed.
2124
*
2225
* php builder.php -wr
2326
* In addition to the -w flag features it will also automatically start the auto-reload server.
24-
*
27+
*
28+
* php builder.php -wp
29+
* Similar to the -w flag but it only generates and then watches the patterns. Does NOT clean public/ when generating the site.
30+
*
2531
* php builder.php -v
2632
* Prints out the current version of Pattern Lab.
2733
*
@@ -50,7 +56,7 @@
5056
}
5157

5258
// grab the arguments from the command line
53-
$args = getopt("gwcrv");
59+
$args = getopt("gwcrvpn");
5460

5561
// load Pattern Lab's config, if first time set-up move files appropriately too
5662
$co = new PatternLab\Configurer;
@@ -66,14 +72,28 @@
6672
if (isset($args["g"]) || isset($args["w"])) {
6773

6874
$g = new PatternLab\Generator($config);
69-
$c = false;
75+
76+
// set some default values
77+
$enableCSS = false;
78+
$moveStatic = true;
79+
$noCacheBuster = false;
7080

7181
// check to see if CSS for patterns should be parsed & outputted
7282
if (isset($args["c"]) && !isset($args["w"])) {
73-
$c = true;
83+
$enableCSS = true;
7484
}
7585

76-
$g->generate($c);
86+
// check to see if we should just generate the patterns
87+
if (isset($args["p"])) {
88+
$moveStatic = false;
89+
}
90+
91+
// check to see if we should turn off the cachebuster value
92+
if (isset($args["n"])) {
93+
$noCacheBuster = true;
94+
}
95+
96+
$g->generate($enableCSS,$moveStatic,$noCacheBuster);
7797

7898
// have some fun
7999
if (!isset($args["w"])) {
@@ -86,13 +106,15 @@
86106
if (isset($args["w"])) {
87107

88108
$w = new PatternLab\Watcher($config);
89-
$a = false;
109+
110+
// set some default values
111+
$reload = false;
90112

91113
if (isset($args["r"])) {
92-
$a = true;
114+
$reload = true;
93115
}
94116

95-
$w->watch($a);
117+
$w->watch($reload,$moveStatic);
96118

97119
}
98120

@@ -105,12 +127,16 @@
105127
print " Iterates over the 'source' directories & files and generates the entire site a single time.\n";
106128
print " It also cleans the 'public' directory.\n\n";
107129
print " php ".$_SERVER["PHP_SELF"]." -gc\n";
108-
print " In addition to the -g flag features it will also generate CSS for each pattern. Resource instensive.\n\n";
130+
print " In addition to the -g flag features it will also generate CSS for each pattern. Resource intensive.\n\n";
131+
print " php ".$_SERVER["PHP_SELF"]." -gp\n";
132+
print " Generates only the patterns a site. Does NOT clean public/ when generating the site.\n\n";
109133
print " php ".$_SERVER["PHP_SELF"]." -w\n";
110134
print " Generates the site like the -g flag and then watches for changes in the 'source' directories &\n";
111135
print " files. Will re-generate files if they've changed.\n\n";
112136
print " php ".$_SERVER["PHP_SELF"]." -wr\n";
113137
print " In addition to the -w flag features it will also automatically start the auto-reload server.\n\n";
138+
print " php ".$_SERVER["PHP_SELF"]." -wp\n";
139+
print " Similar to the -w flag but it only generates and then watches the patterns. Does NOT clean public/ when generating the site.\n\n";
114140
print " php ".$_SERVER["PHP_SELF"]." -v\n";
115141
print " Prints out the current version of Pattern Lab.\n\n";
116142

core/config/config.ini.default

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ v = "0.7.8"
99
ie = "scss,DS_Store,less"
1010

1111
// directories and files to ignore when building or watching the source dir, separate with a comma
12-
id = "scss,.svn"
12+
id = "scss,.svn,.sass-cache"
1313

1414
// choose which ports the websocket services should run on
1515
autoReloadPort = "8002"
@@ -28,4 +28,4 @@ ishControlsHide = ""
2828
patternStates = "inprogress,inreview,complete"
2929

3030
// the pattern types that shouldn't be included in the style guide
31-
styleGuideExcludes = ""
31+
styleGuideExcludes = ""

core/lib/PatternLab/Builder.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class Builder {
4444
protected $patternCSS; // an array to hold the CSS generated for patterns
4545
protected $cssRuleSaver; // where css rule saver will be initialized
4646
protected $cacheBuster; // a timestamp used to bust the cache for static assets like CSS and JS
47+
protected $noCacheBuster; // should we turn the cache buster on or off?
4748
protected $patternHead; // the header to be included on patterns
4849
protected $patternFoot; // the footer to be included on patterns
4950
protected $mainPageHead; // the header to be included on main pages
@@ -390,7 +391,7 @@ protected function generateViewAllPages() {
390391
protected function gatherData() {
391392

392393
// set the cacheBuster
393-
$this->cacheBuster = time();
394+
$this->cacheBuster = $this->noCacheBuster ? 0 : time();
394395

395396
// gather the data from the main source data.json
396397
if (file_exists($this->sd."/_data/_data.json")) {

core/lib/PatternLab/Generator.php

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ public function __construct($config = array()) {
2828
/**
2929
* Pulls together a bunch of functions from builder.lib.php in an order that makes sense
3030
* @param {Boolean} decide if CSS should be parsed and saved. performance hog.
31+
* @param {Boolean} decide if static files like CSS and JS should be moved
3132
*/
32-
public function generate($enableCSS = false) {
33+
public function generate($enableCSS = false, $moveStatic = true, $noCacheBuster = false) {
3334

3435
$timePL = true; // track how long it takes to generate a PL site
3536

@@ -40,6 +41,8 @@ public function generate($enableCSS = false) {
4041
$starttime = $mtime;
4142
}
4243

44+
$this->noCacheBuster = $noCacheBuster;
45+
4346
if ($enableCSS) {
4447

4548
// enable CSS globally throughout PL
@@ -58,7 +61,7 @@ public function generate($enableCSS = false) {
5861
$this->gatherPatternInfo();
5962

6063
// clean the public directory to remove old files
61-
if ($this->cleanPublic == "true") {
64+
if (($this->cleanPublic == "true") && $moveStatic) {
6265
$this->cleanPublic();
6366
}
6467

@@ -83,29 +86,34 @@ public function generate($enableCSS = false) {
8386

8487
}
8588

86-
// iterate over all of the other files in the source directory
87-
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->sd."/"), \RecursiveIteratorIterator::SELF_FIRST);
88-
89-
// make sure dots are skipped
90-
$objects->setFlags(\FilesystemIterator::SKIP_DOTS);
91-
92-
foreach($objects as $name => $object) {
89+
// move all of the files unless pattern only is set
90+
if ($moveStatic) {
9391

94-
// clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
95-
$fileName = str_replace($this->sd.DIRECTORY_SEPARATOR,"",$name);
96-
if (($fileName[0] != "_") && (!in_array($object->getExtension(),$this->ie)) && (!in_array($object->getFilename(),$this->id))) {
97-
98-
// catch directories that have the ignored dir in their path
99-
$ignoreDir = $this->ignoreDir($fileName);
100-
101-
// check to see if it's a new directory
102-
if (!$ignoreDir && $object->isDir() && !is_dir($this->pd."/".$fileName)) {
103-
mkdir($this->pd."/".$fileName);
104-
}
92+
// iterate over all of the other files in the source directory
93+
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->sd."/"), \RecursiveIteratorIterator::SELF_FIRST);
94+
95+
// make sure dots are skipped
96+
$objects->setFlags(\FilesystemIterator::SKIP_DOTS);
97+
98+
foreach($objects as $name => $object) {
10599

106-
// check to see if it's a new file or a file that has changed
107-
if (!$ignoreDir && $object->isFile() && (!file_exists($this->pd."/".$fileName))) {
108-
$this->moveStaticFile($fileName);
100+
// clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
101+
$fileName = str_replace($this->sd.DIRECTORY_SEPARATOR,"",$name);
102+
if (($fileName[0] != "_") && (!in_array($object->getExtension(),$this->ie)) && (!in_array($object->getFilename(),$this->id))) {
103+
104+
// catch directories that have the ignored dir in their path
105+
$ignoreDir = $this->ignoreDir($fileName);
106+
107+
// check to see if it's a new directory
108+
if (!$ignoreDir && $object->isDir() && !is_dir($this->pd."/".$fileName)) {
109+
mkdir($this->pd."/".$fileName);
110+
}
111+
112+
// check to see if it's a new file or a file that has changed
113+
if (!$ignoreDir && $object->isFile() && (!file_exists($this->pd."/".$fileName))) {
114+
$this->moveStaticFile($fileName);
115+
}
116+
109117
}
110118

111119
}

core/lib/PatternLab/Watcher.php

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ public function __construct($config = array()) {
3030

3131
/**
3232
* Watch the source/ directory for any changes to existing files. Will run forever if given the chance.
33+
* @param {Boolean} decide if the reload server should be turned on
34+
* @param {Boolean} decide if static files like CSS and JS should be moved
3335
*/
34-
public function watch($reload = false) {
36+
public function watch($reload = false, $moveStatic = true) {
3537

3638
// automatically start the auto-refresh tool
3739
if ($reload) {
@@ -155,55 +157,60 @@ public function watch($reload = false) {
155157
}
156158

157159
// iterate over all of the other files in the source directory and move them if their modified time has changed
158-
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->sd."/"), \RecursiveIteratorIterator::SELF_FIRST);
159-
160-
// make sure dots are skipped
161-
$objects->setFlags(\FilesystemIterator::SKIP_DOTS);
162-
163-
foreach($objects as $name => $object) {
160+
if ($moveStatic) {
164161

165-
// clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
166-
$fileName = str_replace($this->sd.DIRECTORY_SEPARATOR,"",$name);
167-
if (($fileName[0] != "_") && (!in_array($object->getExtension(),$this->ie)) && (!in_array($object->getFilename(),$this->id))) {
168-
169-
// catch directories that have the ignored dir in their path
170-
$ignoreDir = $this->ignoreDir($fileName);
171-
172-
// check to see if it's a new directory
173-
if (!$ignoreDir && $object->isDir() && !isset($o->$fileName) && !is_dir($this->pd."/".$fileName)) {
174-
mkdir($this->pd."/".$fileName);
175-
$o->$fileName = "dir created"; // placeholder
176-
print $fileName."/ directory was created...\n";
177-
}
162+
$objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->sd."/"), \RecursiveIteratorIterator::SELF_FIRST);
163+
164+
// make sure dots are skipped
165+
$objects->setFlags(\FilesystemIterator::SKIP_DOTS);
166+
167+
foreach($objects as $name => $object) {
178168

179-
// check to see if it's a new file or a file that has changed
180-
if (file_exists($name)) {
169+
// clean-up the file name and make sure it's not one of the pattern lab files or to be ignored
170+
$fileName = str_replace($this->sd.DIRECTORY_SEPARATOR,"",$name);
171+
if (($fileName[0] != "_") && (!in_array($object->getExtension(),$this->ie)) && (!in_array($object->getFilename(),$this->id))) {
181172

182-
$mt = $object->getMTime();
183-
if (!$ignoreDir && $object->isFile() && !isset($o->$fileName) && !file_exists($this->pd."/".$fileName)) {
184-
$o->$fileName = $mt;
185-
$this->moveStaticFile($fileName,"added");
186-
if ($object->getExtension() == "css") {
187-
$this->updateSite($fileName,"changed",0); // make sure the site is updated for MQ reasons
188-
}
189-
} else if (!$ignoreDir && $object->isFile() && isset($o->$fileName) && ($o->$fileName != $mt)) {
190-
$o->$fileName = $mt;
191-
$this->moveStaticFile($fileName,"changed");
192-
if ($object->getExtension() == "css") {
193-
$this->updateSite($fileName,"changed",0); // make sure the site is updated for MQ reasons
173+
// catch directories that have the ignored dir in their path
174+
$ignoreDir = $this->ignoreDir($fileName);
175+
176+
// check to see if it's a new directory
177+
if (!$ignoreDir && $object->isDir() && !isset($o->$fileName) && !is_dir($this->pd."/".$fileName)) {
178+
mkdir($this->pd."/".$fileName);
179+
$o->$fileName = "dir created"; // placeholder
180+
print $fileName."/ directory was created...\n";
181+
}
182+
183+
// check to see if it's a new file or a file that has changed
184+
if (file_exists($name)) {
185+
186+
$mt = $object->getMTime();
187+
if (!$ignoreDir && $object->isFile() && !isset($o->$fileName) && !file_exists($this->pd."/".$fileName)) {
188+
$o->$fileName = $mt;
189+
$this->moveStaticFile($fileName,"added");
190+
if ($object->getExtension() == "css") {
191+
$this->updateSite($fileName,"changed",0); // make sure the site is updated for MQ reasons
192+
}
193+
} else if (!$ignoreDir && $object->isFile() && isset($o->$fileName) && ($o->$fileName != $mt)) {
194+
$o->$fileName = $mt;
195+
$this->moveStaticFile($fileName,"changed");
196+
if ($object->getExtension() == "css") {
197+
$this->updateSite($fileName,"changed",0); // make sure the site is updated for MQ reasons
198+
}
199+
} else if (!isset($o->fileName)) {
200+
$o->$fileName = $mt;
194201
}
195-
} else if (!isset($o->fileName)) {
196-
$o->$fileName = $mt;
202+
203+
} else {
204+
unset($o->$fileName);
197205
}
198206

199-
} else {
200-
unset($o->$fileName);
201207
}
202208

203209
}
204210

205211
}
206212

213+
207214
$c = true;
208215

209216
// taking out the garbage. basically killing mustache after each run.

core/source/_patterns/00-atoms/02-text/07-hr.mustache

Lines changed: 0 additions & 1 deletion
This file was deleted.

core/source/_patterns/01-molecules/00-text/01-byline-author-time.mustache

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)