Skip to content

Commit

Permalink
compile dist
Browse files Browse the repository at this point in the history
  • Loading branch information
wonknu committed Sep 27, 2016
1 parent a360164 commit 7620186
Show file tree
Hide file tree
Showing 13 changed files with 391 additions and 390 deletions.
11 changes: 6 additions & 5 deletions dist/cli/controllers/Save.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ function save(url, tplPath) {
var date = _.fileAttr.get(pathIso.jsonPath).d;

if (publishAll) {
date = json[meta].publish.date;
if (typeof json[meta].publish !== 'undefined' && json[meta].publish !== null) {
date = json[meta].publish.date;
}
}
if (typeof date === 'undefined' || date === null || date === '') {
date = new Date();
Expand All @@ -143,13 +145,13 @@ function save(url, tplPath) {
json = _.Hooks.instance.trigger('afterGetDataListOnSave', json);
for (var prop in json) {
if (_typeof(json[prop]) === 'object' && Array.isArray(json[prop]) && json[prop].length === 1) {
var valuesAreEmplty = true;
var valuesAreEmpty = true;
json[prop].forEach(function (element) {
for (var p in element) {
if (element[p] !== '') valuesAreEmplty = false;
if (element[p] !== '') valuesAreEmpty = false;
}
});
if (valuesAreEmplty) delete json[prop];
if (valuesAreEmpty) delete json[prop];
}
}

Expand Down Expand Up @@ -238,7 +240,6 @@ function saveHtml(url, html) {
if (_.fileAttr.test(url) && _.fileAttr.get(url).s !== 'd') {
_.fileUtils.deleteOlderRevisionByType(_.fileAttr.delete(url), _.fileAttr.get(url).s);
}

_fsExtra2.default.writeFileSync(url, html);
}

Expand Down
8 changes: 4 additions & 4 deletions dist/cli/handlebars/abe/compileAbe.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ function compileAbe() {
value = '';
}
if (typeof hash.type !== 'undefined' && hash.type !== null && hash.type === 'rich') {
var testXSS = (0, _xss2.default)(value.replace(/"/g, '"'), {
var testXSS = (0, _xss2.default)(value.replace(/&quote;/g, "'"), {
'whiteList': _.config.htmlWhiteList,
stripIgnoreTag: true
});
return new _handlebars2.default.SafeString(testXSS);
}
return value.replace(/%27/, '\'');
return value.replace(/%27/, '\'').replace(/&quote;/g, "'");
}

var key = arguments[0].hash['key'].replace('.', '-');
Expand All @@ -61,11 +61,11 @@ function compileAbe() {
}

if (typeof hash.type !== 'undefined' && hash.type !== null && hash.type === 'rich') {
var testXSS = (0, _xss2.default)(value.replace(/"/g, '"'), {
var testXSS = (0, _xss2.default)(value.replace(/&quote;/g, "'"), {
'whiteList': _.config.htmlWhiteList,
stripIgnoreTag: true
});
return new _handlebars2.default.SafeString(testXSS);
}
return value.replace(/%27/, '\'');
return value.replace(/%27/, '\'').replace(/&quote;/g, "'");
}
8 changes: 4 additions & 4 deletions dist/cli/handlebars/abe/printInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ function printInput() {
if (typeof params.value === 'string') params.value = params.value.replace(/\"/g, '"');

var inputClass = 'form-control form-abe';
var commonParams = 'id="' + params.key + '"\n data-id="' + params.key + '"\n value="' + params.value + '"\n maxlength="' + params.maxLength + '"\n reload="' + params.reload + '"\n tabIndex="' + params.order + '"\n data-required="' + params.required + '"\n data-display="' + params.display + '"\n data-visible="' + params.visible + '"\n data-autocomplete="' + params.autocomplete + '"\n placeholder="' + params.placeholder + '"';
var commonParams = 'id="' + params.key + '"\n data-id="' + params.key + '"\n value="' + params.value + '"\n maxlength="' + params['max-length'] + '"\n reload="' + params.reload + '"\n tabIndex="' + params.order + '"\n data-required="' + params.required + '"\n data-display="' + params.display + '"\n data-visible="' + params.visible + '"\n data-autocomplete="' + params.autocomplete + '"\n placeholder="' + params.placeholder + '"';

if (typeof params.source !== 'undefined' && params.source !== null) {
commonParams = 'id="' + params.key + '"\n data-id="' + params.key + '"\n data-maxlength="' + params.maxLength + '"\n reload="' + params.reload + '"\n tabIndex="' + params.order + '"\n data-required="' + params.required + '"\n data-display="' + params.display + '"\n data-visible="' + params.visible + '"\n data-autocomplete="' + params.autocomplete + '"\n placeholder="' + params.placeholder + '"';
commonParams = 'id="' + params.key + '"\n data-id="' + params.key + '"\n data-maxlength="' + params['max-length'] + '"\n reload="' + params.reload + '"\n tabIndex="' + params.order + '"\n data-required="' + params.required + '"\n data-display="' + params.display + '"\n data-visible="' + params.visible + '"\n data-autocomplete="' + params.autocomplete + '"\n placeholder="' + params.placeholder + '"';

var multiple = '';
var disabled = '';
if (typeof params.maxLength === 'undefined' || params.maxLength === null || params.maxLength === '' || params.maxLength > 1 && params.source.length > 0) {
if (typeof params['max-length'] === 'undefined' || params['max-length'] === null || params['max-length'] === '' || params['max-length'] > 1 && params.source.length > 0) {
multiple = 'multiple';
}
if (params.source.length <= 0) {
Expand Down Expand Up @@ -87,7 +87,7 @@ function printInput() {
res += '</select>';
}
} else if (params.type.indexOf('rich') >= 0) {
commonParams = 'id="' + params.key + '"\n data-id="' + params.key + '"\n maxlength="' + params.maxLength + '"\n reload="' + params.reload + '"\n tabIndex="' + params.order + '"\n data-required="' + params.required + '"\n data-display="' + params.display + '"\n data-visible="' + params.visible + '"\n data-autocomplete="' + params.autocomplete + '"\n placeholder="' + params.placeholder + '"';
commonParams = 'id="' + params.key + '"\n data-id="' + params.key + '"\n maxlength="' + params['max-length'] + '"\n reload="' + params.reload + '"\n tabIndex="' + params.order + '"\n data-required="' + params.required + '"\n data-display="' + params.display + '"\n data-visible="' + params.visible + '"\n data-autocomplete="' + params.autocomplete + '"\n placeholder="' + params.placeholder + '"';

res += '<div class="wysiwyg-container rich">\n <div class="wysiwyg-toolbar wysiwyg-toolbar-top">\n <a class="wysiwyg-toolbar-icon" href="#" title="Bold (Ctrl+B)" hotkey="b" data-action="bold" data-param="">\n <span class="glyphicon glyphicon-bold"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Italic (Ctrl+I)" hotkey="i" data-action="italic" data-param="">\n <span class="glyphicon glyphicon-italic"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Underline (Ctrl+U)" hotkey="u" data-action="underline" data-param="">\n <span class="glyphicon underline">U</span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Text color" data-action="forecolor" data-param="" data-popup="color">\n <span class="glyphicon glyphicon-text-color"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Background color" data-action="highlight" data-param="" data-popup="color">\n <span class="glyphicon glyphicon-text-background"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Left" data-action="align" data-param="left">\n <span class="glyphicon glyphicon-object-align-left"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Center" data-action="align" data-param="center">\n <span class="glyphicon glyphicon-object-align-vertical"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Right" data-action="align" data-param="right">\n <span class="glyphicon glyphicon-object-align-right"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Justify" data-action="justify" data-param="justify">\n <span class="glyphicon glyphicon-menu-hamburger"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Subscript" data-action="subscript" data-param="">\n <span class="glyphicon glyphicon-subscript"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Superscript" data-action="superscript" data-param="">\n <span class="glyphicon glyphicon-superscript"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Indent" data-action="indent" data-param="">\n <span class="glyphicon glyphicon-triangle-right"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Outdent" data-action="indent" data-param="outdent">\n <span class="glyphicon glyphicon-triangle-left"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Unordered list" data-action="insertList" data-param="">\n <span class="glyphicon glyphicon-th-list"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Remove format" data-action="removeFormat" data-param="">\n <span class="glyphicon glyphicon-remove"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Add link" data-action="insertLink" data-popup="link" data-param="">\n <span class="glyphicon glyphicon-link"></span>\n </a>\n <a class="wysiwyg-toolbar-icon" href="#" title="Code style" data-action="code" data-param="">\n <span class="glyphicon glyphicon-console"></span>\n </a>\n </div>\n <textarea class="' + inputClass + ' form-rich"\n ' + commonParams + '\n rows="4">' + params.value + '</textarea>\n </div>';
} else if (params.type.indexOf('file') >= 0) {
Expand Down
3 changes: 1 addition & 2 deletions dist/cli/helpers/abe-get-select-template-keys.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ var findRequestColumns = function findRequestColumns(templatesList) {
}
});
}
resolve(whereKeys);
});
});
resolve(whereKeys);
});

return p;
Expand All @@ -98,7 +98,6 @@ var getSelectTemplateKeys = function getSelectTemplateKeys(templatesPath) {
findTemplates(templatesPath).then(function (templatesList) {

findRequestColumns(templatesList).then(function (whereKeys) {

resolve(whereKeys);
}, function () {
console.log('findRequestColumns reject');
Expand Down
121 changes: 57 additions & 64 deletions dist/cli/helpers/abe-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ var Utils = function () {
* @param {String} type textarea | text | meta | link | image | ...
* @param {String} key unique ID, no space allowed
* @param {String} desc input description
* @param {Int} maxLength maximum characteres allowed inside input
* @param {Int} max-length maximum characteres allowed inside input
* @param {String} tab tab name
* @param {String} jsonValue
* @return {Void}
Expand All @@ -90,27 +90,28 @@ var Utils = function () {
key: 'add',
value: function add(obj) {
var defaultValues = {
type: 'text',
key: '',
autocomplete: null,
block: '',
desc: '',
maxLength: null,
tab: 'default',
placeholder: '',
value: '',
source: null,
display: null,
reload: false,
editable: true,
key: '',
'max-length': null,
order: 0,
placeholder: '',
prefill: false,
'prefill-quantity': null,
reload: false,
required: false,
editable: true,
visible: true,
block: ''
source: null,
tab: 'default',
type: 'text',
value: '',
visible: true
};

obj = (0, _extend2.default)(true, defaultValues, obj);
obj.tab = typeof obj.tab !== 'undefined' && obj.tab !== null && obj.tab !== '' ? obj.tab : 'default';

obj.reload = typeof obj.reload !== 'undefined' && obj.reload !== null && obj.reload === 'true' ? true : false, obj.key = obj.key.replace(/\./, '-');
obj.key = obj.key.replace(/\./, '-');

if (obj.key.indexOf('[') < 0 && obj.key.indexOf('.') > -1) {
obj.block = obj.key.split('.')[0];
Expand Down Expand Up @@ -332,18 +333,18 @@ var Utils = function () {
_.Sql.executeQuery(tplPath, match, jsonPage).then(function (data) {
jsonPage[sourceAttr][obj.key] = data;
if (!obj.editable) {
if (obj.maxLength) {
jsonPage[obj.key] = data.slice(0, obj.maxLength);
if (obj['max-length']) {
jsonPage[obj.key] = data.slice(0, obj['max-length']);
} else {
jsonPage[obj.key] = data;
}
} else if (obj.prefill) {
if (obj.prefillQuantity && obj.maxLength) {
jsonPage[obj.key] = data.slice(0, obj.prefillQuantity > obj.maxLength ? obj.maxLength : obj.prefillQuantity);
} else if (obj.prefillQuantity) {
jsonPage[obj.key] = data.slice(0, obj.prefillQuantity);
} else if (obj.maxLength) {
jsonPage[obj.key] = data.slice(0, obj.maxLength);
if (obj['prefill-quantity'] && obj['max-length']) {
jsonPage[obj.key] = data.slice(0, obj['prefill-quantity'] > obj['max-length'] ? obj['max-length'] : obj['prefill-quantity']);
} else if (obj['prefill-quantity']) {
jsonPage[obj.key] = data.slice(0, obj['prefill-quantity']);
} else if (obj['max-length']) {
jsonPage[obj.key] = data.slice(0, obj['max-length']);
} else {
jsonPage[obj.key] = data;
}
Expand Down Expand Up @@ -553,66 +554,58 @@ var Utils = function () {
}, {
key: 'replaceUnwantedChar',
value: function replaceUnwantedChar(str) {
var chars = { '’': '', '\'': '', '\"': '', 'Š': 'S', 'š': 's', 'Ž': 'Z', 'ž': 'z', 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'A', 'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I', 'Î': 'I', 'Ï': 'I', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O', 'Õ': 'O', 'Ö': 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U', 'Ü': 'U', 'Ý': 'Y', 'Þ': 'B', 'ß': 'Ss', 'à': 'a', 'á': 'a', 'â': 'a', 'ã': 'a', 'ä': 'a', 'å': 'a', 'æ': 'a', 'ç': 'c', 'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', 'œ': 'oe', 'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', 'ð': 'o', 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o', 'ö': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 'û': 'u', 'ý': 'y', 'þ': 'b', 'ÿ': 'y' };
var chars = { '’': '', '\'': '', '"': '', 'Š': 'S', 'š': 's', 'Ž': 'Z', 'ž': 'z', 'À': 'A', 'Á': 'A', 'Â': 'A', 'Ã': 'A', 'Ä': 'A', 'Å': 'A', 'Æ': 'A', 'Ç': 'C', 'È': 'E', 'É': 'E', 'Ê': 'E', 'Ë': 'E', 'Ì': 'I', 'Í': 'I', 'Î': 'I', 'Ï': 'I', 'Ñ': 'N', 'Ò': 'O', 'Ó': 'O', 'Ô': 'O', 'Õ': 'O', 'Ö': 'O', 'Ø': 'O', 'Ù': 'U', 'Ú': 'U', 'Û': 'U', 'Ü': 'U', 'Ý': 'Y', 'Þ': 'B', 'ß': 'Ss', 'à': 'a', 'á': 'a', 'â': 'a', 'ã': 'a', 'ä': 'a', 'å': 'a', 'æ': 'a', 'ç': 'c', 'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', 'œ': 'oe', 'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', 'ð': 'o', 'ñ': 'n', 'ò': 'o', 'ó': 'o', 'ô': 'o', 'õ': 'o', 'ö': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 'û': 'u', 'ý': 'y', 'þ': 'b', 'ÿ': 'y' };
for (var prop in chars) {
str = str.replace(new RegExp(prop, 'g'), chars[prop]);
}return str;
}

/**
* Get All attributes from a Abe tag
* @return {Object} parsed attributes
*/

}, {
key: 'getAllAttributes',
value: function getAllAttributes(str, json) {
str = _.Hooks.instance.trigger('beforeAbeAttributes', str, json);

var defaultValues = {
type: 'text',
prefill: false,
prefillQuantity: null,
key: '',
desc: '',
maxLength: null,
tab: 'default',
value: '',
source: null,
//This regex analyzes all attributes of a Abe tag
var re = /\b([a-z][a-z0-9\-]*)\s*=\s*("([^"]+)"|'([^']+)'|(\S+))/ig;
var source = (0, _.getAttr)(str, 'source');
var key = (0, _.getAttr)(str, 'key');

var attrs = {
autocomplete: null,
desc: '',
display: null,
reload: false,
editable: true,
key: '',
'max-length': null,
'min-length': 0,
order: 0,
prefill: false,
'prefill-quantity': null,
reload: false,
required: false,
editable: true,
source: null,
tab: 'default',
type: 'text',
value: '',
visible: true
};

var source = (0, _.getAttr)(str, 'source');
var key = (0, _.getAttr)(str, 'key');

var obj = {
type: (0, _.getAttr)(str, 'type'),
key: key,
prefill: (0, _.getAttr)(str, 'prefill'),
prefillQuantity: (0, _.getAttr)(str, 'prefill-quantity'),
desc: (0, _.getAttr)(str, 'desc'),
autocomplete: (0, _.getAttr)(str, 'autocomplete'),
maxLength: (0, _.getAttr)(str, 'max-length'),
value: json[key],
tab: (0, _.getAttr)(str, 'tab'),
sourceString: typeof source !== 'undefined' && source !== null && source !== '' ? source : null,
source: typeof source !== 'undefined' && source !== null && source !== '' ? typeof json[_.config.source.name] !== 'undefined' && json[_.config.source.name] !== null && json[_.config.source.name] !== '' ? json[_.config.source.name][key] : null : null,
display: (0, _.getAttr)(str, 'display'),
reload: (0, _.getAttr)(str, 'reload'),
order: (0, _.getAttr)(str, 'order'),
required: (0, _.getAttr)(str, 'required'),
visible: (0, _.getAttr)(str, 'visible'),
editable: (0, _.getAttr)(str, 'editable')
};
obj = (0, _extend2.default)(true, defaultValues, obj);
for (var match; match = re.exec(str);) {
attrs[match[1]] = match[3] || match[4] || match[5];
}

obj.editable = typeof obj.editable === 'undefined' || obj.editable === null || obj.editable === '' || obj.editable === 'false' ? false : true;
obj.prefill = typeof obj.prefill !== 'undefined' && obj.prefill !== null && obj.prefill === 'true' ? true : false;
obj.prefillQuantity = typeof obj.prefillQuantity !== 'undefined' && obj.prefillQuantity !== null && obj.prefillQuantity !== '' ? obj.prefillQuantity : false;
attrs.sourceString = attrs.source;
attrs.source = typeof source !== 'undefined' && source !== null && source !== '' ? typeof json[_.config.source.name] !== 'undefined' && json[_.config.source.name] !== null && json[_.config.source.name] !== '' ? json[_.config.source.name][key] : null : null;
attrs.editable = typeof attrs.editable === 'undefined' || attrs.editable === null || attrs.editable === '' || attrs.editable === 'false' ? false : true;

obj = _.Hooks.instance.trigger('afterAbeAttributes', obj, str, json);
attrs = _.Hooks.instance.trigger('afterAbeAttributes', attrs, str, json);

return obj;
return attrs;
}
}]);

Expand Down
Loading

0 comments on commit 7620186

Please sign in to comment.