Skip to content

Commit 3f2efa9

Browse files
author
Brian Muenzenmeyer
committed
Merge pull request pattern-lab#207 from pattern-lab/dev
v1.0.0
2 parents e8f060f + ddfd363 commit 3f2efa9

26 files changed

+403
-158
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ public/index.html
44
public/styleguide.html
55
public/styleguide/html/styleguide.html
66
public/css/*
7+
public/data/*
78
public/fonts/*
89
public/js/*
910
public/images/*

CHANGELOG

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.
22

3+
PL-node-v1.0.0
4+
- FIX: Resolve issue with not hiding underscored patterns.
5+
- THX: Thanks @ivancamilov for reporting this regression.
6+
- FIX: Fix misapplied error input class
7+
- THX: Thanks @johngerome for the pull request!
8+
- ADD: Added a note in the README during installation to run with elevated privileges
9+
- THX: Thanks @RichardBray for the heads up
10+
- ADD: Added a Prerequisites section to the README
11+
- ADD: Added unit tests for pattern states and pseudopatterns
12+
- CHG: Changed pseudopattern generation to use config.patterns.source directory instead of hardcode
13+
- CHG: Explicitly sorting patterns by name prior to building the UI
14+
- ADD: Added ability to specify link.* urls inside data objects
15+
- CHG: Incremented version to 1.0.0. Achieved near-parity with PL PHP 1!
16+
- THX: Thanks to each and every person who cared about Pattern Lab Node! - Brian
17+
318
PL-node-v0.15.1
419
- FIX: Resolve issue with styleModifiers not being replaced when the partial has spaces in it.
520
- ADD: Support multiple styleModifier classes using the | pipe syntax

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@ The Node version of [Pattern Lab](http://patternlab.io/) is, at its core, a stat
66

77
This repository contains the vanilla builder logic, grunt and gulp configurations, and some sample template/css/data to illustrate the power and flexibility of the tool.
88

9+
### Prerequisites
10+
11+
Make sure Node and npm are installed. A great guide can be found here: [https://docs.npmjs.com/getting-started/installing-node](https://docs.npmjs.com/getting-started/installing-node)
12+
913
### Download
1014

1115
* Download the [latest release of patternlab-node](https://github.com/pattern-lab/patternlab-node/releases/latest) from Github
1216
* Via npm, run `npm install patternlab-node` (Note this will auto install the grunt version currently. see below)
1317
* **NOTE** Node version 4.X and 5.X have tentative support, citing [a lot of Windows issues](https://github.com/nodejs/node-gyp/issues/629), including [mine](https://github.com/pattern-lab/patternlab-node/issues/162). Upgrade node at your own risk until otherwise stated. I've tried to catalog some issues and troubleshooting steps on the [wiki](https://github.com/pattern-lab/patternlab-node/wiki/Windows-Issues).
1418

19+
### Troubleshooting Installs
20+
21+
Make sure you are running your terminal/command line session as administrator. This could mean `sudo`, or opening the window with a right-click option.
22+
1523
### Choose Your Adventure! Now Vanilla, Grunt & Gulp
1624

1725
This repository ships with two `package.json` files, a `Gruntfile.js`, and a `gulpfile.js`. The default is grunt currently. The core builder is not dependent on either.

builder/lineage_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.15.1 - 2015
2+
* patternlab-node - v1.0.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/list_item_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.15.1 - 2015
2+
* patternlab-node - v1.0.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/media_hunter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.15.1 - 2015
2+
* patternlab-node - v1.0.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/object_factory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.15.1 - 2015
2+
* patternlab-node - v1.0.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/parameter_hunter.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
* patternlab-node - v0.15.1 - 2015
3-
*
1+
/*
2+
* patternlab-node - v1.0.0 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
5-
* Licensed under the MIT license.
6-
*
7-
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
5+
* Licensed under the MIT license.
6+
*
7+
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
88
*
99
*/
1010

builder/pattern_assembler.js

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
/*
2-
* patternlab-node - v0.15.1 - 2015
3-
*
1+
/*
2+
* patternlab-node - v1.0.0 - 2015
3+
*
44
* Brian Muenzenmeyer, and the web community.
5-
* Licensed under the MIT license.
6-
*
7-
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
5+
* Licensed under the MIT license.
6+
*
7+
* Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
88
*
99
*/
1010

