Skip to content

Commit

Permalink
Merge pull request #7 from virginiacommonwealthuniversity/release/1.6.0
Browse files Browse the repository at this point in the history
Release 1.6.0
  • Loading branch information
joeleisner authored Feb 24, 2017
2 parents 1f50349 + 5dddaf4 commit 5c7134e
Show file tree
Hide file tree
Showing 16 changed files with 236 additions and 101 deletions.
38 changes: 38 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"env": {
"browser": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"com": true,
"content": true,
"ContentHierarchy": true,
"ContentManager": true,
"currentSection": true,
"dbStatement": true,
"importClass": true,
"importPackage": true,
"isPreview": true,
"java": true,
"language": true,
"MediaManager": true,
"MediaUtils": true,
"MessageDigest": true,
"PathBuilder": true,
"publishCache": true,
"section": true,
"T4Utils": true,
"TreeTraversalUtils": true
},
"parserOptions": {
"ecmaVersion": 6
},
"rules": {
"indent": ["warn", 4],
"linebreak-style": ["warn", "unix"],
"quotes": ["warn", "single"],
"semi": ["warn", "always"],
"valid-jsdoc": ["error"]
}
}
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"-W060": false // disable: document.write can be a form of eval.
"-W060": false
}
9 changes: 8 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# 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.5.1_2016.12.19 - generateT4Tag() v7 Bug Fix](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.5.1_2016.12.19)
## [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.5.1_2016.12.19 - generateT4Tag() v7 Bug Fix](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.5.1_2016.12.19)
This is a v7 bug fix for `brokerUtils`'s module `generateT4Tag()`. Here's the scoop:
* T4 was processing the tag templates before being loaded into a content type or page layout.
* No matter how this module was used, an empty string was always returned
Expand Down
14 changes: 7 additions & 7 deletions gulp/build.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
var 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');
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');

