Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern Lab Node v1.1.0 #243

Merged
merged 55 commits into from Feb 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
134e01a
Fix issue where partials containing styleModifiers with integers were…
bmuenzenmeyer Dec 17, 2015
5a091d8
Merge pull request #212 from pattern-lab/211
Dec 17, 2015
bf8cc0d
Fix issue where excluded patterns were still rendered on the Pattern …
bmuenzenmeyer Dec 18, 2015
d40ff89
Path reform! Make paths more configurable from the config.json, and try
geoffp Dec 22, 2015
d585257
some gulp cleanup
geoffp Dec 22, 2015
9dcfc63
make the gulpfile use the paths from the config JSON
geoffp Dec 23, 2015
57c1302
Nice comments in the gulpfile
geoffp Dec 23, 2015
9177378
we are not yet ready for handlebars unit tests, clearly
geoffp Dec 23, 2015
cafd440
fix one unit test
geoffp Dec 23, 2015
980118f
fuzzy partial matching. unit test coverage for some basic scenarios, …
bmuenzenmeyer Dec 29, 2015
90376d0
copy the retrieved partial during list item block parsing instead of …
bmuenzenmeyer Dec 29, 2015
a972335
fix name of unit test
bmuenzenmeyer Dec 29, 2015
ea6c625
Merge pull request #218 from pattern-lab/190
Dec 29, 2015
0307ab3
Merge branch 'dev' into fuzzy-patterns
bmuenzenmeyer Dec 30, 2015
22bf232
updated changelog to reference fuzzy pattern support
bmuenzenmeyer Dec 30, 2015
6ad11a6
Merge pull request #219 from pattern-lab/fuzzy-patterns
Dec 30, 2015
d01383a
Merge pull request #216 from geoffp/configurable-paths-galore
Jan 1, 2016
db3028d
Setting up absolute basics of being dependent and passing in configur…
EvanLovely Jan 5, 2016
6dfd2f7
moving browser sync html injector to dev deps
EvanLovely Jan 5, 2016
0619ab5
Fix gulpfile issues with copying and watching css files.
robinsonaaron Jan 7, 2016
784fc95
Merge pull request #228 from robinsonaaron/dev
Jan 8, 2016
6bc2f6e
Updated changelog to reflect robinsonaaron's PR
bmuenzenmeyer Jan 8, 2016
0173a0a
Prefer exact key match over verbose and partial matching
bmuenzenmeyer Jan 8, 2016
9c65be0
replace remaining .substring(2) path concatenations
geoffp Jan 7, 2016
3bbee0d
Merge remote-tracking branch 'refs/remotes/upstream/dev' into configu…
geoffp Jan 8, 2016
31d5ff6
re-delete the underscore-prefixed pattern unit test; not sure how this
geoffp Jan 8, 2016
a71069e
Update gulp direction in README
kyleknighted Jan 11, 2016
e15062b
Merge pull request #232 from kyleknighted/kyleknighted-patch-readme
Jan 13, 2016
14797d9
Merge pull request #230 from geoffp/configurable-paths-galore
Jan 14, 2016
630384b
Merge branch 'dev' into feature/enable-as-dependency
EvanLovely Jan 14, 2016
26d359f
Add entries to CHANGELOG to reflect resolved issues
bmuenzenmeyer Jan 14, 2016
e73b21d
When config loads json file, ensuring the path is resolved from the f…
EvanLovely Jan 14, 2016
18ff75a
Merge branch 'feature/enable-as-dependency' of https://github.com/Eva…
bmuenzenmeyer Jan 17, 2016
2a449d2
Merge branch 'EvanLovely-feature/enable-as-dependency' into dev
bmuenzenmeyer Jan 17, 2016
9af1814
moved styleguide to from public into the core directory
bmuenzenmeyer Jan 24, 2016
8ed60e0
remove scss files from styleguide project
bmuenzenmeyer Jan 27, 2016
b74988a
add the compiled css
bmuenzenmeyer Jan 27, 2016
c340e3c
removing experimental package
bmuenzenmeyer Jan 27, 2016
4a56ffa
whoops!
bmuenzenmeyer Jan 27, 2016
96f6432
switch output to source path of the styleguide so the copy command ca…
bmuenzenmeyer Jan 27, 2016
e4d71d1
gulp file basic support for styleguide copy and watch
bmuenzenmeyer Jan 28, 2016
e7b8d75
update gulp file dependencies
bmuenzenmeyer Jan 28, 2016
2b11640
updated changelog to reflect configurable paths and styleguide move
bmuenzenmeyer Jan 28, 2016
cb4fe8e
add README entry for configurable paths
bmuenzenmeyer Jan 28, 2016
3094e60
delete core/styleguide/html/styleguide.html from the shipped project …
bmuenzenmeyer Jan 28, 2016
1e21f59
add thank you to Geoff and Evan
bmuenzenmeyer Jan 28, 2016
bf17ef5
Merge pull request #237 from pattern-lab/core-restructure-start
Jan 28, 2016
f3f85c9
bugfix: #171 pattern links inside base data object
kylewelsby Jan 29, 2016
88ce8cf
added resolve path to grunt and gulp to guard against any relative pa…
bmuenzenmeyer Jan 30, 2016
b45a809
building patternlab.partials object during addPattern now.
bmuenzenmeyer Feb 3, 2016
04409d3
update patternlab.partials[key] if an extended template changes
bmuenzenmeyer Feb 3, 2016
d66edf0
allow pseudo linking
kylewelsby Feb 4, 2016
f187cf4
Merge pull request #239 from kylewelsby/master
Feb 7, 2016
2832cf7
Update changelog to reflect pattern link enhancement #239
bmuenzenmeyer Feb 7, 2016
5293fb9
bumped version number
bmuenzenmeyer Feb 7, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -18,3 +18,5 @@ public/styleguide/css/static.css.map
public/styleguide/css/styleguide-specific.css.map
public/styleguide/css/styleguide.css.map
source/css/style.css.map
.idea/
public/styleguide/
24 changes: 24 additions & 0 deletions CHANGELOG
@@ -1,5 +1,29 @@
THIS CHANGELOG IS AN ATTEMPT TO DOCUMENT CHANGES TO THIS PROJECT.