@@ -46,14 +46,15 @@
4646
}
4747

4848
function setState(pattern, patternlab){
49-
if(patternlab.config.patternStates[pattern.patternName]){
49+
if(patternlab.config.patternStates && patternlab.config.patternStates[pattern.patternName]){
5050
pattern.patternState = patternlab.config.patternStates[pattern.patternName];
5151
} else{
5252
pattern.patternState = "";
5353
}
5454
}
5555

5656
function addPattern(pattern, patternlab){
57+
//add the link to the global object
5758
patternlab.data.link[pattern.patternGroup + '-' + pattern.patternName] = '/patterns/' + pattern.patternLink;
5859

5960
//only push to array if the array doesn't contain this pattern
@@ -94,21 +95,17 @@
9495
var filename = path.basename(file);
9596
var ext = path.extname(filename);
9697

97-
//ignore dotfiles and non-variant .json files
98-
if(filename.charAt(0) === '.' || (ext === '.json' && filename.indexOf('~') === -1)){
98+
//ignore dotfiles, underscored files, and non-variant .json files
99+
if(filename.charAt(0) === '.' || filename.charAt(0) === '_' || (ext === '.json' && filename.indexOf('~') === -1)){
99100
return;
100101
}
101102

102103
//make a new Pattern Object
103104
var currentPattern = new of.oPattern(file, subdir, filename);
104105

105-
//if file is named in the syntax for variants
106+
//if file is named in the syntax for variants, no need to process further
107+
//processPatternRecursive() will run find_pseudopatterns() and look at each pattern for a variant
106108
if(ext === '.json' && filename.indexOf('~') > -1){
107-
//add current pattern to patternlab object with minimal data
108-
//processPatternRecursive() will run find_pseudopatterns() to fill out
109-
//the object in the next diveSync
110-
addPattern(currentPattern, patternlab);
111-
//no need to process further
112109
return;
113110
}
114111

@@ -321,6 +318,36 @@
321318
return o;
322319
}
323320

321+
//look for pattern links included in data files.
322+
//these will be in the form of link.* WITHOUT {{}}, which would still be there from direct pattern inclusion
323+
function parseDataLinks(patternlab){
324+
325+
//loop through all patterns
326+
for (var i = 0; i < patternlab.patterns.length; i++){
327+
var pattern = patternlab.patterns[i];
328+
//look for link.* such as link.pages-blog as a value
329+
var linkRE = /link.[A-z0-9-_]+/g;
330+
//convert to string for easier searching
331+
var dataObjAsString = JSON.stringify(pattern.jsonFileData);
332+
var linkMatches = dataObjAsString.match(linkRE);
333+
334+
//if no matches found, escape current loop iteration
335+
if(linkMatches === null) { continue; }
336+
337+
for(var i = 0; i < linkMatches.length; i++){
338+
//for each match, find the expanded link within the already constructed patternlab.data.link object
339+
var expandedLink = patternlab.data.link[linkMatches[i].split('.')[1]];
340+
if(patternlab.config.debug){
341+
console.log('expanded data link from ' + linkMatches[i] + ' to ' + expandedLink + ' inside ' + pattern.key);
342+
}
343+
//replace value with expandedLink on the pattern
344+
dataObjAsString = dataObjAsString.replace(linkMatches[i], expandedLink);
345+
}
346+
//write back to data on the pattern
347+
pattern.jsonFileData = JSON.parse(dataObjAsString);
348+
}
349+
}
350+
324351
return {
325352
find_pattern_partials: function(pattern){
326353
return findPartials(pattern);
@@ -360,6 +387,9 @@
360387
},
361388
is_object_empty: function(obj){
362389
return isObjectEmpty(obj);
390+
},
391+
parse_data_links: function(patternlab){
392+
parseDataLinks(patternlab);
363393
}
364394
};
365395

builder/pattern_exporter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.15.1 - 2015
2+
* patternlab-node - v1.0.0 - 2015
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

0 commit comments

Comments
 (0)