var api = {
content_type_id: {
Expand Down
5 changes: 2 additions & 3 deletions gulp/config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Gulp Config
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 */
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 */
};
8 changes: 4 additions & 4 deletions gulp/datestamp.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Export
module.exports = function () {
var today = new Date(),
let today = new Date(),
month = leftPad(today.getMonth() + 1),
day = leftPad(today.getDate()),
year = today.getFullYear();
function leftPad(int) {return int < 10 ? '0' + int : int;}
day = leftPad(today.getDate()),
year = today.getFullYear();
return year + '.' + month + '.' + day;
function leftPad(int) {return int < 10 ? '0' + int : int;}
};
38 changes: 17 additions & 21 deletions gulp/header.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
// Required Modules
var datestamp = require('./datestamp.js'),
header = require('gulp-header'),
pkg = require('../package.json');
let datestamp = require('./datestamp.js'),
header = require('gulp-header'),
pkg = require('../package.json');

// Export
module.exports = function(version) {
// Define banner structure
var banner = [
'/**',
' * T4Utils 2',
' * @author <%= pkg.author %>',
' * @version <%= pkg.version %>_<%= info.date %> (<%= info.version %>)',
' * @license <%= pkg.license %>',
' */',
'\n'
].join('\n');
// Define the build information
var info = {
version: version,
date: datestamp()
};
// Return
return header(banner, { pkg:pkg, info:info });
let banner =
`/**
* T4Utils 2
* @author <%= pkg.author %>
* @version <%= pkg.version %>_<%= info.date %> (<%= info.version %>)
* @license <%= pkg.license %>
*/
`,
info = {
version: version,
date: datestamp()
};
return header(banner, {pkg, info});
};
14 changes: 5 additions & 9 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
// Required Modules
var build = require('./gulp/build.js'),
config = require('./gulp/config.js'),
gulp = require('gulp'),
jsdoc = require('gulp-jsdoc3');
let build = require('./gulp/build'),
config = require('./gulp/config'),
gulp = require('gulp'),
jsdoc = require('gulp-jsdoc3');

// Default Task
gulp.task('default', ['build']);

// Build Task
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

// Watch Task
gulp.task('watch', function() {
gulp.watch(config.watch, ['build']); // Run the build task
});

// Docs Task
gulp.task('docs', ['build'], function(doc) {
gulp.src('dist/T4Utils.js', {read: false})
.pipe(jsdoc(doc));
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "t4-utils-2",
"version": "1.5.1",
"version": "1.6.0",
"description": "A Javascript Library of Utility Classes and Extensions for TerminalFour Programmable Layouts",
"main": "dist/8.4/T4Utils.min.js",
"author": "Joel Eisner <[email protected]>",
Expand Down
11 changes: 6 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ A Javascript library of utility classes and extensions for TerminalFour Programm

## Latest Version

### [v1.5.1_2016.12.19 - generateT4Tag() v7 Bug Fix](https://github.com/virginiacommonwealthuniversity/T4Utils2/releases/tag/v1.5.1_2016.12.19)
This is a v7 bug fix for `brokerUtils`'s module `generateT4Tag()`. Here's the scoop:
* T4 was processing the tag templates before being loaded into a content type or page layout.
* No matter how this module was used, an empty string was always returned
* The first `<` of the tag template has been replaced with the unicode equivalent `\u003C`
### [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!

Check out the [changelog](changelog.md) for previous release information.

Expand Down
37 changes: 16 additions & 21 deletions src/modules/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,54 +27,50 @@ var T4Utils = (function (utils) {
/**
* Writes the specified message type to the browser console
* @member console
* @param {string} consoleMethod - You can specify which console method you want to use. "log, warn, error" are valid
* @param {string} consoleMethod - You can specify which console method you want to use. 'log, warn, error' are valid
* @param {String|Object} textOrObj - The text you want to write to the screen. With the console method you should be able to write objects as well, but it's not the case from inside the Util class
* @returns {null} document.write's a script tag with a console method
* @example
* T4Utils.console(string, string);
*/
utils.console = function (consoleMethod, textOrObj) {
if (typeof textOrObj === "string") {
document.write("<script>console." + consoleMethod + "('" + textOrObj + "');</script>\n");
}
if (typeof textOrObj === 'string') document.write('<script>console.' + consoleMethod + '("' + textOrObj + '");</script>\n');
};

/**
* Writes a message to the browser console
* @function console.log
* @param {String|Object} textOrObj - The text you want to write to the screen. With the console method you should be able to write objects as well, but it's not the case from inside the Util class
* @returns {null} document.write's a script tag with a console.log method
* @example
* T4Utils.console.log(string);
*/
utils.console.log = function (textOrObj) {
if (typeof textOrObj === "string") {
document.write("<script>console.log('" + textOrObj + "');</script>\n");
}
if (typeof textOrObj === 'string') document.write('<script>console.log("' + textOrObj + '");</script>\n');
};

/**
* Writes a warning to the browser console
* @function console.warn
* @param {String|Object} textOrObj - The text you want to write to the screen. With the console method you should be able to write objects as well, but it's not the case from inside the Util class
* @returns {null} document.write's a script tag with a console.warn method
* @example
* T4Utils.console.warn(string);
*/
utils.console.warn = function (textOrObj) {
if(typeof textOrObj === "string") {
document.write("<script>console.warn('" + textOrObj + "');</script>\n");
}
if(typeof textOrObj === 'string') document.write('<script>console.warn("' + textOrObj + '");</script>\n');
};

/**
* Writes an error to the browser console
* @function console.error
* @param {String|Object} textOrObj - The text you want to write to the screen. With the console method you should be able to write objects as well, but it's not the case from inside the Util class
* @returns {null} document.write's a script tag with a console.error method
* @example
* T4Utils.console.error(string);
*/
utils.console.error = function (textOrObj) {
if(typeof textOrObj === "string") {
document.write("<script>console.error('" + textOrObj + "');</script>\n");
}
if(typeof textOrObj === 'string') document.write('<script>console.error("' + textOrObj + '");</script>\n');
};

/**
Expand Down Expand Up @@ -113,11 +109,12 @@ var T4Utils = (function (utils) {
* Writes a paragraph formatted HTML message to the browser
* @member write
* @param {string} text - The text you want to write to the screen
* @returns {null} document.write's a paragraph tag
* @example
* T4Utils.write(string);
*/
utils.write = function (text) {
document.write("<p>" + text + "</p>\n");
document.write('<p>' + text + '</p>\n');
};

/**
Expand All @@ -139,15 +136,13 @@ var T4Utils = (function (utils) {
* T4Utils.escapeHTML(string);
*/
utils.escapeHtml = function (unsafe) {
return unsafe.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/'/g, "&#039;");
return unsafe.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/'/g, '&#039;');
};

/**
* Creates a toJavaString prototype on the global String object
*/
// Creates a toJavaString prototype on the global String object
String.prototype.toJavaString = function () {return new java.lang.String(this);};

// Return the utils
Expand Down
2 changes: 1 addition & 1 deletion src/modules/brokerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ T4Utils.brokerUtils.processT4Tag = function (t4Tag) {
/**
* Creates and processes a T4 tag from a configuration object and returns its computed value
* @function brokerUtils.generateT4Tag
* @param {Object} userSettings - The configuration object for creating the T4 tag
* @param {Object} userConfig - The configuration object for creating the T4 tag
* @returns {string} the string of the computed value
* T4Utils.brokerUtils.generateT4Tag(object);
*/
Expand Down
23 changes: 13 additions & 10 deletions src/modules/dependencies.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
// Dependencies ----------------------------------------------------------------
/* Dependencies */

// Get Section Info (getSectionInfo)
importClass(com.terminalfour.publish.PathBuilder); /* Path builder package */
importClass(com.terminalfour.publish.PathBuilder); // Path builder package

// Java
importPackage(java.lang); /* Java language package */
importPackage(java.lang); // Java language package

// Media (media)
importPackage(com.terminalfour.media); /* Media package */
importPackage(com.terminalfour.media.utils); /* Media utilities package */
importPackage(com.terminalfour.media); // Media package
importPackage(com.terminalfour.media.utils); // Media utilities package

// Ordinal Indicators (ordinalIndicators)
importClass(com.terminalfour.sitemanager.cache.utils.CSHelper); /* CS helper class */
importClass(com.terminalfour.sitemanager.cache.CachedContent); /* Cached content class */
importPackage(com.terminalfour.sitemanager); /* Site manager package */
importPackage(com.terminalfour.content); /* Content package */
importClass(com.terminalfour.sitemanager.cache.utils.CSHelper); // CS helper class
importClass(com.terminalfour.sitemanager.cache.CachedContent); // Cached content class
importPackage(com.terminalfour.sitemanager); // Site manager package
importPackage(com.terminalfour.content); // Content package

// Publish Cache (publishCache)
importClass(com.terminalfour.publish.utils.TreeTraversalUtils); // Tree traversal utility class

// Security (security)
importPackage(java.security); /* Java security package */
importPackage(java.security); // Java security package
6 changes: 3 additions & 3 deletions src/modules/elementInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ T4Utils.elementInfo.getElements = function () {
T4Utils.elementInfo.getElementValue = function (element) {
if (T4Utils.contextIsContent) {
var el = content.get(element);
if (typeof el.publish === "function") {
if (typeof el.publish === 'function') {
return el.publish();
}
}
Expand All @@ -49,7 +49,7 @@ T4Utils.elementInfo.getElementValue = function (element) {
T4Utils.elementInfo.getElementName = function (element) {
if (T4Utils.contextIsContent) {
var el = content.get(element);
if (typeof el.getName === "function") {
if (typeof el.getName === 'function') {
return el.getName();
}
}
Expand All @@ -67,7 +67,7 @@ T4Utils.elementInfo.getElementName = function (element) {
T4Utils.elementInfo.getElementID = function (element) {
if (T4Utils.contextIsContent) {
var el = content.get(element);
if (typeof el.getID === "function") {
if (typeof el.getID === 'function') {
return el.getID();
}
}
Expand Down
Loading

0 comments on commit 5c7134e

Please sign in to comment.