Skip to content

Commit 14415ed

Browse files
committed
pattern states and connect and dot files
fixes #51 fixes #50 fixes #44 fixes #34
1 parent 448fb04 commit 14415ed

File tree

10 files changed

+76
-20
lines changed

10 files changed

+76
-20
lines changed

CHANGELOG

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

3+
PL-node-v0.1.3
4+
- ADD: Pattern states
5+
- FIX: Removed all grunt dependencies from patternlab.js
6+
- ADD: Ships with grunt connect if you are into that kinda thing
7+
38
PL-node-v0.1.2
49
- ADD: Abstracted template rendering into a function for easier swapping of rendering engine
510
- ADD: Smarter filtering of files to support other templates Thanks

Gruntfile.js

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ module.exports = function(grunt) {
2424
copy: {
2525
main: {
2626
files: [
27-
{ expand: true, cwd: './source/js/', src: '*', dest: './public/js/'},
28-
{ expand: true, cwd: './source/css/', src: 'style.css', dest: './public/css/' },
29-
{ expand: true, cwd: './source/images/', src: ['*.png', '*.jpg', '*.gif', '*.jpeg'], dest: './public/images/' },
30-
{ expand: true, cwd: './source/images/sample/', src: ['*.png', '*.jpg', '*.gif', '*.jpeg'], dest: './public/images/sample/'},
31-
{ expand: true, cwd: './source/fonts/', src: '*', dest: './public/fonts/'},
32-
{ expand: true, cwd: './source/_data/', src: 'annotations.js', dest: './public/data/' }
27+
{ expand: true, cwd: './source/js/', src: '*', dest: './public/js/'},
28+
{ expand: true, cwd: './source/css/', src: 'style.css', dest: './public/css/' },
29+
{ expand: true, cwd: './source/images/', src: ['*.png', '*.jpg', '*.gif', '*.jpeg'], dest: './public/images/' },
30+
{ expand: true, cwd: './source/images/sample/', src: ['*.png', '*.jpg', '*.gif', '*.jpeg'], dest: './public/images/sample/'},
31+
{ expand: true, cwd: './source/fonts/', src: '*', dest: './public/fonts/'},
32+
{ expand: true, cwd: './source/_data/', src: 'annotations.js', dest: './public/data/' }
3333
]
3434
}
3535
},
@@ -50,12 +50,12 @@ module.exports = function(grunt) {
5050
// files: ['source/css/**/*.scss', 'public/styleguide/css/*.scss'],
5151
// tasks: ['default']
5252
// },
53-
mustache: {
54-
files: ['source/_patterns/**/*.mustache'],
55-
tasks: ['default']
56-
},
57-
data: {
58-
files: ['source/_patterns/**/*.json', 'source/_data/*.json'],
53+
all: {
54+
files: [
55+
'source/_patterns/**/*.mustache',
56+
'source/_patterns/**/*.json',
57+
'source/_data/*.json'
58+
],
5959
tasks: ['default']
6060
}
6161
},
@@ -74,6 +74,16 @@ module.exports = function(grunt) {
7474
},
7575
nodeunit: {
7676
all: ['test/*_tests.js']
77+
},
78+
connect: {
79+
app:{
80+
options: {
81+
port: 9001,
82+
base: './public',
83+
hostname: 'localhost',
84+
keepalive: true
85+
}
86+
}
7787
}
7888
});
7989

