diff --git a/Gruntfile.js b/Gruntfile.js index 2dfa9be8a..2f5dc2ad3 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,52 +15,52 @@ module.exports = function (grunt) { banner: '/* \n * <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy") %> \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', }, patternlab: { - src: './builder/patternlab.js', - dest: './builder/patternlab.js' + src: './core/lib/patternlab.js', + dest: './core/lib/patternlab.js' }, object_factory: { - src: './builder/object_factory.js', - dest: './builder/object_factory.js' + src: './core/lib/object_factory.js', + dest: './core/lib/object_factory.js' }, lineage: { - src: './builder/lineage_hunter.js', - dest: './builder/lineage_hunter.js' + src: './core/lib/lineage_hunter.js', + dest: './core/lib/lineage_hunter.js' }, media_hunter: { - src: './builder/media_hunter.js', - dest: './builder/media_hunter.js' + src: './core/lib/media_hunter.js', + dest: './core/lib/media_hunter.js' }, patternlab_grunt: { - src: './builder/patternlab_grunt.js', - dest: './builder/patternlab_grunt.js' + src: './core/lib/patternlab_grunt.js', + dest: './core/lib/patternlab_grunt.js' }, patternlab_gulp: { - src: './builder/patternlab_gulp.js', - dest: './builder/patternlab_gulp.js' + src: './core/lib/patternlab_gulp.js', + dest: './core/lib/patternlab_gulp.js' }, parameter_hunter: { - src: './builder/parameter_hunter.js', - dest: './builder/parameter_hunter.js' + src: './core/lib/parameter_hunter.js', + dest: './core/lib/parameter_hunter.js' }, pattern_exporter: { - src: './builder/pattern_exporter.js', - dest: './builder/pattern_exporter.js' + src: './core/lib/pattern_exporter.js', + dest: './core/lib/pattern_exporter.js' }, pattern_assembler: { - src: './builder/pattern_assembler.js', - dest: './builder/pattern_assembler.js' + src: './core/lib/pattern_assembler.js', + dest: './core/lib/pattern_assembler.js' }, pseudopattern_hunter: { - src: './builder/pseudopattern_hunter.js', - dest: './builder/pseudopattern_hunter.js' + src: './core/lib/pseudopattern_hunter.js', + dest: './core/lib/pseudopattern_hunter.js' }, list_item_hunter: { - src: './builder/list_item_hunter.js', - dest: './builder/list_item_hunter.js' + src: './core/lib/list_item_hunter.js', + dest: './core/lib/list_item_hunter.js' }, style_modifier_hunter: { - src: './builder/style_modifier_hunter.js', - dest: './builder/style_modifier_hunter.js' + src: './core/lib/style_modifier_hunter.js', + dest: './core/lib/style_modifier_hunter.js' } }, copy: { @@ -142,7 +142,7 @@ module.exports = function (grunt) { options: { configFile: './.eslintrc' }, - target: ['./builder/*'] + target: ['./core/lib/*'] }, bsReload: { css: path.resolve(paths().public.root + '**/*.css') @@ -153,7 +153,7 @@ module.exports = function (grunt) { require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks); //load the patternlab task - grunt.task.loadTasks('./builder/'); + grunt.task.loadTasks('./core/lib/'); grunt.registerTask('default', ['patternlab', 'copy:main', 'copy:styleguide']); diff --git a/README.md b/README.md index 156abd8ac..22df180af 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ This repository ships with two `package.json` files, a `Gruntfile.js`, and a `gu To run patternlab-node using grunt, do the following in the directory you downloaded and extracted the zipped release: 1. Run `npm install` from the command line -2. Optionally, delete `package.gulp.json`, `gulpfile.js`, and `builder/patternlab_gulp.js` files if you are certain you don't need it. -* Not deleting `builder/patternlab_gulp.js` may cause a harmless error when running grunt. Delete it. +2. Optionally, delete `package.gulp.json`, `gulpfile.js`, and `core/lib/patternlab_gulp.js` files if you are certain you don't need it. +* Not deleting `core/lib/patternlab_gulp.js` may cause a harmless error when running grunt. Delete it. 3. Run `grunt` or `grunt 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 have BrowserSync spin up and serve the files to you. @@ -164,6 +164,16 @@ Pattern states should be lowercase and use hyphens where spaces are present. Coupled with exported css (much easier to extract with existing tools like [grunt-contrib-copy](https://github.com/gruntjs/grunt-contrib-copy)), pattern export can help to maintain the relevancy of the design system by directly placing partials in a directory of your choosing. +##### cacheBust +`config.json` has this flag to instruct Pattern Lab to append a unique query string to Javascript and CSS assets throughout the frontend. + +``` +"cacheBust": true +``` + +Default: true + + ##### baseurl If your instance of Pattern Lab lives in a subdirectory of your server, for instance on github pages (ex: yourusername.github.io/patterns-demo/), then add the baseurl here. The baseurl is everything after the hostname - ie: `patterns-demo` diff --git a/config.json b/config.json index 187e8955d..4d42d0bc5 100644 --- a/config.json +++ b/config.json @@ -5,7 +5,7 @@ "patterns" : "./source/_patterns/", "data" : "./source/_data/", "styleguide" : "./core/styleguide/", - "patternlabFiles" : "./source/_patternlab-files/", + "patternlabFiles" : "./core/", "js" : "./source/js", "images" : "./source/images", "fonts" : "./source/fonts", @@ -53,5 +53,6 @@ }, "patternExportKeys": [], "patternExportDirectory": "./pattern_exports/", - "baseurl" : "" + "baseurl" : "", + "cacheBust": true } diff --git a/builder/lineage_hunter.js b/core/lib/lineage_hunter.js similarity index 100% rename from builder/lineage_hunter.js rename to core/lib/lineage_hunter.js diff --git a/builder/list_item_hunter.js b/core/lib/list_item_hunter.js similarity index 100% rename from builder/list_item_hunter.js rename to core/lib/list_item_hunter.js diff --git a/builder/media_hunter.js b/core/lib/media_hunter.js similarity index 100% rename from builder/media_hunter.js rename to core/lib/media_hunter.js diff --git a/builder/object_factory.js b/core/lib/object_factory.js similarity index 100% rename from builder/object_factory.js rename to core/lib/object_factory.js diff --git a/builder/parameter_hunter.js b/core/lib/parameter_hunter.js similarity index 100% rename from builder/parameter_hunter.js rename to core/lib/parameter_hunter.js diff --git a/builder/pattern_assembler.js b/core/lib/pattern_assembler.js similarity index 100% rename from builder/pattern_assembler.js rename to core/lib/pattern_assembler.js diff --git a/builder/pattern_exporter.js b/core/lib/pattern_exporter.js similarity index 100% rename from builder/pattern_exporter.js rename to core/lib/pattern_exporter.js diff --git a/builder/patternlab.js b/core/lib/patternlab.js similarity index 81% rename from builder/patternlab.js rename to core/lib/patternlab.js index b4705deaf..1d7dcf62a 100644 --- a/builder/patternlab.js +++ b/core/lib/patternlab.js @@ -22,7 +22,7 @@ var patternlab_engine = function (config) { patternlab = {}; patternlab.package = fs.readJSONSync('./package.json'); - patternlab.config = config || fs.readJSONSync(path.resolve(__dirname, '../config.json')); + patternlab.config = config || fs.readJSONSync(path.resolve(__dirname, '../../config.json')); var paths = patternlab.config.paths; @@ -54,15 +54,29 @@ var patternlab_engine = function (config) { } } + function setCacheBust() { + if (patternlab.config.cacheBust) { + if (patternlab.config.debug) { + console.log('setting cacheBuster value for frontend assets.'); + } + patternlab.cacheBuster = new Date().getTime(); + } else { + patternlab.cacheBuster = 0; + } + } + function buildPatterns(deletePatternDir) { patternlab.data = fs.readJSONSync(path.resolve(paths.source.data, 'data.json')); patternlab.listitems = fs.readJSONSync(path.resolve(paths.source.data, 'listitems.json')); - patternlab.header = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'pattern-header-footer/header.html'), 'utf8'); - patternlab.footer = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'pattern-header-footer/footer.html'), 'utf8'); + patternlab.header = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/pattern-header-footer/header.html'), 'utf8'); + patternlab.footerPattern = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/pattern-header-footer/footer-pattern.html'), 'utf8'); + patternlab.footer = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/pattern-header-footer/footer.html'), 'utf8'); patternlab.patterns = []; patternlab.partials = {}; patternlab.data.link = {}; + setCacheBust(); + var pattern_assembler = new pa(), entity_encoder = new he(), pattern_exporter = new pe(), @@ -116,6 +130,25 @@ var patternlab_engine = function (config) { pattern_assembler.process_pattern_recursive(path.resolve(file), patternlab); }); + //set user defined head and foot if they exist + try { + patternlab.userHead = pattern_assembler.get_pattern_by_key('atoms-head', patternlab); + } + catch(ex) { + if (patternlab.config.debug) { + console.log(ex); + console.log('Could not find optional user-defined header, atoms-head pattern. It was likely deleted.'); + } + } + try { + patternlab.userFoot = pattern_assembler.get_pattern_by_key('atoms-foot', patternlab); + } + catch(ex) { + if (patternlab.config.debug) { + console.log(ex); + console.log('Could not find optional user-defined footer, atoms-foot pattern. It was likely deleted.'); + } + } //now that all the main patterns are known, look for any links that might be within data and expand them //we need to do this before expanding patterns & partials into extendedTemplates, otherwise we could lose the data -> partial reference @@ -126,21 +159,43 @@ var patternlab_engine = function (config) { fs.emptyDirSync(paths.public.patterns); } + //set pattern-specific header if necessary + var head; + if (patternlab.userHead) { + head = patternlab.userHead.extendedTemplate.replace('{% pattern-lab-head %}', patternlab.header); + } else { + head = patternlab.header; + } + //render all patterns last, so lineageR works patternlab.patterns.forEach(function (pattern) { + pattern.header = head; + //render the pattern, but first consolidate any data we may have var allData = JSON.parse(JSON.stringify(patternlab.data)); allData = pattern_assembler.merge_data(allData, pattern.jsonFileData); + //also add the cachebuster value. slight chance this could collide with a user that has defined cacheBuster as a value + allData.cacheBuster = patternlab.cacheBuster; + pattern.cacheBuster = patternlab.cacheBuster; + + //render the pattern-specific header + var headHtml = pattern_assembler.renderPattern(pattern.header, allData); + //render the extendedTemplate with all data pattern.patternPartial = pattern_assembler.renderPattern(pattern.extendedTemplate, allData); - //add footer info before writing - var patternFooter = pattern_assembler.renderPattern(patternlab.footer, pattern); + //set the pattern-specific footer if necessary + if (patternlab.userFoot) { + var userFooter = patternlab.userFoot.extendedTemplate.replace('{% pattern-lab-foot %}', patternlab.footerPattern + patternlab.footer); + pattern.footer = pattern_assembler.renderPattern(userFooter, pattern); + } else { + pattern.footer = pattern_assembler.renderPattern(patternlab.footerPattern, pattern); + } //write the compiled template to the public patterns directory - fs.outputFileSync(paths.public.patterns + pattern.patternLink, patternlab.header + pattern.patternPartial + patternFooter); + fs.outputFileSync(paths.public.patterns + pattern.patternLink, headHtml + pattern.patternPartial + pattern.footer); //write the mustache file too fs.outputFileSync(paths.public.patterns + pattern.patternLink.replace('.html', '.mustache'), entity_encoder.encode(pattern.template)); @@ -211,11 +266,20 @@ var patternlab_engine = function (config) { styleguidePatterns = patternlab.patterns; } + //also add the cachebuster value. slight chance this could collide with a user that has defined cacheBuster as a value + patternlab.data.cacheBuster = patternlab.cacheBuster; + + //get the main page head and foot + var mainPageHead = patternlab.userHead.extendedTemplate.replace('{% pattern-lab-head %}', patternlab.header); + var mainPageHeadHtml = pattern_assembler.renderPattern(mainPageHead, patternlab.data); + var mainPageFoot = patternlab.userFoot.extendedTemplate.replace('{% pattern-lab-foot %}', patternlab.footer); + var mainPageFootHtml = pattern_assembler.renderPattern(mainPageFoot, patternlab.data); + //build the styleguide - var styleguideTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'styleguide.mustache'), 'utf8'), - styleguideHtml = pattern_assembler.renderPattern(styleguideTemplate, {partials: styleguidePatterns}); + var styleguideTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/styleguide.mustache'), 'utf8'), + styleguideHtml = pattern_assembler.renderPattern(styleguideTemplate, {partials: styleguidePatterns, cacheBuster: patternlab.cacheBuster}); - fs.outputFileSync(path.resolve(paths.public.styleguide, 'html/styleguide.html'), styleguideHtml); + fs.outputFileSync(path.resolve(paths.public.styleguide, 'html/styleguide.html'), mainPageHeadHtml + styleguideHtml + mainPageFootHtml); //build the viewall pages var prevSubdir = '', @@ -255,9 +319,9 @@ var patternlab_engine = function (config) { } } - var viewAllTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'viewall.mustache'), 'utf8'); - var viewAllHtml = pattern_assembler.renderPattern(viewAllTemplate, {partials: viewAllPatterns, patternPartial: patternPartial}); - fs.outputFileSync(paths.public.patterns + pattern.subdir.slice(0, pattern.subdir.indexOf(pattern.patternGroup) + pattern.patternGroup.length) + '/index.html', viewAllHtml); + var viewAllTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/viewall.mustache'), 'utf8'); + var viewAllHtml = pattern_assembler.renderPattern(viewAllTemplate, {partials: viewAllPatterns, patternPartial: patternPartial, cacheBuster: patternlab.cacheBuster }); + fs.outputFileSync(paths.public.patterns + pattern.subdir.slice(0, pattern.subdir.indexOf(pattern.patternGroup) + pattern.patternGroup.length) + '/index.html', mainPageHead + viewAllHtml + mainPageFoot); } // create the view all for the subsection @@ -282,14 +346,14 @@ var patternlab_engine = function (config) { } } - var viewAllTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'viewall.mustache'), 'utf8'); - var viewAllHtml = pattern_assembler.renderPattern(viewAllTemplate, {partials: viewAllPatterns, patternPartial: patternPartial}); - fs.outputFileSync(paths.public.patterns + pattern.flatPatternPath + '/index.html', viewAllHtml); + var viewAllTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/viewall.mustache'), 'utf8'); + var viewAllHtml = pattern_assembler.renderPattern(viewAllTemplate, {partials: viewAllPatterns, patternPartial: patternPartial, cacheBuster: patternlab.cacheBuster}); + fs.outputFileSync(paths.public.patterns + pattern.flatPatternPath + '/index.html', mainPageHeadHtml + viewAllHtml + mainPageFootHtml); } } //build the patternlab website - var patternlabSiteTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'index.mustache'), 'utf8'); + var patternlabSiteTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/index.mustache'), 'utf8'); //loop through all patterns.to build the navigation //todo: refactor this someday @@ -462,24 +526,24 @@ var patternlab_engine = function (config) { //the patternlab site requires a lot of partials to be rendered. //patternNav - var patternNavTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'partials/patternNav.mustache'), 'utf8'); + var patternNavTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/partials/patternNav.mustache'), 'utf8'); var patternNavPartialHtml = pattern_assembler.renderPattern(patternNavTemplate, patternlab); //ishControls - var ishControlsTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'partials/ishControls.mustache'), 'utf8'); + var ishControlsTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/partials/ishControls.mustache'), 'utf8'); patternlab.config.mqs = patternlab.mediaQueries; var ishControlsPartialHtml = pattern_assembler.renderPattern(ishControlsTemplate, patternlab.config); //patternPaths - var patternPathsTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'partials/patternPaths.mustache'), 'utf8'); + var patternPathsTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/partials/patternPaths.mustache'), 'utf8'); var patternPathsPartialHtml = pattern_assembler.renderPattern(patternPathsTemplate, {'patternPaths': JSON.stringify(patternlab.patternPaths)}); //viewAllPaths - var viewAllPathsTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'partials/viewAllPaths.mustache'), 'utf8'); + var viewAllPathsTemplate = fs.readFileSync(path.resolve(paths.source.patternlabFiles, 'templates/partials/viewAllPaths.mustache'), 'utf8'); var viewAllPathsPartialHtml = pattern_assembler.renderPattern(viewAllPathsTemplate, {'viewallpaths': JSON.stringify(patternlab.viewAllPaths)}); //render the patternlab template, with all partials - var patternlabSiteHtml = pattern_assembler.renderPattern(patternlabSiteTemplate, {}, { + var patternlabSiteHtml = pattern_assembler.renderPattern(patternlabSiteTemplate, {cacheBuster: patternlab.cacheBuster}, { 'ishControls': ishControlsPartialHtml, 'patternNav': patternNavPartialHtml, 'patternPaths': patternPathsPartialHtml, diff --git a/builder/patternlab_grunt.js b/core/lib/patternlab_grunt.js similarity index 100% rename from builder/patternlab_grunt.js rename to core/lib/patternlab_grunt.js diff --git a/builder/patternlab_gulp.js b/core/lib/patternlab_gulp.js similarity index 100% rename from builder/patternlab_gulp.js rename to core/lib/patternlab_gulp.js diff --git a/builder/pseudopattern_hunter.js b/core/lib/pseudopattern_hunter.js similarity index 100% rename from builder/pseudopattern_hunter.js rename to core/lib/pseudopattern_hunter.js diff --git a/builder/style_modifier_hunter.js b/core/lib/style_modifier_hunter.js similarity index 100% rename from builder/style_modifier_hunter.js rename to core/lib/style_modifier_hunter.js diff --git a/source/_patternlab-files/README b/core/templates/README.txt similarity index 100% rename from source/_patternlab-files/README rename to core/templates/README.txt diff --git a/source/_patternlab-files/index.mustache b/core/templates/index.mustache similarity index 69% rename from source/_patternlab-files/index.mustache rename to core/templates/index.mustache index 1688121dd..e3c1be462 100644 --- a/source/_patternlab-files/index.mustache +++ b/core/templates/index.mustache @@ -3,11 +3,19 @@ Pattern Lab + + + + + + + + - - - - + + + + @@ -21,7 +29,7 @@ - +
@@ -78,17 +86,17 @@
- - - - + + + + {{> patternPaths }} {{> viewAllPaths }} - - - - - + + + + + - \ No newline at end of file + diff --git a/source/_patternlab-files/partials/ishControls.mustache b/core/templates/partials/ishControls.mustache similarity index 100% rename from source/_patternlab-files/partials/ishControls.mustache rename to core/templates/partials/ishControls.mustache diff --git a/source/_patternlab-files/partials/patternNav.mustache b/core/templates/partials/patternNav.mustache similarity index 100% rename from source/_patternlab-files/partials/patternNav.mustache rename to core/templates/partials/patternNav.mustache diff --git a/source/_patternlab-files/partials/patternPaths.mustache b/core/templates/partials/patternPaths.mustache similarity index 100% rename from source/_patternlab-files/partials/patternPaths.mustache rename to core/templates/partials/patternPaths.mustache diff --git a/source/_patternlab-files/partials/viewAllPaths.mustache b/core/templates/partials/viewAllPaths.mustache similarity index 100% rename from source/_patternlab-files/partials/viewAllPaths.mustache rename to core/templates/partials/viewAllPaths.mustache diff --git a/source/_patternlab-files/pattern-header-footer/README b/core/templates/pattern-header-footer/README.txt similarity index 100% rename from source/_patternlab-files/pattern-header-footer/README rename to core/templates/pattern-header-footer/README.txt diff --git a/core/templates/pattern-header-footer/footer-pattern.html b/core/templates/pattern-header-footer/footer-pattern.html new file mode 100644 index 000000000..20caf0102 --- /dev/null +++ b/core/templates/pattern-header-footer/footer-pattern.html @@ -0,0 +1,19 @@ + + + + + + + diff --git a/core/templates/pattern-header-footer/footer.html b/core/templates/pattern-header-footer/footer.html new file mode 100644 index 000000000..b865c85ab --- /dev/null +++ b/core/templates/pattern-header-footer/footer.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/core/templates/pattern-header-footer/header.html b/core/templates/pattern-header-footer/header.html new file mode 100644 index 000000000..ebe81993e --- /dev/null +++ b/core/templates/pattern-header-footer/header.html @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/source/_patternlab-files/styleguide.mustache b/core/templates/styleguide.mustache similarity index 64% rename from source/_patternlab-files/styleguide.mustache rename to core/templates/styleguide.mustache index fe39a3816..b9a63debe 100644 --- a/source/_patternlab-files/styleguide.mustache +++ b/core/templates/styleguide.mustache @@ -1,15 +1,3 @@ - - - - Pattern Lab Style Guide - - - - - - - -
@@ -58,11 +46,3 @@ var lineage = ""; var baseurl = "{{{baseurl}}}"; - - - - - - - - diff --git a/source/_patternlab-files/viewall.mustache b/core/templates/viewall.mustache similarity index 68% rename from source/_patternlab-files/viewall.mustache rename to core/templates/viewall.mustache index 87b345ae2..e22a33833 100644 --- a/source/_patternlab-files/viewall.mustache +++ b/core/templates/viewall.mustache @@ -1,14 +1,3 @@ - - - - Pattern Lab Sub-type Style Guide - - - - - - -
@@ -58,11 +47,3 @@ var lineage = ""; var baseurl = "{{{baseurl}}}"; - - - - - - - - diff --git a/gulpfile.js b/gulpfile.js index a00019f2d..85e157f15 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -27,7 +27,7 @@ function paths() { } //load patternlab-node tasks -gulp.loadTasks(__dirname + '/builder/patternlab_gulp.js'); +gulp.loadTasks(__dirname + '/core/lib/patternlab_gulp.js'); //clean patterns dir gulp.task('clean', function (cb) { @@ -38,25 +38,25 @@ gulp.task('clean', function (cb) { //build the banner gulp.task('banner', function () { return gulp.src([ - './builder/patternlab.js', - './builder/object_factory.js', - './builder/lineage_hunter.js', - './builder/media_hunter.js', - './builder/patternlab_grunt.js', - './builder/patternlab_gulp.js', - './builder/parameter_hunter.js', - './builder/pattern_exporter.js', - './builder/pattern_assembler.js', - './builder/pseudopattern_hunter.js', - './builder/list_item_hunter.js', - './builder/style_modifier_hunter.js' + './core/lib/patternlab.js', + './core/lib/object_factory.js', + './core/lib/lineage_hunter.js', + './core/lib/media_hunter.js', + './core/lib/patternlab_grunt.js', + './core/lib/patternlab_gulp.js', + './core/lib/parameter_hunter.js', + './core/lib/pattern_exporter.js', + './core/lib/pattern_assembler.js', + './core/lib/pseudopattern_hunter.js', + './core/lib/list_item_hunter.js', + './core/lib/style_modifier_hunter.js' ]) .pipe(strip_banner()) .pipe(header(banner, { pkg : pkg, today : new Date().getFullYear() } )) - .pipe(gulp.dest('./builder')); + .pipe(gulp.dest('./core/lib')); }); @@ -154,7 +154,7 @@ gulp.task('connect', ['lab'], function () { //lint gulp.task('eslint', function () { - return gulp.src(['./builder/*.js', '!node_modules/**']) + return gulp.src(['./core/lib/*.js', '!node_modules/**']) .pipe(eslint()) .pipe(eslint.format()) .pipe(eslint.failAfterError()); diff --git a/package.gulp.json b/package.gulp.json index 87a4d0044..3bb48a781 100644 --- a/package.gulp.json +++ b/package.gulp.json @@ -2,7 +2,7 @@ "name": "patternlab-node", "description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).", "version": "1.1.3", - "main": "./builder/patternlab.js", + "main": "./core/lib/patternlab.js", "dependencies": { "del": "^2.2.0", "diveSync": "^0.3.0", diff --git a/package.json b/package.json index a62664b52..68c810687 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "patternlab-node", "description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).", "version": "1.1.3", - "main": "./builder/patternlab.js", + "main": "./core/lib/patternlab.js", "dependencies": { "diveSync": "^0.3.0", "fs-extra": "^0.26.2", diff --git a/source/_patternlab-files/pattern-header-footer/footer.html b/source/_patternlab-files/pattern-header-footer/footer.html deleted file mode 100644 index 2234cfd9f..000000000 --- a/source/_patternlab-files/pattern-header-footer/footer.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/_patternlab-files/pattern-header-footer/header.html b/source/_patternlab-files/pattern-header-footer/header.html deleted file mode 100644 index 1d0019a03..000000000 --- a/source/_patternlab-files/pattern-header-footer/header.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - Pattern Lab Pattern - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/source/_patterns/00-atoms/00-meta/_00-head.mustache b/source/_patterns/00-atoms/00-meta/_00-head.mustache new file mode 100644 index 000000000..a751d06a2 --- /dev/null +++ b/source/_patterns/00-atoms/00-meta/_00-head.mustache @@ -0,0 +1,15 @@ + + + + {{ title }} + + + + + + + {% pattern-lab-head %} + + + + diff --git a/source/_patterns/00-atoms/00-meta/_01-foot.mustache b/source/_patterns/00-atoms/00-meta/_01-foot.mustache new file mode 100644 index 000000000..10e69fba6 --- /dev/null +++ b/source/_patterns/00-atoms/00-meta/_01-foot.mustache @@ -0,0 +1,7 @@ + + +{% pattern-lab-foot %} + + + + diff --git a/source/_patterns/00-atoms/00-global/00-colors.mustache b/source/_patterns/00-atoms/01-global/00-colors.mustache similarity index 100% rename from source/_patterns/00-atoms/00-global/00-colors.mustache rename to source/_patterns/00-atoms/01-global/00-colors.mustache diff --git a/source/_patterns/00-atoms/00-global/01-fonts.mustache b/source/_patterns/00-atoms/01-global/01-fonts.mustache similarity index 100% rename from source/_patterns/00-atoms/00-global/01-fonts.mustache rename to source/_patterns/00-atoms/01-global/01-fonts.mustache diff --git a/source/_patterns/00-atoms/00-global/02-animations.mustache b/source/_patterns/00-atoms/01-global/02-animations.mustache similarity index 100% rename from source/_patterns/00-atoms/00-global/02-animations.mustache rename to source/_patterns/00-atoms/01-global/02-animations.mustache diff --git a/source/_patterns/00-atoms/00-global/03-visibility.mustache b/source/_patterns/00-atoms/01-global/03-visibility.mustache similarity index 100% rename from source/_patterns/00-atoms/00-global/03-visibility.mustache rename to source/_patterns/00-atoms/01-global/03-visibility.mustache diff --git a/source/_patterns/00-atoms/01-text/00-headings.mustache b/source/_patterns/00-atoms/02-text/00-headings.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/00-headings.mustache rename to source/_patterns/00-atoms/02-text/00-headings.mustache diff --git a/source/_patterns/00-atoms/01-text/01-subheadings.mustache b/source/_patterns/00-atoms/02-text/01-subheadings.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/01-subheadings.mustache rename to source/_patterns/00-atoms/02-text/01-subheadings.mustache diff --git a/source/_patterns/00-atoms/01-text/02-headings-with-links.mustache b/source/_patterns/00-atoms/02-text/02-headings-with-links.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/02-headings-with-links.mustache rename to source/_patterns/00-atoms/02-text/02-headings-with-links.mustache diff --git a/source/_patterns/00-atoms/01-text/03-paragraph.mustache b/source/_patterns/00-atoms/02-text/03-paragraph.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/03-paragraph.mustache rename to source/_patterns/00-atoms/02-text/03-paragraph.mustache diff --git a/source/_patterns/00-atoms/01-text/04-blockquote.mustache b/source/_patterns/00-atoms/02-text/04-blockquote.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/04-blockquote.mustache rename to source/_patterns/00-atoms/02-text/04-blockquote.mustache diff --git a/source/_patterns/00-atoms/01-text/05-inline-elements.mustache b/source/_patterns/00-atoms/02-text/05-inline-elements.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/05-inline-elements.mustache rename to source/_patterns/00-atoms/02-text/05-inline-elements.mustache diff --git a/source/_patterns/00-atoms/01-text/06-time.mustache b/source/_patterns/00-atoms/02-text/06-time.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/06-time.mustache rename to source/_patterns/00-atoms/02-text/06-time.mustache diff --git a/source/_patterns/00-atoms/01-text/07-preformatted-text.mustache b/source/_patterns/00-atoms/02-text/07-preformatted-text.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/07-preformatted-text.mustache rename to source/_patterns/00-atoms/02-text/07-preformatted-text.mustache diff --git a/source/_patterns/00-atoms/01-text/08-emphasis-colors.mustache b/source/_patterns/00-atoms/02-text/08-emphasis-colors.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/08-emphasis-colors.mustache rename to source/_patterns/00-atoms/02-text/08-emphasis-colors.mustache diff --git a/source/_patterns/00-atoms/01-text/09-hr.mustache b/source/_patterns/00-atoms/02-text/09-hr.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/09-hr.mustache rename to source/_patterns/00-atoms/02-text/09-hr.mustache diff --git a/source/_patterns/00-atoms/01-text/10-caption.mustache b/source/_patterns/00-atoms/02-text/10-caption.mustache similarity index 100% rename from source/_patterns/00-atoms/01-text/10-caption.mustache rename to source/_patterns/00-atoms/02-text/10-caption.mustache diff --git a/source/_patterns/00-atoms/02-lists/00-unordered.mustache b/source/_patterns/00-atoms/03-lists/00-unordered.mustache similarity index 100% rename from source/_patterns/00-atoms/02-lists/00-unordered.mustache rename to source/_patterns/00-atoms/03-lists/00-unordered.mustache diff --git a/source/_patterns/00-atoms/02-lists/01-ordered.mustache b/source/_patterns/00-atoms/03-lists/01-ordered.mustache similarity index 100% rename from source/_patterns/00-atoms/02-lists/01-ordered.mustache rename to source/_patterns/00-atoms/03-lists/01-ordered.mustache diff --git a/source/_patterns/00-atoms/02-lists/02-definition.mustache b/source/_patterns/00-atoms/03-lists/02-definition.mustache similarity index 100% rename from source/_patterns/00-atoms/02-lists/02-definition.mustache rename to source/_patterns/00-atoms/03-lists/02-definition.mustache diff --git a/source/_patterns/00-atoms/03-images/00-logo.mustache b/source/_patterns/00-atoms/04-images/00-logo.mustache similarity index 100% rename from source/_patterns/00-atoms/03-images/00-logo.mustache rename to source/_patterns/00-atoms/04-images/00-logo.mustache diff --git a/source/_patterns/00-atoms/03-images/01-landscape-4x3.mustache b/source/_patterns/00-atoms/04-images/01-landscape-4x3.mustache similarity index 100% rename from source/_patterns/00-atoms/03-images/01-landscape-4x3.mustache rename to source/_patterns/00-atoms/04-images/01-landscape-4x3.mustache diff --git a/source/_patterns/00-atoms/03-images/02-landscape-16x9.mustache b/source/_patterns/00-atoms/04-images/02-landscape-16x9.mustache similarity index 100% rename from source/_patterns/00-atoms/03-images/02-landscape-16x9.mustache rename to source/_patterns/00-atoms/04-images/02-landscape-16x9.mustache diff --git a/source/_patterns/00-atoms/03-images/03-square.mustache b/source/_patterns/00-atoms/04-images/03-square.mustache similarity index 100% rename from source/_patterns/00-atoms/03-images/03-square.mustache rename to source/_patterns/00-atoms/04-images/03-square.mustache diff --git a/source/_patterns/00-atoms/03-images/04-avatar.mustache b/source/_patterns/00-atoms/04-images/04-avatar.mustache similarity index 100% rename from source/_patterns/00-atoms/03-images/04-avatar.mustache rename to source/_patterns/00-atoms/04-images/04-avatar.mustache diff --git a/source/_patterns/00-atoms/03-images/05-icons.mustache b/source/_patterns/00-atoms/04-images/05-icons.mustache similarity index 100% rename from source/_patterns/00-atoms/03-images/05-icons.mustache rename to source/_patterns/00-atoms/04-images/05-icons.mustache diff --git a/source/_patterns/00-atoms/03-images/06-loading-icon.mustache b/source/_patterns/00-atoms/04-images/06-loading-icon.mustache similarity index 100% rename from source/_patterns/00-atoms/03-images/06-loading-icon.mustache rename to source/_patterns/00-atoms/04-images/06-loading-icon.mustache diff --git a/source/_patterns/00-atoms/03-images/07-favicon.mustache b/source/_patterns/00-atoms/04-images/07-favicon.mustache similarity index 100% rename from source/_patterns/00-atoms/03-images/07-favicon.mustache rename to source/_patterns/00-atoms/04-images/07-favicon.mustache diff --git a/source/_patterns/00-atoms/04-forms/00-text-fields.mustache b/source/_patterns/00-atoms/05-forms/00-text-fields.mustache similarity index 100% rename from source/_patterns/00-atoms/04-forms/00-text-fields.mustache rename to source/_patterns/00-atoms/05-forms/00-text-fields.mustache diff --git a/source/_patterns/00-atoms/04-forms/01-select-menu.mustache b/source/_patterns/00-atoms/05-forms/01-select-menu.mustache similarity index 100% rename from source/_patterns/00-atoms/04-forms/01-select-menu.mustache rename to source/_patterns/00-atoms/05-forms/01-select-menu.mustache diff --git a/source/_patterns/00-atoms/04-forms/02-checkbox.mustache b/source/_patterns/00-atoms/05-forms/02-checkbox.mustache similarity index 100% rename from source/_patterns/00-atoms/04-forms/02-checkbox.mustache rename to source/_patterns/00-atoms/05-forms/02-checkbox.mustache diff --git a/source/_patterns/00-atoms/04-forms/03-radio-buttons.mustache b/source/_patterns/00-atoms/05-forms/03-radio-buttons.mustache similarity index 100% rename from source/_patterns/00-atoms/04-forms/03-radio-buttons.mustache rename to source/_patterns/00-atoms/05-forms/03-radio-buttons.mustache diff --git a/source/_patterns/00-atoms/04-forms/04-html5-inputs.mustache b/source/_patterns/00-atoms/05-forms/04-html5-inputs.mustache similarity index 100% rename from source/_patterns/00-atoms/04-forms/04-html5-inputs.mustache rename to source/_patterns/00-atoms/05-forms/04-html5-inputs.mustache diff --git a/source/_patterns/00-atoms/05-buttons/00-buttons.mustache b/source/_patterns/00-atoms/06-buttons/00-buttons.mustache similarity index 100% rename from source/_patterns/00-atoms/05-buttons/00-buttons.mustache rename to source/_patterns/00-atoms/06-buttons/00-buttons.mustache diff --git a/source/_patterns/00-atoms/06-tables/00-table.mustache b/source/_patterns/00-atoms/07-tables/00-table.mustache similarity index 100% rename from source/_patterns/00-atoms/06-tables/00-table.mustache rename to source/_patterns/00-atoms/07-tables/00-table.mustache diff --git a/source/_patterns/00-atoms/07-media/00-video.mustache b/source/_patterns/00-atoms/08-media/00-video.mustache similarity index 100% rename from source/_patterns/00-atoms/07-media/00-video.mustache rename to source/_patterns/00-atoms/08-media/00-video.mustache diff --git a/source/_patterns/00-atoms/07-media/01-audio.mustache b/source/_patterns/00-atoms/08-media/01-audio.mustache similarity index 100% rename from source/_patterns/00-atoms/07-media/01-audio.mustache rename to source/_patterns/00-atoms/08-media/01-audio.mustache diff --git a/test/lineage_hunter_tests.js b/test/lineage_hunter_tests.js index 0cd6a4aea..490c704ec 100644 --- a/test/lineage_hunter_tests.js +++ b/test/lineage_hunter_tests.js @@ -1,7 +1,7 @@ (function () { "use strict"; - var lh = require('../builder/lineage_hunter'); + var lh = require('../core/lib/lineage_hunter'); exports['lineage hunter '] = { 'find_lineage - finds lineage' : function(test){ diff --git a/test/list_item_hunter_tests.js b/test/list_item_hunter_tests.js index b2895b24d..eb3ade6cf 100644 --- a/test/list_item_hunter_tests.js +++ b/test/list_item_hunter_tests.js @@ -1,9 +1,9 @@ (function () { "use strict"; - var lih = require('../builder/list_item_hunter'); - var pa = require('../builder/pattern_assembler'); - var object_factory = require('../builder/object_factory'); + var lih = require('../core/lib/list_item_hunter'); + var pa = require('../core/lib/pattern_assembler'); + var object_factory = require('../core/lib/object_factory'); exports['list_item_hunter'] = { 'process_list_item_partials finds and outputs basic repeating blocks' : function(test){ diff --git a/test/media_hunter_tests.js b/test/media_hunter_tests.js index e41db5f88..05ce5926b 100644 --- a/test/media_hunter_tests.js +++ b/test/media_hunter_tests.js @@ -1,7 +1,7 @@ (function () { "use strict"; - var MediaHunter = require('../builder/media_hunter'); + var MediaHunter = require('../core/lib/media_hunter'); exports['media_query hunter basic support '] = { 'test media hunter finds query' : function(test){ diff --git a/test/object_factory_tests.js b/test/object_factory_tests.js index f58b2e664..c3e736690 100644 --- a/test/object_factory_tests.js +++ b/test/object_factory_tests.js @@ -1,7 +1,7 @@ (function () { "use strict"; - var of = require('../builder/object_factory'); + var of = require('../core/lib/object_factory'); exports['oPattern initialization'] = { 'test oPattern initializes correctly' : function(test){ diff --git a/test/parameter_hunter_tests.js b/test/parameter_hunter_tests.js index 3672a4a79..96d345792 100644 --- a/test/parameter_hunter_tests.js +++ b/test/parameter_hunter_tests.js @@ -1,7 +1,7 @@ (function () { "use strict"; - var ph = require('../builder/parameter_hunter'); + var ph = require('../core/lib/parameter_hunter'); //setup current pattern from what we would have during execution function currentPatternClosure() { diff --git a/test/pattern_assembler_tests.js b/test/pattern_assembler_tests.js index 5ba989a11..cca671f9d 100644 --- a/test/pattern_assembler_tests.js +++ b/test/pattern_assembler_tests.js @@ -1,8 +1,8 @@ (function () { "use strict"; - var pa = require('../builder/pattern_assembler'); - var object_factory = require('../builder/object_factory'); + var pa = require('../core/lib/pattern_assembler'); + var object_factory = require('../core/lib/object_factory'); var path = require('path'); exports['pattern_assembler'] = { @@ -193,7 +193,7 @@ //prepare to diveSync var diveSync = require('diveSync'); var fs = require('fs-extra'); - var pa = require('../builder/pattern_assembler'); + var pa = require('../core/lib/pattern_assembler'); var pattern_assembler = new pa(); var patterns_dir = './test/files/_patterns'; var patternlab = {}; @@ -202,8 +202,8 @@ patternlab.data = fs.readJSONSync(path.resolve(patternlab.config.paths.source.data, 'data.json')); patternlab.listitems = fs.readJSONSync(path.resolve(patternlab.config.paths.source.data, 'listitems.json')); - patternlab.header = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'pattern-header-footer/header.html'), 'utf8'); - patternlab.footer = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'pattern-header-footer/footer.html'), 'utf8'); + patternlab.header = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'templates/pattern-header-footer/header.html'), 'utf8'); + patternlab.footer = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'templates/pattern-header-footer/footer.html'), 'utf8'); patternlab.patterns = []; patternlab.data.link = {}; patternlab.partials = {}; @@ -520,7 +520,7 @@ //arrange var diveSync = require('diveSync'); var fs = require('fs-extra'); - var pa = require('../builder/pattern_assembler'); + var pa = require('../core/lib/pattern_assembler'); var pattern_assembler = new pa(); var patterns_dir = './test/files/_patterns'; var patternlab = {}; @@ -530,8 +530,8 @@ patternlab.data = fs.readJSONSync(path.resolve(patternlab.config.paths.source.data, 'data.json')); patternlab.listitems = fs.readJSONSync(path.resolve(patternlab.config.paths.source.data, 'listitems.json')); - patternlab.header = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'pattern-header-footer/header.html'), 'utf8'); - patternlab.footer = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'pattern-header-footer/footer.html'), 'utf8'); + patternlab.header = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'templates/pattern-header-footer/header.html'), 'utf8'); + patternlab.footer = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'templates/pattern-header-footer/footer.html'), 'utf8'); patternlab.patterns = []; patternlab.data.link = {}; patternlab.partials = {}; @@ -571,7 +571,7 @@ }, 'setState - applies any patternState matching the pattern' : function(test){ //arrange - var pa = require('../builder/pattern_assembler'); + var pa = require('../core/lib/pattern_assembler'); var pattern_assembler = new pa(); var patternlab = {}; patternlab.config = {}; @@ -591,7 +591,7 @@ }, 'setState - does not apply any patternState if nothing matches the pattern' : function(test){ //arrange - var pa = require('../builder/pattern_assembler'); + var pa = require('../core/lib/pattern_assembler'); var pattern_assembler = new pa(); var patternlab = {}; patternlab.config = {}; @@ -613,7 +613,7 @@ //arrange var diveSync = require('diveSync'); var fs = require('fs-extra'); - var pa = require('../builder/pattern_assembler'); + var pa = require('../core/lib/pattern_assembler'); var pattern_assembler = new pa(); var patterns_dir = './test/files/_patterns/'; var patternlab = {}; @@ -622,8 +622,8 @@ patternlab.config.paths.source.patterns = patterns_dir; patternlab.data = fs.readJSONSync(path.resolve(patternlab.config.paths.source.data, 'data.json')); patternlab.listitems = fs.readJSONSync(path.resolve(patternlab.config.paths.source.data, 'listitems.json')); - patternlab.header = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'pattern-header-footer/header.html'), 'utf8'); - patternlab.footer = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'pattern-header-footer/footer.html'), 'utf8'); + patternlab.header = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'templates/pattern-header-footer/header.html'), 'utf8'); + patternlab.footer = fs.readFileSync(path.resolve(patternlab.config.paths.source.patternlabFiles, 'templates/pattern-header-footer/footer.html'), 'utf8'); patternlab.patterns = []; patternlab.data.link = {}; patternlab.partials = {}; diff --git a/test/pseudopattern_hunter_tests.js b/test/pseudopattern_hunter_tests.js index 9a0269482..3a97b773f 100644 --- a/test/pseudopattern_hunter_tests.js +++ b/test/pseudopattern_hunter_tests.js @@ -1,9 +1,9 @@ (function () { "use strict"; - var pha = require('../builder/pseudopattern_hunter'); - var pa = require('../builder/pattern_assembler'); - var object_factory = require('../builder/object_factory'); + var pha = require('../core/lib/pseudopattern_hunter'); + var pa = require('../core/lib/pattern_assembler'); + var object_factory = require('../core/lib/object_factory'); exports['pseudopattern_hunter'] = { 'pseudpattern found and added as a pattern' : function(test){ diff --git a/test/style_modifier_hunter_tests.js b/test/style_modifier_hunter_tests.js index 9a13a75e4..7a3562ad0 100644 --- a/test/style_modifier_hunter_tests.js +++ b/test/style_modifier_hunter_tests.js @@ -1,7 +1,7 @@ (function () { "use strict"; - var smh = require('../builder/style_modifier_hunter'); + var smh = require('../core/lib/style_modifier_hunter'); exports['consume_style_modifier'] = { 'uses the partial stylemodifer to modify the patterns extendedTemplate' : function(test){