From f8a44e8906f926fd204e3cd38ef079ad2e075e1a Mon Sep 17 00:00:00 2001 From: Joel Eisner Date: Fri, 17 Mar 2017 15:23:31 -0400 Subject: [PATCH 1/5] Updated the publishCache module to fix Java errors when utilizing microsite.rootSection.object --- src/modules/publishCache.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/publishCache.js b/src/modules/publishCache.js index 4bbe1d2..d80e43a 100644 --- a/src/modules/publishCache.js +++ b/src/modules/publishCache.js @@ -61,11 +61,12 @@ T4Utils.publishCache.channel = (function() { */ T4Utils.publishCache.microsite = (function() { // Select the microsite based on the current section and its root ID and section - var microsite = publishCache.getMicroSiteFromChild(section), + var channel = publishCache.getChannel(), + microsite = publishCache.getMicroSiteFromChild(section), isMicrosite = Boolean(microsite); if (isMicrosite) { var rootID = Number(microsite.getRootSectionID()), - rootSection = TreeTraversalUtils.findSection(microsite, section, rootID, language); + rootSection = TreeTraversalUtils.findSection(channel, section, rootID, language); // Return an object that contains... return { baseHref: String(microsite.getBaseHref()), // (String) Base HREF for the microsite From 9cc648ddcdf111cd6a520b99ee7886f6d2f180bd Mon Sep 17 00:00:00 2001 From: Joel Eisner Date: Fri, 17 Mar 2017 15:23:58 -0400 Subject: [PATCH 2/5] Dropped T4 7.4 support --- gulp/build.js | 54 +++++++------------------------- gulp/datestamp.js | 6 ++-- gulp/header.js | 5 ++- gulpfile.js | 31 ++++++++++++++---- src/modules/base.js | 9 ------ src/modules/ordinalIndicators.js | 36 ++++++++++----------- 6 files changed, 61 insertions(+), 80 deletions(-) diff --git a/gulp/build.js b/gulp/build.js index 35230b4..bbd0c08 100644 --- a/gulp/build.js +++ b/gulp/build.js @@ -6,47 +6,17 @@ let datestamp = require('./datestamp.js'), replace = require('gulp-replace'), uglify = require('gulp-uglify'); -var api = { - content_type_id: { - '8.1': 'content.getContentTypeID()', - '7.4': 'content.getTemplateID()' - }, - ocm: { - '8.1': 'com.terminalfour.spring.ApplicationContextProvider.getBean(com.terminalfour.content.IContentManager)', - '7.4': 'ContentManager.getManager()' - }, - ocm_get_id: { - '8.1': 'oCM.get(contentInSection[i], \'en\').getID()', - '7.4': 'oCM.get(dbStatement, contentInSection[i], \'en\').getID()' - }, - ocm_next_content_type_id: { - '8.1': 'oCM.get(contentInSection[i + 1], \'en\').getContentTypeID()', - '7.4': 'oCM.get(dbStatement, contentInSection[i + 1], \'en\').getTemplateID()' - }, - ocm_prev_content_type_id: { - '8.1': 'oCM.get(contentInSection[i - 1], \'en\').getContentTypeID()', - '7.4': 'oCM.get(dbStatement, contentInSection[i - 1], \'en\').getTemplateID()' - } -}; - -module.exports = function(gulp, config, version) { - gulp.task('build-' + version, function() { - return gulp.src(config.src) // Grab the source files - .pipe(include()) // Include javascript modules - .pipe(replace(/\{\{version\}\}/g, pkg.version)) // Replace {{version}} with the package.json version - .pipe(replace(/\{\{t4_version\}\}/g, version)) // Replace {{t4_version}} with the passed in version - .pipe(replace(/\{\{datestamp\}\}/g, datestamp())) // Replace {{datestamp}} with a YYYY.mm.dd datestamp - .pipe(replace(/'\{\{api:content_type_id\}\}'/g, api.content_type_id[version])) // Replace {{api:content_type_id}} with the version specific JS - .pipe(replace(/'\{\{api:ocm\}\}'/g, api.ocm[version])) // Replace {{api:ocm}} with the version specific JS - .pipe(replace(/'\{\{api:ocm_get_id\}\}'/g, api.ocm_get_id[version])) // Replace {{api:ocm_get_id}} with the version specific JS - .pipe(replace(/'\{\{api:ocm_next_content_type_id\}\}'/g, api.ocm_next_content_type_id[version])) // Replace {{api:ocm_next_content_type_id}} with the version specific JS - .pipe(replace(/'\{\{api:ocm_prev_content_type_id\}\}'/g, api.ocm_prev_content_type_id[version])) // Replace {{api:ocm_prev_content_type_id}} with the version specific JS - .pipe(header(version)) // Inject library header - .pipe(rename({suffix:'.' + version})) // Give the filename a version suffix - .pipe(gulp.dest(config.dest)) // Save to the destination folder - .pipe(uglify()) // Uglify the code - .pipe(header(version)) // Re-inject library header - .pipe(rename({suffix:'.min'})) // Give the filename a .min suffix - .pipe(gulp.dest(config.dest)); // Save to the destination folder +module.exports = (gulp, config) => { + gulp.task('build', () => { + return gulp.src(config.src) // Grab the source files + .pipe(include()) // Include javascript modules + .pipe(replace(/\{\{version\}\}/g, pkg.version)) // Replace {{version}} with the package.json version + .pipe(replace(/\{\{datestamp\}\}/g, datestamp())) // Replace {{datestamp}} with a YYYY.mm.dd datestamp + .pipe(header()) // Inject library header + .pipe(gulp.dest(config.dest)) // Save to the destination folder + .pipe(uglify()) // Uglify the code + .pipe(header()) // Re-inject library header + .pipe(rename({suffix:'.min'})) // Give the filename a .min suffix + .pipe(gulp.dest(config.dest)); // Save to the destination folder }); }; diff --git a/gulp/datestamp.js b/gulp/datestamp.js index 3a49e68..687c38c 100644 --- a/gulp/datestamp.js +++ b/gulp/datestamp.js @@ -1,9 +1,11 @@ // Export -module.exports = function () { +module.exports = () => { let today = new Date(), month = leftPad(today.getMonth() + 1), day = leftPad(today.getDate()), year = today.getFullYear(); return year + '.' + month + '.' + day; - function leftPad(int) {return int < 10 ? '0' + int : int;} + function leftPad(int) { + return int < 10 ? '0' + int : int; + } }; diff --git a/gulp/header.js b/gulp/header.js index a611350..2cce965 100644 --- a/gulp/header.js +++ b/gulp/header.js @@ -3,18 +3,17 @@ let datestamp = require('./datestamp.js'), header = require('gulp-header'), pkg = require('../package.json'); -module.exports = function(version) { +module.exports = () => { let banner = `/** * T4Utils 2 * @author <%= pkg.author %> - * @version <%= pkg.version %>_<%= info.date %> (<%= info.version %>) + * @version <%= pkg.version %>_<%= info.date %> * @license <%= pkg.license %> */ `, info = { - version: version, date: datestamp() }; return header(banner, {pkg, info}); diff --git a/gulpfile.js b/gulpfile.js index 5d30455..7ab1d40 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,14 +1,33 @@ -let build = require('./gulp/build'), - config = require('./gulp/config'), +let config = require('./gulp/config'), + datestamp = require('./gulp/datestamp.js'), gulp = require('gulp'), - jsdoc = require('gulp-jsdoc3'); + header = require('./gulp/header.js'), + include = require('gulp-include'), + jsdoc = require('gulp-jsdoc3'), + pkg = require('./package.json'), + rename = require('gulp-rename'), + replace = require('gulp-replace'), + uglify = require('gulp-uglify'); gulp.task('default', ['build']); -gulp.task('build', ['build-8.1', 'build-7.4']); // Build both versions of the library +// gulp.task('build', ['build-8.1', 'build-7.4']); // Build both versions of the library -build(gulp, config, '8.1'); // Build the v8 version of the library -build(gulp, config, '7.4'); // Build the v7 version of the library +// build(gulp, config, '8.1'); // Build the v8 version of the library +// build(gulp, config, '7.4'); // Build the v7 version of the library + +gulp.task('build', () => { + return gulp.src(config.src) // Grab the source files + .pipe(include()) // Include javascript modules + .pipe(replace(/\{\{version\}\}/g, pkg.version)) // Replace {{version}} with the package.json version + .pipe(replace(/\{\{datestamp\}\}/g, datestamp())) // Replace {{datestamp}} with a YYYY.mm.dd datestamp + .pipe(header()) // Inject library header + .pipe(gulp.dest(config.dest)) // Save to the destination folder + .pipe(uglify()) // Uglify the code + .pipe(header()) // Re-inject library header + .pipe(rename({suffix:'.min'})) // Give the filename a .min suffix + .pipe(gulp.dest(config.dest)); // Save to the destination folder +}); gulp.task('watch', function() { gulp.watch(config.watch, ['build']); // Run the build task diff --git a/src/modules/base.js b/src/modules/base.js index 6ba2b8d..2832a02 100644 --- a/src/modules/base.js +++ b/src/modules/base.js @@ -15,15 +15,6 @@ var T4Utils = (function (utils) { */ utils.version = '{{version}}_{{datestamp}}'; - /** - * The version of TerminalFour this library is intended for - * @member t4 - * @returns {string} the version of TerminalFour this library is intened for - * @example - * T4Utils.t4; - */ - utils.t4 = '{{t4_version}}'; - /** * Writes the specified message type to the browser console * @member console diff --git a/src/modules/ordinalIndicators.js b/src/modules/ordinalIndicators.js index 5d7755d..7fcb01b 100644 --- a/src/modules/ordinalIndicators.js +++ b/src/modules/ordinalIndicators.js @@ -55,15 +55,15 @@ T4Utils.ordinalIndicators.pageInfo = (function() { for (var k = 0; k < cL.length; k++) { var cP = cL[k], ctID = cP.getTemplateID(), - uID = cP.getID(); + uID = cP.getID(); for (var l = 0; l < listContentTypeIDs.length; l++) { var contentTypeID = listContentTypeIDs[l]; if (ctID === contentTypeID.key) contentTypeID.pieces.push(uID); } } // Get the current content's content-type and unique ID's - var this_ctID = '{{api:content_type_id}}', - this_uID = content.getID(); + var this_ctID = content.getContentTypeID(), + this_uID = content.getID(); // For each key/pieces object... for (var m = 0; m < listContentTypeIDs.length; m++) { // ... create a reference, ... @@ -71,10 +71,10 @@ T4Utils.ordinalIndicators.pageInfo = (function() { // ... if the referenced object's key is equal to the current content's content-type ID... if (typeID.key === this_ctID) { // Define (of this content-type, in the scope of the entire page)... - var pieces = typeID.pieces, /* All content */ - pFirst = pieces[0], /* The first piece of content */ - pLength = pieces.length, /* The amount of pieces of content */ - pLast = pieces[pLength - 1]; /* The last piece of content */ + var pieces = typeID.pieces, /* All content */ + pFirst = pieces[0], /* The first piece of content */ + pLength = pieces.length, /* The amount of pieces of content */ + pLast = pieces[pLength - 1]; /* The last piece of content */ // ... then assign values for pageCount, pageFirst, pageLast, and pageIndex based on the previously defined variables pageCount = pLength; pageFirst = pFirst === this_uID ? true : false; @@ -94,7 +94,7 @@ T4Utils.ordinalIndicators.pageInfo = (function() { count: pageCount, /* (Integer) The amount of content of its kind on the page */ first: pageFirst, /* (Boolean) First of its kind on the page? */ index: pageIndex, /* (Integer) Position index of its kind on the page */ - last: pageLast /* (Boolean) Last of its kind on the page? */ + last: pageLast /* (Boolean) Last of its kind on the page? */ }; } else { // ... otherwise, return an object that contains null key/value pairs @@ -102,7 +102,7 @@ T4Utils.ordinalIndicators.pageInfo = (function() { count: null, first: null, index: null, - last: null + last: null }; } })(); @@ -153,28 +153,28 @@ T4Utils.ordinalIndicators.pageLast = T4Utils.ordinalIndicators.pageInfo.last; T4Utils.ordinalIndicators.groupInfo = (function() { // If content is defined... if (T4Utils.contextIsContent) { - var ctid = '{{api:content_type_id}}', - sid = section.getID(), - oCH = new ContentHierarchy(), - oCM = '{{api:ocm}}', + var ctid = content.getContentTypeID(), + sid = section.getID(), + oCH = new ContentHierarchy(), + oCM = com.terminalfour.spring.ApplicationContextProvider.getBean(com.terminalfour.content.IContentManager), contentInSection = oCH.getContent(dbStatement, sid, 'en'), groupFirst, groupLast; for (var i = 0; i < contentInSection.length; i++) { - if (content.getID() === '{{api:ocm_get_id}}') { - groupFirst = i === 0 ? true : ctid !== '{{api:ocm_prev_content_type_id}}' ? true : false; - groupLast = i === contentInSection.length - 1 ? true : ctid !== '{{api:ocm_next_content_type_id}}' ? true : false; + if (content.getID() === oCM.get(contentInSection[i], 'en').getID()) { + groupFirst = i === 0 ? true : ctid !== oCM.get(contentInSection[i - 1], 'en').getContentTypeID() ? true : false; + groupLast = i === contentInSection.length - 1 ? true : ctid !== oCM.get(contentInSection[i + 1], 'en').getContentTypeID() ? true : false; } } // Return an object that contains... return { first: groupFirst, /* (Boolean) First of its kind in a group? */ - last: groupLast /* (Boolean) Last of its kind in a group? */ + last: groupLast /* (Boolean) Last of its kind in a group? */ }; } else { // ... otherwise, return an object that contains null key/value pairs return { first: null, - last: null + last: null }; } })(); From 09c7f212a11aee19ef3490480ca27ba476685d86 Mon Sep 17 00:00:00 2001 From: Joel Eisner Date: Mon, 20 Mar 2017 08:29:56 -0400 Subject: [PATCH 3/5] Updated documentation/changelog info on the 1.6.1 release --- changelog.md | 7 +++++++ readme.md | 12 ++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index b3c9daa..fae84a0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,13 @@ # Changelog T4Utils 2 utilizes [GitHub's releases feature](https://github.com/blog/1547-release-your-software) for its changelogs, but this document serves as static duplicate of that content. +## [v1.6.1_2017.03.20 - publishCache Microsite Fix](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.6.1_2017.03.20) +This update fixes an issue with `publishCache.microsite`; This module variable is now working as intended. Here's some other updates: +* T4Utils2 is dropping support for v7.4 + * The v7.4 release of 1.6.0 has been pulled for API discrepancies and errors + * Maintenance of one utility file with drastically different API calls is no longer feasible +* Build system files have been further simplified and upgraded to ES2015 (ES6) + ## [v1.6.0_2017.02.24 - publishCache Module](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.6.0_2017.02.24) This update brings a much needed `publishCache` module to T4Utils. Here's what you can do with it: * `publishCache.channel` - Returns a data object containing information about the current channel diff --git a/readme.md b/readme.md index 1ce0a81..0c3b78e 100644 --- a/readme.md +++ b/readme.md @@ -5,12 +5,12 @@ A Javascript library of utility classes and extensions for TerminalFour Programm ## Latest Version -### [v1.6.0_2017.02.24 - publishCache Module](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.6.0_2017.02.24) -This update brings a much needed `publishCache` module to T4Utils. Here's what you can do with it: -* `publishCache.channel` - Returns a data object containing information about the current channel -* `publishCache.microsite` - Returns, if at all possible, a data object containing information about the current microsite - -Check the source file to see the types of information you can pull from these objects! +### [v1.6.1_2017.03.20 - publishCache Microsite Fix](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.6.1_2017.03.20) +This update fixes an issue with `publishCache.microsite`; This module variable is now working as intended. Here's some other updates: +* T4Utils2 is dropping support for v7.4 + * The v7.4 release of 1.6.0 has been pulled for API discrepancies and errors + * Maintenance of one utility file with drastically different API calls is no longer feasible +* Build system files have been further simplified and upgraded to ES2015 (ES6) Check out the [changelog](changelog.md) for previous release information. From 709e18deeb6ac64509a832594d7a4b7752d27ec5 Mon Sep 17 00:00:00 2001 From: Joel Eisner Date: Mon, 20 Mar 2017 08:30:23 -0400 Subject: [PATCH 4/5] Updated the package.json to version 1.6.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a432d1b..a0330a9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "t4-utils-2", - "version": "1.6.0", + "version": "1.6.1", "description": "A Javascript Library of Utility Classes and Extensions for TerminalFour Programmable Layouts", "main": "dist/8.4/T4Utils.min.js", "author": "Joel Eisner ", From e38ad6514eb4909b54e1028796acd596f9f3562a Mon Sep 17 00:00:00 2001 From: Joel Eisner Date: Mon, 20 Mar 2017 08:31:01 -0400 Subject: [PATCH 5/5] Simplified and updated the Gulp build system in dropping v7.4 support --- gulp/build.js | 22 ---------------------- gulp/config.js | 6 +++--- gulp/datestamp.js | 3 +-- gulp/header.js | 24 +++++++++++++++++------- gulpfile.js | 9 ++------- 5 files changed, 23 insertions(+), 41 deletions(-) delete mode 100644 gulp/build.js diff --git a/gulp/build.js b/gulp/build.js deleted file mode 100644 index bbd0c08..0000000 --- a/gulp/build.js +++ /dev/null @@ -1,22 +0,0 @@ -let datestamp = require('./datestamp.js'), - header = require('./header.js'), - include = require('gulp-include'), - pkg = require('../package.json'), - rename = require('gulp-rename'), - replace = require('gulp-replace'), - uglify = require('gulp-uglify'); - -module.exports = (gulp, config) => { - gulp.task('build', () => { - return gulp.src(config.src) // Grab the source files - .pipe(include()) // Include javascript modules - .pipe(replace(/\{\{version\}\}/g, pkg.version)) // Replace {{version}} with the package.json version - .pipe(replace(/\{\{datestamp\}\}/g, datestamp())) // Replace {{datestamp}} with a YYYY.mm.dd datestamp - .pipe(header()) // Inject library header - .pipe(gulp.dest(config.dest)) // Save to the destination folder - .pipe(uglify()) // Uglify the code - .pipe(header()) // Re-inject library header - .pipe(rename({suffix:'.min'})) // Give the filename a .min suffix - .pipe(gulp.dest(config.dest)); // Save to the destination folder - }); -}; diff --git a/gulp/config.js b/gulp/config.js index d81f1ab..f6b98e6 100644 --- a/gulp/config.js +++ b/gulp/config.js @@ -1,5 +1,5 @@ module.exports = { - dest: 'dist', /* Save the build to the destination directory */ - src: 'src/*.js', /* Build all .js files at the root of the source directory */ - watch: 'src/**/*.js' /* Watch all .js files throughout the source directory */ + dest: 'dist', + src: 'src/*.js', + watch: 'src/**/*.js' }; diff --git a/gulp/datestamp.js b/gulp/datestamp.js index 687c38c..c1f319a 100644 --- a/gulp/datestamp.js +++ b/gulp/datestamp.js @@ -1,10 +1,9 @@ -// Export module.exports = () => { let today = new Date(), month = leftPad(today.getMonth() + 1), day = leftPad(today.getDate()), year = today.getFullYear(); - return year + '.' + month + '.' + day; + return `${year}.${month}.${day}`; function leftPad(int) { return int < 10 ? '0' + int : int; } diff --git a/gulp/header.js b/gulp/header.js index 2cce965..338832a 100644 --- a/gulp/header.js +++ b/gulp/header.js @@ -1,10 +1,15 @@ -// Required Modules let datestamp = require('./datestamp.js'), header = require('gulp-header'), pkg = require('../package.json'); -module.exports = () => { - let banner = +module.exports = format => { + let banner, + info = { + date: datestamp() + }; + switch (format) { + case 'exp': + banner = `/** * T4Utils 2 * @author <%= pkg.author %> @@ -12,9 +17,14 @@ module.exports = () => { * @license <%= pkg.license %> */ -`, - info = { - date: datestamp() - }; +`; + break; + case 'min': + banner = +`/* T4Utils2 <%= pkg.version %>_<%= info.date %> | <%= pkg.license %> | <%= pkg.author %> */ + +`; + break; + } return header(banner, {pkg, info}); }; diff --git a/gulpfile.js b/gulpfile.js index 7ab1d40..293f891 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -11,20 +11,15 @@ let config = require('./gulp/config'), gulp.task('default', ['build']); -// gulp.task('build', ['build-8.1', 'build-7.4']); // Build both versions of the library - -// build(gulp, config, '8.1'); // Build the v8 version of the library -// build(gulp, config, '7.4'); // Build the v7 version of the library - gulp.task('build', () => { return gulp.src(config.src) // Grab the source files .pipe(include()) // Include javascript modules .pipe(replace(/\{\{version\}\}/g, pkg.version)) // Replace {{version}} with the package.json version .pipe(replace(/\{\{datestamp\}\}/g, datestamp())) // Replace {{datestamp}} with a YYYY.mm.dd datestamp - .pipe(header()) // Inject library header + .pipe(header('exp')) // Inject library header .pipe(gulp.dest(config.dest)) // Save to the destination folder .pipe(uglify()) // Uglify the code - .pipe(header()) // Re-inject library header + .pipe(header('min')) // Re-inject library header .pipe(rename({suffix:'.min'})) // Give the filename a .min suffix .pipe(gulp.dest(config.dest)); // Save to the destination folder });