PL-node-v1.1.0
- FIX: Fixed issue where partials containing styleModifiers with integers were not found correctly under all circumstances
- FIX: Fixed issue where excluded patterns were still rendered on the Pattern Lab site. Now they do not directly get rendered via the menu, view all links, or the styleguide, but are accessible for inclusion as pattern partials, and can be accessed via lineage.
- THX: Thanks @theorise for reporting these issues.
- THX: Thanks @dmolsen for input on desired behavior.
- FIX: Fixed issue where style modifier partials within list item blocks where not uniquely being applied. this seems like a regression. added a unit test with fix
- ADD: Added fuzzy pattern matching support based on patternType-substring(patternName) to align with PL PHP
- FIX: Fixed issue with gulpfile not copying style.css and watching the wrong directory
- THX: Thanks @robinsonaaron for the issue and pull request!
- FIX: Prefer exact pattern key match over fuzzy matches inside getpatternbykey()
- THX: Thanks @EvanLovely for the suggestion
- ADD: Make all paths configurable
- THX: HUGE Thanks to @geoffp and @EvanLovely for their thoughts, time, and talent to make this a reality!
- FIX: Fix issue where absolute paths in the config path object would not resolve
- THX: Thanks to @geoffp and @EvanLovely for reporting, fixing and testing the issue in the dev branch.
- FIX: Typo in gulp instructions in README.
- THX: Thanks @simonknittel for the watchful eyes
- CHG: Changed locations of ./public/styleguide to ./core/styleguide to make ./public/ a cleaner distribution directory
- CHG: Removed scss files and config from project. This is in preparation for including the default asset repo in the future
- FIX: Fix issue where partials were not being sent to Mustache during pattern parameter parsing.
- THX: Thanks to @e2tha-e for reporting this issue.
- ADD: Now patterns and pseudopatterns can be linked from global or file data.json
- THX: Thanks @kylewelsby for the thoughtful enhancement

