Skip to content

Commit

Permalink
spec changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bmuenzenmeyer committed Jun 20, 2016
1 parent e71107d commit 49538bd
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 13 deletions.
92 changes: 80 additions & 12 deletions core/lib/ui_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ var eol = require('os').EOL;

function addToPatternPaths(patternlab, patternTypeName, pattern) {
//this is messy, could use a refactor.
if (!patternlab.patternPaths[patternTypeName]) {
patternlab.patternPaths[patternTypeName] = {};
}
patternlab.patternPaths[patternTypeName][pattern.patternBaseName] = pattern.subdir.replace(/\\/g, '/') + "/" + pattern.fileName.replace('~', '-');
}

Expand All @@ -29,31 +32,52 @@ function assembleStyleguidePatterns(patternlab) {
if (styleguideExcludes && styleguideExcludes.length) {
for (var i = 0; i < patternlab.patterns.length; i++) {

var pattern = patternlab.patterns[i];

// skip underscore-prefixed files
if (isPatternExcluded(patternlab.patterns[i])) {
if (isPatternExcluded(pattern)) {
if (patternlab.config.debug) {
console.log('Omitting ' + patternlab.patterns[i].patternPartial + " from styleguide pattern exclusion.");
console.log('Omitting ' + pattern.patternPartial + " from styleguide pattern exclusion.");
}
continue;
}

var partial = patternlab.patterns[i].patternPartial;
//this is meant to be a homepage that is not present anywhere else
if (pattern.patternPartial === patternlab.config.defaultPattern) {
if (patternlab.config.debug) {
console.log('omitting ' + pattern.patternPartial + ' from styleguide patterns because it is defined as a defaultPattern');
}
continue;
}

var partial = pattern.patternPartial;
var partialType = partial.substring(0, partial.indexOf('-'));
var isExcluded = (styleguideExcludes.indexOf(partialType) > -1);
if (!isExcluded) {
styleguidePatterns.push(patternlab.patterns[i]);
styleguidePatterns.push(pattern);
}
}
} else {
for (i = 0; i < patternlab.patterns.length; i++) {
var pattern = patternlab.patterns[i];

// skip underscore-prefixed files
if (isPatternExcluded(patternlab.patterns[i])) {
if (isPatternExcluded(pattern)) {
if (patternlab.config.debug) {
console.log('Omitting ' + patternlab.patterns[i].patternPartial + " from styleguide pattern exclusion.");
console.log('Omitting ' + pattern.patternPartial + " from styleguide pattern exclusion.");
}
continue;
}
styleguidePatterns.push(patternlab.patterns[i]);

//this is meant to be a homepage that is not present anywhere else
if (pattern.patternPartial === patternlab.config.defaultPattern) {
if (patternlab.config.debug) {
console.log('omitting ' + pattern.patternPartial + ' from styleguide patterns because it is defined as a defaultPattern');
}
continue;
}

styleguidePatterns.push(pattern);
}
}

Expand All @@ -68,6 +92,19 @@ function buildNavigation(patternlab) {
//todo: check if this is already available
var patternTypeName = pattern.name.replace(/\\/g, '-').split('-')[1];

//exclude any named defaultPattern from the navigation.
//this is meant to be a homepage that is not navigable
if (pattern.patternPartial === patternlab.config.defaultPattern) {
if (patternlab.config.debug) {
console.log('omitting ' + pattern.patternPartial + ' from navigation because it is defined as a defaultPattern');
}

//add to patternPaths before continuing
addToPatternPaths(patternlab, patternTypeName, pattern);

continue;
}

// skip underscore-prefixed files. don't create a patternType on account of an underscored pattern
if (isPatternExcluded(pattern)) {
continue;
Expand Down Expand Up @@ -101,7 +138,7 @@ function buildNavigation(patternlab) {
var patternType = new of.oPatternType(patternTypeName);

//add patternPath and viewAllPath
patternlab.patternPaths[patternTypeName] = {};
patternlab.patternPaths[patternTypeName] = patternlab.patternPaths[patternTypeName] || {};
patternlab.viewAllPaths[patternTypeName] = {};

//test whether the pattern structure is flat or not - usually due to a template or page
Expand Down Expand Up @@ -246,15 +283,24 @@ function buildViewAllPages(mainPageHeadHtml, patternlab) {
var i;

for (i = 0; i < patternlab.patterns.length; i++) {

var pattern = patternlab.patterns[i];

// skip underscore-prefixed files
if (isPatternExcluded(patternlab.patterns[i])) {
if (isPatternExcluded(pattern)) {
if (patternlab.config.debug) {
console.log('Omitting ' + patternlab.patterns[i].patternPartial + " from view all rendering.");
console.log('Omitting ' + pattern.patternPartial + " from view all rendering.");
}
continue;
}

var pattern = patternlab.patterns[i];
//this is meant to be a homepage that is not present anywhere else
if (pattern.patternPartial === patternlab.config.defaultPattern) {
if (patternlab.config.debug) {
console.log('Omitting ' + pattern.patternPartial + ' from view all rendering because it is defined as a defaultPattern');
}
continue;
}

//create the view all for the section
// check if the current section is different from the previous one
Expand All @@ -275,6 +321,14 @@ function buildViewAllPages(mainPageHeadHtml, patternlab) {
continue;
}

//this is meant to be a homepage that is not present anywhere else
if (patternlab.patterns[j].patternPartial === patternlab.config.defaultPattern) {
if (patternlab.config.debug) {
console.log('Omitting ' + pattern.patternPartial + ' from view all sibling rendering because it is defined as a defaultPattern');
}
continue;
}

viewAllPatterns.push(patternlab.patterns[j]);
}
}
Expand Down Expand Up @@ -306,6 +360,14 @@ function buildViewAllPages(mainPageHeadHtml, patternlab) {
continue;
}

//this is meant to be a homepage that is not present anywhere else
if (patternlab.patterns[j].patternPartial === patternlab.config.defaultPattern) {
if (patternlab.config.debug) {
console.log('Omitting ' + pattern.patternPartial + ' from view all sibling rendering because it is defined as a defaultPattern');
}
continue;
}

viewAllPatterns.push(patternlab.patterns[j]);
}
}
Expand Down Expand Up @@ -428,11 +490,17 @@ function buildFrontEnd(patternlab) {

//plugins someday
output += 'var plugins = [];' + eol;

//smaller config elements
output += 'var defaultShowPatternInfo = ' + (patternlab.config.defaultShowPatternInfo ? patternlab.config.defaultShowPatternInfo : 'false') + ';' + eol;
output += 'var defaultPattern = "' + (patternlab.config.defaultPattern ? patternlab.config.defaultPattern : 'all') + '";' + eol;

//write all ouytput to patternlab-data
fs.outputFileSync(path.resolve(paths.public.data, 'patternlab-data.js'), output);

//annotations
var annotationsJSON = annotation_exporter.gather();
var annotations = 'var comments = ' + JSON.stringify(annotationsJSON);
var annotations = 'var comments = { "comments" : ' + JSON.stringify(annotationsJSON) + '};';
fs.outputFileSync(path.resolve(paths.public.annotations, 'annotations.js'), annotations);

}
Expand Down
1 change: 0 additions & 1 deletion patternlab-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,5 @@
},
"patternExportPatternPartials": [],
"patternExportDirectory": "./pattern_exports/",
"baseurl" : "",
"cacheBust": true
}

0 comments on commit 49538bd

Please sign in to comment.