Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Updated the generator settings and JS file.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhartman committed Sep 12, 2018
1 parent 0fbe653 commit 56cd4db
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 77 deletions.
56 changes: 18 additions & 38 deletions _generator-settings.html
Original file line number Diff line number Diff line change
@@ -1,63 +1,43 @@
<form onsubmit="assistant.finish(); return false;">
<section>
<h4>Choose a base:</h4>

<input type="radio" name="base" value="none" checked="true">
<strong>None</strong>
<span>Start with just the basics.</span>
<br/>

<input type="radio" name="base" value="responsive">
<strong>Responsive</strong>
<span>A mobile-first, responsive design</span>
<br/>

<input type="radio" name="base" value="bootstrap">
<strong>Bootstrap</strong>
<span>A mobile-first, responsive design using the Bootstrap framework.
<br/>
</section>

<section>
<h4>Choose an HTML5 Fallback:</h4>
<h4>Choose a Template:</h4>

<input type="radio" name="polyfill" value="modernizr" checked="true">
<strong>Modernizr</strong>
<span>Check each HTML5 feature natively and add basic DOM support for unrecognized elements.</span>
<input type="radio" name="base" value="starter" checked="true">
<strong>Starter</strong>
<span>Nothing but the basics: compiled CSS and JavaScript.</span>
<br/>
<input type="radio" name="polyfill" value="html5shiv">
<strong>HTML5Shiv</strong>
<span>Add basic DOM support for unrecognized elements.</span>

<input type="radio" name="base" value="jumbotron">
<strong>Jumbotron</strong>
<span>Build around the jumbotron with a navbar and some basic grid columns.
<br/>
</section>
</section>


<section>
<h4>Extras</h4>

<input type="checkbox" name="ieTags" checked="true">
<strong>IE Classes</strong>
<span>Include classes in the markup for Internet Explorer.</span>
<span>Include classes in the markup for Internet Explorer 9?</span>
<br/>
<input type="checkbox" name="serverExtras">

<input type="checkbox" name="serverExtras" checked="true">
<strong>Server Extras</strong>
<span>Include .htaccess, robots.txt, a 404 landing page, etc.</span>
<span>Include .htaccess, robots.txt, humans.txt, etc.</span>
<br/>
<input type="checkbox" name="ga" onclick="h5bp.toggle_gaSiteId();" >

<input type="checkbox" name="ga" onclick="Bootstrap.toggle_gaSiteId();" checked="true">
<strong>Google Analytics</strong>
<span>Insert markup for Site ID: <input type="text" name="ga_siteId" placeholder="UA-XXXXX-X" disabled="true"></span>
<br/>
</section>
</form>