PL-node-v1.0.0
- FIX: Resolve issue with not hiding underscored patterns.
- THX: Thanks @ivancamilov for reporting this regression.
Expand Down
78 changes: 30 additions & 48 deletions Gruntfile.js
@@ -1,5 +1,7 @@
module.exports = function(grunt) {

var path = require('path');

// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
Expand Down Expand Up @@ -60,97 +62,77 @@ module.exports = function(grunt) {
copy: {
main: {
files: [
{ expand: true, cwd: './source/js/', src: '*', dest: './public/js/'},
{ expand: true, cwd: './source/css/', src: '*.css', dest: './public/css/' },
{ expand: true, cwd: './source/images/', src: ['*.png', '*.jpg', '*.gif', '*.jpeg'], dest: './public/images/' },
{ expand: true, cwd: './source/images/sample/', src: ['*.png', '*.jpg', '*.gif', '*.jpeg'], dest: './public/images/sample/'},
{ expand: true, cwd: './source/fonts/', src: '*', dest: './public/fonts/'},
{ expand: true, cwd: './source/_data/', src: 'annotations.js', dest: './public/data/' }
{ expand: true, cwd: path.resolve(paths().source.js), src: '*.js', dest: path.resolve(paths().public.js) },
{ expand: true, cwd: path.resolve(paths().source.css), src: '*.css', dest: path.resolve(paths().public.css) },
{ expand: true, cwd: path.resolve(paths().source.images), src: ['**/*.png', '**/*.jpg', '**/*.gif', '**/*.jpeg'], dest: path.resolve(paths().public.images) },
{ expand: true, cwd: path.resolve(paths().source.fonts), src: '*', dest: path.resolve(paths().public.fonts) },
{ expand: true, cwd: path.resolve(paths().source.data), src: 'annotations.js', dest: path.resolve(paths().public.data) }
]
},
css: {
styleguide: {
files: [
{ expand: true, cwd: './source/css/', src: '*.css', dest: './public/css/' }
{ expand: true, cwd: path.resolve(paths().source.styleguide), src: ['*.*', '**/*.*'], dest: path.resolve(paths().public.styleguide) }
]
}
},
watch: {
all: {
files: [
'source/css/**/*.css',
'public/styleguide/css/*.css',
'source/_patterns/**/*.mustache',
'source/_patterns/**/*.json',
'source/_data/*.json'
path.resolve(paths().source.css + '**/*.css'),
path.resolve(paths().source.styleguide + 'css/*.css'),
path.resolve(paths().source.patterns + '**/*.mustache'),
path.resolve(paths().source.patterns + '**/*.json'),
path.resolve(paths().source.fonts + '/*'),
path.resolve(paths().source.images + '/*'),
path.resolve(paths().source.data + '*.json')
],
tasks: ['default']
},
// scss: {
// files: ['source/css/**/*.scss', 'public/styleguide/css/*.scss'],
// tasks: ['sass', 'copy:css','bsReload:css']
// },
patterns: {
files: [
'source/_patterns/**/*.mustache',
'source/_patterns/**/*.json',
'source/_data/*.json'
],
tasks: ['default']
tasks: ['default', 'bsReload:css']
}
},
// sass: {
// build: {
// options: {
// style: 'expanded',
// precision: 8
// },
// files: {
// './source/css/style.css': './source/css/style.scss',
// './public/styleguide/css/static.css': './public/styleguide/css/static.scss',
// './public/styleguide/css/styleguide.css': './public/styleguide/css/styleguide.scss',
// './public/styleguide/css/styleguide-specific.css': './public/styleguide/css/styleguide-specific.scss'
// }
// }
// },
nodeunit: {
all: ['test/*_tests.js']
},
browserSync: {
dev: {
options: {
server: './public',
server: path.resolve(paths().public.root),
watchTask: true,
watchOptions: {
ignoreInitial: true,
ignored: '*.html'
},
plugins: [
{
module: 'bs-html-injector',
options: {
files: './public/index.html'
files: [path.resolve(paths().public.root + '/index.html'), path.resolve(paths().public.styleguide + '/styleguide.html')]
}
}
]
}
}
},
bsReload: {
css: './public/**/*.css'
css: path.resolve(paths().public.root + '**/*.css')
}
});

function paths () {
return require('./config.json').paths;
}

// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

//load the patternlab task
grunt.task.loadTasks('./builder/');

//if you choose to use scss, or any preprocessor, you can add it here
grunt.registerTask('default', ['patternlab', /*'sass',*/ 'copy:main']);
grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']);

//travis CI task
grunt.registerTask('travis', ['nodeunit', 'patternlab']);

//TODO: this line is more efficient, but you cannot run concurrent watch tasks without another dependency.
//grunt.registerTask('serve', ['patternlab', /*'sass',*/ 'copy:main', 'browserSync', 'watch:patterns', 'watch:scss']);
grunt.registerTask('serve', ['patternlab', /*'sass',*/ 'copy:main', 'browserSync', 'watch:all']);
grunt.registerTask('serve', ['patternlab', 'copy:main', 'copy:styleguide', 'browserSync', 'watch:all']);

grunt.registerTask('build', ['nodeunit', 'concat']);

Expand Down
34 changes: 30 additions & 4 deletions README.md
Expand Up @@ -44,7 +44,7 @@ To run patternlab-node using gulp, you need to swap out the default grunt config
3. Run `npm install` from the command line
4. Run `gulp` or `gulp serve` from the command line

This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `grunt serve` to see have BrowserSync spin up and serve the files to you.
This creates all patterns, the styleguide, and the pattern lab site. It's strongly recommended to run `gulp serve` to have BrowserSync spin up and serve the files to you.

### There and Back Again, or Switching Between Grunt and Gulp

Expand Down Expand Up @@ -80,10 +80,36 @@ Get more information about patternlab-node, pattern lab in general, and where to
##### Watching Changes
To have patternlab-node watch for changes to either a mustache template, data, or stylesheets, run `grunt|gulp watch` or `grunt|gulp serve`. The `Gruntfile|Gulpfile` governs what is watched. It should be easy to add scss or whatever preprocessor you fancy.

##### Preprocessor Support
The patternlab-node release package ships with some `.scss` files utilized in the creation of the style guide and sample templates, but these are not required. The compilation tasks are commented out in the `Gruntfiles|Gulpfiles` but can be uncommented or changed to meet your needs. Sass modules are not included in `package.json` files - the prevailing thought being if you are familiar enough with preprocessors, you can use the instructions for [grunt-contrib-sass](https://github.com/gruntjs/grunt-contrib-sass) / [gulp-sass](https://github.com/dlmanning/gulp-sass) / _preprocessor of choice_ to install them. Uncomment the preprocessor configuration to fully utilize the example templates, css and style guide.
##### Configurable Paths
Pattern Lab Node ships with a particular source and public workflow intended to separate the code you work on with the code generated for consumption elsewhere. If you wish to change any paths, you may do so within `config.json`. The contents are here:

**NOTE:** You may run into issues installing gulp-sass if you don't have the latest Visual Studio on Windows. See [here](https://github.com/sass/node-sass/issues/469) for more information and [this query](https://github.com/sass/node-sass/issues?utf8=%E2%9C%93&q=is%3Aissue+install) for a slew of installation problems related to gulp-sass.
```
"paths" : {
"source" : {
"root": "./source/",
"patterns" : "./source/_patterns/",
"data" : "./source/_data/",
"styleguide" : "./core/styleguide/",
"patternlabFiles" : "./source/_patternlab-files/",
"js" : "./source/js",
"images" : "./source/images",
"fonts" : "./source/fonts",
"css" : "./source/css/"
},
"public" : {
"root" : "./public/",
"patterns" : "./public/patterns/",
"data" : "./public/data/",
"styleguide" : "./public/styleguide/",
"js" : "./public/js",
"images" : "./public/images",
"fonts" : "./public/fonts",
"css" : "./public/css"
}
}
```

Note the intentional repitition of the nested structure, made this way for maximum flexibility. Relative paths are default but absolute paths should work too. You may also use these paths within Grunt or Gulp files by referring to the paths() object.

##### Nav Bar Controls
If you don't have a need for some of the nav-bar tools in the Pattern Lab frontend, you can turn them off in `config.json`.
Expand Down
58 changes: 26 additions & 32 deletions builder/lineage_hunter.js
@@ -1,5 +1,5 @@
/*
* patternlab-node - v1.0.0 - 2015
* patternlab-node - v1.1.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand All @@ -23,47 +23,41 @@
if(matches !== null){
matches.forEach(function(match, index, matches){
//strip out the template cruft
var foundPattern = match.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");
var foundPatternKey = match.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");

// remove any potential pattern parameters. this and the above are rather brutish but I didn't want to do a regex at the time
if(foundPattern.indexOf('(') > 0){
foundPattern = foundPattern.substring(0, foundPattern.indexOf('('));
if(foundPatternKey.indexOf('(') > 0){
foundPatternKey = foundPatternKey.substring(0, foundPatternKey.indexOf('('));
}

//add if it doesnt exist
if (pattern.lineageIndex.indexOf(foundPattern) === -1){
//remove any potential stylemodifiers.
foundPatternKey = foundPatternKey.split(':')[0];

pattern.lineageIndex.push(foundPattern);
//get the ancestorPattern
var ancestorPattern = pattern_assembler.get_pattern_by_key(foundPatternKey, patternlab);

patternlab.patterns.forEach(function(ancestorPattern, index, patterns){
if (ancestorPattern && pattern.lineageIndex.indexOf(ancestorPattern.key) === -1){

//find the pattern in question
var searchPattern = ancestorPattern.patternGroup + "-" + ancestorPattern.patternName;
//add it since it didnt exist
pattern.lineageIndex.push(ancestorPattern.key);
//create the more complex patternLineage object too
var l = {
"lineagePattern": ancestorPattern.key,
"lineagePath": "../../patterns/" + ancestorPattern.patternLink
};
pattern.lineage.push(JSON.stringify(l));

if(searchPattern === foundPattern){
//create the more complex patternLineage object too
var l = {
"lineagePattern": foundPattern,
"lineagePath": "../../patterns/" + ancestorPattern.patternLink
//also, add the lineageR entry if it doesn't exist
if (ancestorPattern.lineageRIndex.indexOf(pattern.key) === -1){
ancestorPattern.lineageRIndex.push(pattern.key);

//create the more complex patternLineage object in reverse
var lr = {
"lineagePattern": pattern.key,
"lineagePath": "../../patterns/" + pattern.patternLink
};
pattern.lineage.push(JSON.stringify(l));

//also, add the lineageR entry if it doesn't exist
var patternLabel = pattern.patternGroup + "-" + pattern.patternName;
if (ancestorPattern.lineageRIndex.indexOf(patternLabel) === -1){
ancestorPattern.lineageRIndex.push(patternLabel);

//create the more complex patternLineage object in reverse
var lr = {
"lineagePattern": patternLabel,
"lineagePath": "../../patterns/" + pattern.patternLink
};
ancestorPattern.lineageR.push(JSON.stringify(lr));
}
ancestorPattern.lineageR.push(JSON.stringify(lr));
}

});

}
});
}
Expand Down
14 changes: 10 additions & 4 deletions builder/list_item_hunter.js
@@ -1,5 +1,5 @@
/*
* patternlab-node - v1.0.0 - 2015
* patternlab-node - v1.1.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down Expand Up @@ -72,13 +72,16 @@
var partialName = foundPartials[j].match(/([\w\-\.\/~]+)/g)[0];
var partialPattern = pattern_assembler.get_pattern_by_key(partialName, patternlab);

//create a copy of the partial so as to not pollute it after the get_pattern_by_key call.
var cleanPartialPattern = JSON.parse(JSON.stringify(partialPattern));

//if partial has style modifier data, replace the styleModifier value
if(pattern.stylePartials && pattern.stylePartials.length > 0){
style_modifier_hunter.consume_style_modifier(partialPattern, foundPartials[j], patternlab);
if(foundPartials[j].indexOf(':') > -1){
style_modifier_hunter.consume_style_modifier(cleanPartialPattern, foundPartials[j], patternlab);
}

//replace its reference within the block with the extended template
thisBlockTemplate = thisBlockTemplate.replace(foundPartials[j], partialPattern.extendedTemplate);
thisBlockTemplate = thisBlockTemplate.replace(foundPartials[j], cleanPartialPattern.extendedTemplate);
}

//render with data
Expand All @@ -97,6 +100,9 @@
var repeatingBlock = pattern.extendedTemplate.substring(pattern.extendedTemplate.indexOf(liMatch), pattern.extendedTemplate.indexOf(end) + end.length);
pattern.extendedTemplate = pattern.extendedTemplate.replace(repeatingBlock, repeatedBlockHtml);

//update the extendedTemplate in the partials object in case this pattern is consumed later
patternlab.partials[pattern.key] = pattern.extendedTemplate;

});
}
}
Expand Down
2 changes: 1 addition & 1 deletion builder/media_hunter.js
@@ -1,5 +1,5 @@
/*
* patternlab-node - v1.0.0 - 2015
* patternlab-node - v1.1.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down
2 changes: 1 addition & 1 deletion builder/object_factory.js
@@ -1,5 +1,5 @@
/*
* patternlab-node - v1.0.0 - 2015
* patternlab-node - v1.1.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down
5 changes: 4 additions & 1 deletion builder/parameter_hunter.js
@@ -1,5 +1,5 @@
/*
* patternlab-node - v1.0.0 - 2015
* patternlab-node - v1.1.0 - 2016
*
* Brian Muenzenmeyer, and the web community.
* Licensed under the MIT license.
Expand Down Expand Up @@ -61,6 +61,9 @@

//remove the parameter from the partial and replace it with the rendered partial + paramData
pattern.extendedTemplate = pattern.extendedTemplate.replace(pMatch, renderedPartial);

//update the extendedTemplate in the partials object in case this pattern is consumed later
patternlab.partials[pattern.key] = pattern.extendedTemplate;
});
}
}
Expand Down