Skip to content

Commit 02834b6

Browse files
author
Brian Muenzenmeyer
committed
Merge pull request #21 from pattern-lab/nav-fixes
Version 0.1.0
2 parents 3700bd9 + 63029d9 commit 02834b6

27 files changed

+2024
-1456
lines changed

CHANGELOG

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

3+
PL-node-v0.1.0
4+
- FIX: Links to patterns did not work when visited from a server
5+
- FIX: Patterns with hyphens in the name were breaking the iframe messaging
6+
- FIX: Added stlyeguide/js files that were ignored at one point
7+
- FIX: Watch _data/*.json files too
8+
- FIX: Copy images, in an attempt to exclude files like Thumbs.db
9+
- FIX: Typos in CHANGELOG
10+
- ADD: A banner to patternlab.js
11+
312
PL-node-v0.0.5
4-
- FIX: type in organisms global header
13+
- FIX: typo in organisms global header
514
- FIX: flat-structured pattern items rendered as if they had sub-menus #4
615
- ADD: Load all grunt tasks using matchdep
716
- THX: thanks to @colynb for the typo heads up
@@ -21,4 +30,4 @@ PL-node-v0.0.2
2130
- FIX: Grunt watching styleguide scss
2231

2332
PL-node-v0.0.1
24-
- Minimum Viable Product! At this point, I feel you could use Pattern Lab Node to build a atomic design-drive website.
33+
- Minimum Viable Product! At this point, I feel you could use Pattern Lab Node to build an atomic design-driven website.

Gruntfile.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,25 @@ module.exports = function(grunt) {
44
grunt.initConfig({
55
pkg: grunt.file.readJSON('package.json'),
66
clean: ['./public/patterns'],
7+
concat: {
8+
options: {
9+
stripBanners: true,
10+
banner: '/* \n * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> \n * \n * <%= pkg.author %>, and the web community.\n * Licensed under the <%= pkg.license %> license. \n * \n * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. \n *\n */\n\n',
11+
},
12+
dist: {
13+
src: './builder/patternlab.js',
14+
dest: './builder/patternlab.js'
15+
}
16+
},
717
copy: {
818
main: {
919
files: [
1020
{ expand: true, cwd: './source/js/', src: '*', dest: './public/js/'},
1121
{ expand: true, cwd: './source/css/', src: 'style.css', dest: './public/css/' },
1222
{ expand: true, cwd: './source/images/', src: ['*.png', '*.jpg', '*.gif', '*.jpeg'], dest: './public/images/' },
1323
{ expand: true, cwd: './source/images/sample/', src: ['*.png', '*.jpg', '*.gif', '*.jpeg'], dest: './public/images/sample/'},
14-
{ expand: true, cwd: './source/fonts/', src: '*', dest: './public/fonts/'}
24+
{ expand: true, cwd: './source/fonts/', src: '*', dest: './public/fonts/'},
25+
{ expand: true, cwd: './source/_data/', src: 'annotations.js', dest: './public/data/' }
1526
]
1627
}
1728
},
@@ -63,5 +74,5 @@ module.exports = function(grunt) {
6374
grunt.task.loadTasks('./builder/');
6475

6576
//if you choose to use scss, or any preprocessor, you can add it here
66-
grunt.registerTask('default', ['clean', 'patternlab', /*'sass',*/ 'copy']);
77+
grunt.registerTask('default', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy']);
6778
};

builder/patternlab.js

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/*
2+
* patternlab-node - v0.1.0 - 2014-01-21
3+
*
4+
* 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.
8+
*
9+
*/
10+
111
var path = require('path');
212

313
var oPattern = function(name, subdir, filename, data){
@@ -6,7 +16,7 @@ var oPattern = function(name, subdir, filename, data){
616
this.filename = filename;
717
this.data = data;
818
this.template = '';
9-
this.patternOutput = '';
19+
this.patternPartial = '';
1020
this.patternName = ''; //this is the display name for the ui
1121
this.patternLink = '';
1222
this.patternGroup = name.substring(name.indexOf('-') + 1, name.indexOf('-', 4) + 1 - name.indexOf('-') + 1);
@@ -91,11 +101,15 @@ module.exports = function(grunt) {
91101
currentPattern.template = grunt.file.read(abspath);
92102

93103
//render the pattern. pass partials object just in case.
94-
currentPattern.patternOutput = mustache.render(currentPattern.template, patternlab.data, patternlab.partials);
104+
currentPattern.patternPartial = mustache.render(currentPattern.template, patternlab.data, patternlab.partials);
95105

96106
//write the compiled template to the public patterns directory
97107
flatPatternPath = currentPattern.name + '/' + currentPattern.name + '.html';
98-
grunt.file.write('./public/patterns/' + flatPatternPath, patternlab.header + currentPattern.patternOutput + patternlab.footer);
108+
109+
//add footer info before writing
110+
var currentPatternFooter = mustache.render(patternlab.footer, currentPattern);
111+
112+
grunt.file.write('./public/patterns/' + flatPatternPath, patternlab.header + currentPattern.patternPartial + currentPatternFooter);
99113
currentPattern.patternLink = flatPatternPath;
100114

101115
//add as a partial in case this is referenced later. convert to syntax needed by existing patterns
@@ -126,12 +140,17 @@ module.exports = function(grunt) {
126140
currentPattern.template = grunt.file.read(abspath);
127141

128142
//render the pattern. pass partials object just in case.
129-
currentPattern.patternOutput = mustache.render(currentPattern.template, currentPattern.data, patternlab.partials);
143+
currentPattern.patternPartial = mustache.render(currentPattern.template, currentPattern.data, patternlab.partials);
130144
grunt.log.writeln('template compiled with data!');
131145

132146
//write the compiled template to the public patterns directory
133147
flatPatternPath = currentPattern.name + '/' + currentPattern.name + '.html';
134-
grunt.file.write('./public/patterns/' + flatPatternPath, patternlab.header + currentPattern.patternOutput + patternlab.footer);
148+
149+
//add footer info before writing
150+
var currentPatternFooter = mustache.render(patternlab.footer, currentPattern);
151+
152+
grunt.file.write('./public/patterns/' + flatPatternPath, patternlab.header + currentPattern.patternPartial + currentPatternFooter);
153+
135154
currentPattern.patternLink = flatPatternPath;
136155

137156
//done
@@ -184,31 +203,32 @@ module.exports = function(grunt) {
184203
//assume the navSubItem does not exist.
185204
var navSubItem = new oNavSubItem(navSubItemName);
186205
navSubItem.patternPath = pattern.patternLink;
187-
navSubItem.patternPartial = bucketName + "-" + navSubItemName;
206+
navSubItem.patternPartial = bucketName + "-" + pattern.patternName; //add the hyphenated name
188207

189208
//if it is flat - we should not add the pattern to patternPaths
190209
if(flatPatternItem){
191-
//grunt.log.writeln('flat source structure found for ' + navItemName + " " + bucketName);
192210

193-
//add the navItem to patternItems
194211
bucket.patternItems.push(navSubItem);
212+
213+
//add to patternPaths
214+
patternlab.patternPaths[bucketName][pattern.patternName] = pattern.subdir + "/" + pattern.filename.substring(0, pattern.filename.indexOf('.'));
195215

196216
} else{
197-
//add the more complex nav items
217+
198218
bucket.navItems.push(navItem);
199219
bucket.navItemsIndex.push(navItemName);
200220
navItem.navSubItems.push(navSubItem);
201221
navItem.navSubItemsIndex.push(navSubItemName);
202222

203223
//add to patternPaths
204-
patternlab.patternPaths[bucketName][navSubItemName] = pattern.subdir + "/" + pattern.filename.substring(0, pattern.filename.indexOf('.'));
205-
}
224+
patternlab.patternPaths[bucketName][pattern.patternName] = pattern.subdir + "/" + pattern.filename.substring(0, pattern.filename.indexOf('.'));
225+
226+
}
206227

207228
//add the bucket.
208229
patternlab.buckets.push(bucket);
209230
patternlab.bucketIndex.push(bucketName);
210231

211-
212232
//done
213233

214234
} else{
@@ -224,7 +244,7 @@ module.exports = function(grunt) {
224244
//assume the navSubItem does not exist.
225245
var navSubItem = new oNavSubItem(navSubItemName);
226246
navSubItem.patternPath = pattern.patternLink;
227-
navSubItem.patternPartial = bucketName + "-" + navSubItemName;
247+
navSubItem.patternPartial = bucketName + "-" + pattern.patternName; //add the hyphenated name
228248

229249
//test whether the pattern struture is flat or not - usually due to a template or page
230250
var flatPatternItem = false;
@@ -234,10 +254,13 @@ module.exports = function(grunt) {
234254

235255
//if it is flat - we should not add the pattern to patternPaths
236256
if(flatPatternItem){
237-
//grunt.log.writeln('flat source structure found for ' + navItemName + " " + bucketName);
238257

239258
//add the navItem to patternItems
240259
bucket.patternItems.push(navSubItem);
260+
261+
//add to patternPaths
262+
patternlab.patternPaths[bucketName][pattern.patternName] = pattern.subdir + "/" + pattern.filename.substring(0, pattern.filename.indexOf('.'));
263+
241264
} else{
242265
//check to see if navItem exists
243266
var navItemIndex = bucket.navItemsIndex.indexOf(navItemName);
@@ -258,12 +281,11 @@ module.exports = function(grunt) {
258281
navItem.navSubItemsIndex.push(navSubItemName);
259282
}
260283

261-
//add to patternPaths
262-
patternlab.patternPaths[bucketName][navSubItemName] = pattern.subdir + "/" + pattern.filename.substring(0, pattern.filename.indexOf('.'));
284+
// just add to patternPaths
285+
patternlab.patternPaths[bucketName][pattern.patternName] = pattern.subdir + "/" + pattern.filename.substring(0, pattern.filename.indexOf('.'));
263286

264287
}
265288

266-
267289
//check to see if this bucket has a View All yet. If not, add it.
268290
// var navItem = bucket.navItems[navItemIndex];
269291
// if(navItem){

package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "patternlab-node",
3-
"version": "0.0.5",
3+
"description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).",
4+
"version": "0.1.0",
45
"devDependencies": {
56
"grunt": "~0.4.0",
67
"grunt-contrib-nodeunit": "~0.1.2",
@@ -9,6 +10,16 @@
910
"grunt-contrib-copy": "~0.4.0",
1011
"grunt-contrib-jshint": "~0.4.0",
1112
"grunt-contrib-clean": "~0.5.0",
13+
"grunt-contrib-concat": "~0.3.0",
1214
"matchdep": "~0.3.0"
13-
}
15+
},
16+
"keywords": [
17+
"Pattern Lab",
18+
"Atomic Web Design",
19+
"Node",
20+
"Grunt",
21+
"Javascript"
22+
],
23+
"author": "Brian Muenzenmeyer",
24+
"license": "MIT"
1425
}

0 commit comments

Comments
 (0)