Skip to content

Commit

Permalink
Choose the order patterns are added using the settings option: files:…
Browse files Browse the repository at this point in the history
… ['file-1.html', 'file-2.html'...] along with the src setting as the base destination
  • Loading branch information
Dustin Silk committed Oct 21, 2014
1 parent b933db8 commit c861822
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions tasks/patternprimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ module.exports = function(grunt) {
// generates the html output for the patterns
var outputPatterns = function (patterns, cb) {
getSourceFile(function generatePatterns(content) {
var scripts = content.match(/<script[\s\S]*?>[\s\S]*?<\/script>/g);
content = content.replace(/<script[\s\S]*?>[\s\S]*?<\/script>/g, "");
patterns.forEach(function (file) {
content += '<hr/>';
content += '<div class="pattern"><div class="display">';
Expand All @@ -87,7 +85,6 @@ module.exports = function(grunt) {
content += '</textarea>';
content += '</div></div>';
});
content += scripts;
content += '</body></html>';
cb(content);
});
Expand Down Expand Up @@ -131,7 +128,6 @@ module.exports = function(grunt) {
files.push(content);
}
});

// handle all the found pattern files
handleFiles(patternFolder, files, cb);
});
Expand All @@ -152,19 +148,35 @@ module.exports = function(grunt) {
snapshot_port: Array.isArray(data.ports) && data.ports[1] ? data.ports[1] : Array.isArray(options.ports) && options.ports[1] ? options.ports[1] : 7040,
wwwroot: data.wwwroot || options.wwwroot || 'public',
src: data.src || options.src || 'public/patterns',
files: data.files || options.files || [],
dest: data.dest || options.dest || 'docs',
snapshot: (data.snapshot !== undefined ? data.snapshot : (options.snapshot !== undefined ? options.snapshot : false)),
index: data.index || options.index || null,
css: data.css || options.css || ['global.css']
};

var primer;

// local pattern folder (there are the html snapshots)
var patternFolder = './' + settings.src;
if (settings.files.length > 0) {
var patterns = settings.files;
var patternsFolder = settings.src;

// our main function that starts the process
var primer = function (cb) {
readPatterns(patternFolder, cb);
};
// our main function that starts the process
primer = function (cb) {
handleFiles(patternsFolder, patterns, cb);
};

} else {
var patternFolder = './' + settings.src;

// our main function that starts the process
primer = function (cb) {
readPatterns(patternFolder, cb);
};
}



// middleware to spit out 404 (in case a non existing ressource is request)
// or to process the `non static` requests
Expand Down

0 comments on commit c861822

Please sign in to comment.