From 4e0ad4daba44242cc833788984304be5f445348b Mon Sep 17 00:00:00 2001 From: Geoffrey Pursell Date: Fri, 26 Feb 2016 11:22:34 -0600 Subject: [PATCH 1/2] Support for configuring a default pattern in config.json --- builder/patternlab.js | 6 +++++- config.json | 1 + core/styleguide/js/styleguide.js | 10 ++++++---- source/_patternlab-files/index.mustache | 5 +++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/builder/patternlab.js b/builder/patternlab.js index aae791f23..9b99f3553 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -473,7 +473,11 @@ var patternlab_engine = function (config) { var viewAllPathsPartialHtml = pattern_assembler.renderPattern(viewAllPathsTemplate, {'viewallpaths': JSON.stringify(patternlab.viewAllPaths)}); //render the patternlab template, with all partials - var patternlabSiteHtml = pattern_assembler.renderPattern(patternlabSiteTemplate, {}, { + debugger; + + var patternlabSiteHtml = pattern_assembler.renderPattern(patternlabSiteTemplate, { + defaultPattern: patternlab.config.defaultPattern || 'all' + }, { 'ishControls': ishControlsPartialHtml, 'patternNav': patternNavPartialHtml, 'patternPaths': patternPathsPartialHtml, diff --git a/config.json b/config.json index 0ca6ef1f0..204bdd651 100644 --- a/config.json +++ b/config.json @@ -26,6 +26,7 @@ "templates", "pages" ], + "defaultPattern": "all", "ignored-extensions" : ["scss", "DS_Store", "less"], "ignored-directories" : ["scss"], "debug": false, diff --git a/core/styleguide/js/styleguide.js b/core/styleguide/js/styleguide.js index 44adb6561..ce83f10d5 100644 --- a/core/styleguide/js/styleguide.js +++ b/core/styleguide/js/styleguide.js @@ -469,16 +469,18 @@ } // load the iframe source - var patternName = "all"; + var patternName = window.defaultPattern || "all"; var patternPath = ""; - var iFramePath = window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html","")+"styleguide/html/styleguide.html"; + var iFramePath = window.location.protocol + "//" + window.location.host + window.location.pathname.replace("index.html","") + "styleguide/html/styleguide.html"; + + // if we were passed some url parameters, deal with it if ((oGetVars.p != undefined) || (oGetVars.pattern != undefined)) { patternName = (oGetVars.p != undefined) ? oGetVars.p : oGetVars.pattern; - patternPath = urlHandler.getFileName(patternName); - iFramePath = (patternPath != "") ? window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html","")+patternPath : iFramePath; } if (patternName != "all") { + patternPath = urlHandler.getFileName(patternName); + iFramePath = (patternPath != "") ? window.location.protocol + "//" + window.location.host + window.location.pathname.replace("index.html","") + patternPath : iFramePath; document.getElementById("title").innerHTML = "Pattern Lab - "+patternName; history.replaceState({ "pattern": patternName }, null, null); } diff --git a/source/_patternlab-files/index.mustache b/source/_patternlab-files/index.mustache index 1688121dd..d98ce37d5 100644 --- a/source/_patternlab-files/index.mustache +++ b/source/_patternlab-files/index.mustache @@ -10,6 +10,7 @@ + > @@ -21,7 +22,7 @@ - +
@@ -91,4 +92,4 @@ - \ No newline at end of file + From b746ff8b35c5b0c8a3fdc8bf8d5118916a942de5 Mon Sep 17 00:00:00 2001 From: Geoffrey Pursell Date: Mon, 29 Feb 2016 09:50:08 -0600 Subject: [PATCH 2/2] oops, debugger statement --- builder/patternlab.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/builder/patternlab.js b/builder/patternlab.js index 9b99f3553..1cdd75a9a 100644 --- a/builder/patternlab.js +++ b/builder/patternlab.js @@ -1,10 +1,10 @@ -/* - * patternlab-node - v1.1.3 - 2016 - * +/* + * patternlab-node - v1.1.3 - 2016 + * * Brian Muenzenmeyer, and the web community. - * Licensed under the MIT license. - * - * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. + * Licensed under the MIT license. + * + * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice. * */ @@ -473,8 +473,6 @@ var patternlab_engine = function (config) { var viewAllPathsPartialHtml = pattern_assembler.renderPattern(viewAllPathsTemplate, {'viewallpaths': JSON.stringify(patternlab.viewAllPaths)}); //render the patternlab template, with all partials - debugger; - var patternlabSiteHtml = pattern_assembler.renderPattern(patternlabSiteTemplate, { defaultPattern: patternlab.config.defaultPattern || 'all' }, {