From 4cc3fd3a1f10f7f88d4ee1c7292a315fc0ebb006 Mon Sep 17 00:00:00 2001 From: devlinjd Date: Thu, 5 Nov 2015 00:56:41 -0500 Subject: [PATCH] Comments. --- src/core/theme.js | 23 ++++++++++++++++------- src/fluentcmd.js | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/core/theme.js b/src/core/theme.js index 0597b8b..9ade483 100644 --- a/src/core/theme.js +++ b/src/core/theme.js @@ -33,6 +33,9 @@ Abstract theme representation. // Remember the theme folder; might be custom this.folder = themeFolder; + + // Iterate over all files in the theme folder, producing an array, fmts, + // containing info for each file. var tplFolder = PATH.join( themeFolder, 'templates' ); var fmts = FS.readdirSync( tplFolder ).map( function( file ) { var absPath = PATH.join( tplFolder, file ); @@ -48,20 +51,24 @@ Abstract theme representation. return temp; }); - // Freebie formats every theme gets + // Add freebie formats every theme gets fmts.push( [ 'json', { title: 'json', pre: 'json', ext: 'json', path: null, data: null } ] ); fmts.push( [ 'yml', { title: 'yaml', pre: 'yml', ext: 'yml', path: null, data: null } ] ); - // Handle CSS files - var cssFiles = fmts.filter(function( fmt ){ - return fmt[1].ext === 'css'; - }); - cssFiles.forEach(function( cssf ) { + // Now, get all the CSS files... + this.cssFiles = fmts.filter(function( fmt ){ return fmt[1].ext === 'css'; }); + + // ...and assemble information on them + this.cssFiles.forEach(function( cssf ) { // For each CSS file, get its corresponding HTML file - var idx = _.findIndex(fmts, function( fmt ) { return fmt[1].pre === cssf[1].pre && fmt[1].ext === 'html' }); + var idx = _.findIndex(fmts, function( fmt ) { + return fmt[1].pre === cssf[1].pre && fmt[1].ext === 'html' + }); fmts[ idx ][1].css = cssf[1].data; fmts[ idx ][1].cssPath = cssf[1].path; }); + + // Remove CSS files from the formats array fmts = fmts.filter( function( fmt) { return fmt[1].ext !== 'css'; }); @@ -69,7 +76,9 @@ Abstract theme representation. // Create a hash out of the formats for this theme this.formats = _.object( fmts ); + // Set the official theme name this.name = PATH.parse( themeFolder ).name; + return this; }; diff --git a/src/fluentcmd.js b/src/fluentcmd.js index 3a68852..92df228 100644 --- a/src/fluentcmd.js +++ b/src/fluentcmd.js @@ -123,7 +123,7 @@ module.exports = function () { ]; /** - Default FluentCMD options. + Default FluentCV options. */ var _opts = { theme: 'modern',