@@ -88,4 +98,10 @@ module.exports = function(grunt) {
8898

8999
//travis CI task
90100
grunt.registerTask('travis', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy', 'nodeunit']);
101+
102+
grunt.registerTask('serve', ['clean', 'concat', 'patternlab', /*'sass',*/ 'copy', 'connect:app']);
103+
//need to get livereload working
104+
//http://www.thecrumb.com/2014/03/16/using-grunt-for-live-reload-revisited/
105+
//http://rhumaric.com/2013/07/renewing-the-grunt-livereload-magic/
106+
91107
};

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ The current selection is as follows. It reflects support versus patternlab-php.
6464
##### Verbose Mode
6565
`patternlab.json` is a file created for debugging purposes. Set `debug` to true in `.config.json` to see all the secrets.
6666

67+
##### Pattern States
68+
You can set the state of a pattern by including it in `config.json` too. The out of the box styles are in progress (orange), in review (yellow), and complete (green).
69+
Pattern states should be lowercase and use hyphens where spaces are present.
70+
```
71+
"patternStates": {
72+
"colors" : "inprogress",
73+
"fonts" : "inreview",
74+
"three-up" : "complete"
75+
}
76+
```
77+
78+
##### Server
79+
Running `grunt serve` will compile the patternlab front end and host it on <a href="http://localhost:9001">http://localhost:9001</a> by default. This can be changed in the `Gruntfile.js`
80+
81+
**Next steps: Livereload and watches**
82+
6783
### Under Active Development
6884

6985
[![Build Status](https://travis-ci.org/pattern-lab/patternlab-node.png?branch=master)](https://travis-ci.org/pattern-lab/patternlab-node) The Node version of Pattern Lab is under active development by [@bmuenzenmeyer](https://twitter.com/bmuenzenmeyer) and contributors. Pull requests welcome, but please take a moment to read the [guidelines](https://github.com/pattern-lab/patternlab-node/blob/master/CONTRIBUTING.md).

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.1.2 - 2014
2+
* patternlab-node - v0.1.3 - 2014
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.

builder/patternlab.js

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* patternlab-node - v0.1.2 - 2014
2+
* patternlab-node - v0.1.3 - 2014
33
*
44
* Brian Muenzenmeyer, and the web community.
55
* Licensed under the MIT license.
@@ -28,7 +28,7 @@ var patternlab_engine = function(){
2828
console.log('Patternlab Node Help');
2929
console.log('===============================');
3030
console.log('Command Line Arguments');
31-
console.log('patternlab:only_patterns');
31+
console.log('patternlab:only_patterns');
3232
console.log(' > Compiles the patterns only, outputting to ./public/patterns');
3333
console.log('patternlab:v');
3434
console.log(' > Retrieve the version of patternlab-node you have installed');
@@ -75,8 +75,8 @@ var patternlab_engine = function(){
7575
currentPattern,
7676
flatPatternPath;
7777

78-
//ignore _underscored patterns and json
79-
if(filename.charAt(0) === '_' || path.extname(filename) === '.json'){
78+
//ignore _underscored patterns, json, and dotfiles
79+
if(filename.charAt(0) === '_' || path.extname(filename) === '.json' || filename.charAt(0) === '.'){
8080
return;
8181
}
8282

@@ -88,6 +88,11 @@ var patternlab_engine = function(){
8888
currentPattern.patternName = patternName.substring(patternName.indexOf('-') + 1);
8989
currentPattern.data = null;
9090

91+
//see if this file has a state
92+
if(patternlab.config.patternStates[currentPattern.patternName]){
93+
currentPattern.patternState = patternlab.config.patternStates[currentPattern.patternName];
94+
}
95+
9196
//look for a json file for this template
9297
try {
9398
var jsonFilename = abspath.substr(0, abspath.lastIndexOf(".")) + ".json";
@@ -185,6 +190,11 @@ var patternlab_engine = function(){
185190
navSubItem.patternPath = pattern.patternLink;
186191
navSubItem.patternPartial = bucketName + "-" + pattern.patternName; //add the hyphenated name
187192

193+
//add the patternState if it exists
194+
if(pattern.patternState){
195+
navSubItem.patternState = pattern.patternState;
196+
}
197+
188198
//if it is flat - we should not add the pattern to patternPaths
189199
if(flatPatternItem){
190200

@@ -226,6 +236,11 @@ var patternlab_engine = function(){
226236
navSubItem.patternPath = pattern.patternLink;
227237
navSubItem.patternPartial = bucketName + "-" + pattern.patternName; //add the hyphenated name
228238

239+
//add the patternState if it exists
240+
if(pattern.patternState){
241+
navSubItem.patternState = pattern.patternState;
242+
}
243+
229244
//test whether the pattern struture is flat or not - usually due to a template or page
230245
var flatPatternItem = false;
231246
if(navItemName === bucketName){
@@ -267,7 +282,7 @@ var patternlab_engine = function(){
267282

268283
}
269284

270-
};
285+
}
271286

272287
//the patternlab site requires a lot of partials to be rendered.
273288
//patternNav

config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,7 @@
2727
"tools-reload": false,
2828
"tools-shortcuts": false,
2929
"tools-docs": true
30+
},
31+
"patternStates": {
3032
}
3133
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"grunt-contrib-clean": "~0.5.0",
1212
"grunt-contrib-concat": "~0.3.0",
1313
"grunt-contrib-nodeunit": "~0.3.0",
14+
"grunt-contrib-connect": "^0.8.0",
1415
"mustache": "~0.8.1",
1516
"matchdep": "~0.3.0",
1617
"dive": "^0.3.1",

source/_patternlab-files/partials/patternNav.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{{# navItems }}
55
<li class="sg-nav-{{ sectionNameLC }}"><a class="sg-acc-handle">{{ sectionNameUC }}</a><ol class="sg-acc-panel">
66
{{# navSubItems }}
7-
<li><a href="patterns/{{ patternPath }}" class="sg-pop" data-patternpartial="{{ patternPartial }}">{{ patternName }}</a></li>
7+
<li><a href="patterns/{{ patternPath }}" class="sg-pop {{# patternState }}sg-pattern-state {{ patternState }}{{/ patternState }}" data-patternpartial="{{ patternPartial }}">{{ patternName }}</a></li>
88
{{/ navSubItems }}
99
</ol></li>
1010
{{/ navItems }}

source/_patternlab-files/styleguide.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<div id="sg-patterns">
1818
{{# partials }}
1919
<div class="sg-pattern">
20-
<h2 class="sg-pattern-head" ><a href="../../patterns/{{ patternLink }}" class="patternLink" data-patternpartial="{{ patternPartialPath }}">{{ patternName }}</a></h2>
20+
<h2 class="sg-pattern-head" ><a href="../../patterns/{{ patternLink }}" class="patternLink {{# patternState }}sg-pattern-state {{ . }}{{/ patternState }}" data-patternpartial="{{ patternPartialPath }}">{{ patternName }}</a></h2>
2121
<div class="sg-pattern-body">
2222
{{{ patternPartial }}}
2323
<div class="sg-code" style="display: none">
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BOOM

0 commit comments

Comments
 (0)