<script>
window.h5bp = {
window.Bootstrap = {
toggle_gaSiteId: function() {
var siteId = document.querySelector('input[name=ga_siteId]');

if (document.querySelector('input[name=ga]').checked) {
siteId.disabled = false;
siteId.focus();
Expand All @@ -66,7 +46,7 @@ <h4>Extras</h4>
siteId.disabled = true;
siteId.value = '';
}

return true;
}
};
Expand Down
85 changes: 46 additions & 39 deletions _generator.js
Original file line number Diff line number Diff line change
@@ -1,71 +1,78 @@
var vendorScriptMap = {
bootstrap: 'bootstrap-3.3.7.min.js',
html5shiv: 'html5shiv-3.7.3.min.js',
respond: 'respond-1.4.2.min.js',
jquery: 'jquery-3.3.1.min.js',
modernizr: 'modernizr-3.6.0.min.js'
bootstrap: 'bootstrap.min.js',
jquery: 'jquery-slim.min.js',
popper: 'popper.min.js',
anchor: 'anchor.min.js',
clipboard: 'clipboard.min.js',
holder: 'holder.min.js'

};

generator.applyToOutputNode = function(outputFolderNode, inputFolderNode) {
// Read config and set default values

// Read config and set default values
var config = generator.config || {};
config.base = config.base || 'none';
config.polyfill = config.polyfill || 'modernizr';
config.base = config.base || 'starter';
config.serverExtras = !!config.serverExtras;
config.ieTags = (config.ieTags === undefined) ? true : !!config.ieTags;
config.ga = !!config.ga;
config.ga_siteId = config.ga ? config.ga_siteId || '' : undefined;
// Add common files from H5BP
var boilerplateInputNode = inputFolderNode.folderForPath('html5-boilerplate_v6.1.0');

// Add common files from Bootstrap folder.
var boilerplateInputNode = inputFolderNode.folderForPath('bootstrap');
var boilerplateOutputNode = outputFolderNode.addFolderAtPath(boilerplateInputNode, './', OverwriteOnConflict);

var excludePaths = ['css/', 'doc/', 'js/vendor/', 'index.html' ];

var excludePaths = [
'examples/',
'js/'
];
if (!config.serverExtras) {
excludePaths = excludePaths.concat(['.htaccess', '404.html', 'humans.txt', 'robots.txt']);
excludePaths = excludePaths.concat([
'.htaccess',
'.gitignore',
'.gitattributes',
'.editorconfig',
'humans.txt',
'robots.txt'
]);
}
excludePaths.forEach(function(excludePath) {

excludePaths.forEach(function(excludePath) {
var currentNode = null;

if (excludePath.slice(-1) === '/') {
currentNode = boilerplateInputNode.folderForPath(excludePath);
}
else {
currentNode = boilerplateInputNode.fileForPath(excludePath);
}

boilerplateOutputNode.excludeNode(currentNode);
});

// Add vendor script libraries
function addVendorScript(vendorFileName) {
if (vendorFileName) {
var vendorInputFile = inputFolderNode.fileForPath('vendor-scripts/' + vendorFileName);
outputFolderNode.addFileAtPath(vendorInputFile, 'js/vendor/' + vendorFileName, OverwriteOnConflict);
}
};


addVendorScript(vendorScriptMap.bootstrap);
addVendorScript(vendorScriptMap.jquery);
addVendorScript(vendorScriptMap[config.polyfill]);

if (config.base === 'responsive' || config.base === 'bootstrap') {
addVendorScript(vendorScriptMap.respond);
}

if (config.base === 'bootstrap') {
addVendorScript(vendorScriptMap.bootstrap);

if (config.base === 'starter' || config.base === 'jumbotron') {
addVendorScript(vendorScriptMap.popper);
}

// Add template styles
var styleInputFolderNode = inputFolderNode.folderForPath('templates/' + config.base);

if (styleInputFolderNode !== null) {
for (var i = 0, styleChildNodes = styleInputFolderNode.childNodes; i < styleChildNodes.length; i++) {
var childNode = styleChildNodes[i];
var childNodePath = childNode.path.split('/').slice(2).join('/');

if (childNode.type === FolderNode) {
outputFolderNode.addFolderAtPath(childNode, childNodePath);
}
Expand All @@ -74,25 +81,25 @@ generator.applyToOutputNode = function(outputFolderNode, inputFolderNode) {
}
}
}

// Translate our configuration to the index page
var boilerplateIndexNode = outputFolderNode.fileForPath('index.html');

if (boilerplateIndexNode !== null) {
boilerplateIndexNode.assignVariable(config.polyfill, 'true');
// boilerplateIndexNode.assignVariable(config.polyfill, 'true');

if (config.ieTags) {
boilerplateIndexNode.assignVariable('ieTags', true);
}

if (config.ga) {
boilerplateIndexNode.assignVariable('googleAnalytics', true);
}

if (config.ga_siteId) {
boilerplateIndexNode.assignVariable('googleAnalyticsSiteID', config.ga_siteId);
}
}

return true;
};

0 comments on commit 56cd4db

Please sign in to comment.