Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/AdFabConnect/abejs
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Sep 26, 2016
2 parents 8718b0d + 3e946aa commit 556c22e
Show file tree
Hide file tree
Showing 70 changed files with 3,945 additions and 3,921 deletions.
8 changes: 0 additions & 8 deletions dist/cli/Builder.js
Expand Up @@ -4,14 +4,6 @@ var _fsExtra = require('fs-extra');

var _fsExtra2 = _interopRequireDefault(_fsExtra);

var _extend = require('extend');

var _extend2 = _interopRequireDefault(_extend);

var _mkdirp = require('mkdirp');

var _mkdirp2 = _interopRequireDefault(_mkdirp);

var _Save = require('./controllers/Save');

var _path = require('path');
Expand Down
76 changes: 38 additions & 38 deletions dist/cli/Create.js
@@ -1,7 +1,7 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
Expand All @@ -27,43 +27,43 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

var Create = function () {
function Create() {
_classCallCheck(this, Create);
}

_createClass(Create, [{
key: 'init',
value: function init(path) {
var _this = this;

path = path.split('/');
path[path.length - 1] = (0, _slugify2.default)(path[path.length - 1]);
path = path.join('/');
this.addFolder(path).then(function () {
process.chdir(path);
_this.addFolder(_.config.publish.url);
_this.addFolder(_.config.templates.url);
_this.addFolder(_.config.structure.url);
_this.addFolder(_.config.reference.url);
_this.addFolder(_.config.data.url);
_this.addFolder(_.config.draft.url);
}).catch(function (e) {
console.error(e);
});
}
}, {
key: 'addFolder',
value: function addFolder(folder) {
var p = new _es6Promise.Promise(function (resolve, reject) {
(0, _mkdirp2.default)(folder);
resolve();
});

return p;
}
}]);

return Create;
function Create() {
_classCallCheck(this, Create);
}

_createClass(Create, [{
key: 'init',
value: function init(path) {
var _this = this;

path = path.split('/');
path[path.length - 1] = (0, _slugify2.default)(path[path.length - 1]);
path = path.join('/');
this.addFolder(path).then(function () {
process.chdir(path);
_this.addFolder(_.config.publish.url);
_this.addFolder(_.config.templates.url);
_this.addFolder(_.config.structure.url);
_this.addFolder(_.config.reference.url);
_this.addFolder(_.config.data.url);
_this.addFolder(_.config.draft.url);
}).catch(function (e) {
console.error(e);
});
}
}, {
key: 'addFolder',
value: function addFolder(folder) {
var p = new _es6Promise.Promise(function (resolve, reject) {
(0, _mkdirp2.default)(folder);
resolve();
});

return p;
}
}]);

return Create;
}();

exports.default = Create;
42 changes: 21 additions & 21 deletions dist/cli/config/abe-config.js
Expand Up @@ -46,27 +46,27 @@ var config = {
},
security: true,
htmlWhiteList: {
"blockquote": ["style"],
"span": ["style"],
"font": ["style", "color"],
"div": ["style"],
"sup": ["style"],
"sub": ["style"],
"ul": ["style"],
"li": ["style"],
"p": ["style"],
"b": ["style"],
"strong": ["style"],
"i": ["style"],
"u": ["style"],
"a": ["style", "href"],
"br": [],
"h1": ["style"],
"h2": ["style"],
"h3": ["style"],
"h4": ["style"],
"pre": ["style"],
"code": ["style"]
'blockquote': ['style'],
'span': ['style'],
'font': ['style', 'color'],
'div': ['style'],
'sup': ['style'],
'sub': ['style'],
'ul': ['style'],
'li': ['style'],
'p': ['style'],
'b': ['style'],
'strong': ['style'],
'i': ['style'],
'u': ['style'],
'a': ['style', 'href'],
'br': [],
'h1': ['style'],
'h2': ['style'],
'h3': ['style'],
'h4': ['style'],
'pre': ['style'],
'code': ['style']
},
files: {
exclude: /^[.]/,
Expand Down
13 changes: 2 additions & 11 deletions dist/cli/controllers/Save.js
Expand Up @@ -64,7 +64,7 @@ function checkRequired(text, json) {
} else {
complete++;
}
} else {}
}
}
}
});
Expand Down Expand Up @@ -197,12 +197,6 @@ function save(url, tplPath) {
return p;
}

function splitArray(ar, chunkSize) {
return [].concat.apply([], ar.map(function (elem, i) {
return i % chunkSize ? [] : [ar.slice(i, i + chunkSize)];
}));
}

function saveJsonAndHtml(templateId, obj, html) {
var page = new _.Page(templateId, html, obj.json.content, true);

Expand All @@ -226,7 +220,7 @@ function saveJson(url, json) {

var eachRecursive = function eachRecursive(obj) {
for (var k in obj) {
if (_typeof(obj[k]) === "object" && obj[k] !== null) eachRecursive(obj[k]);else if (typeof obj[k] !== "undefined" && obj[k] !== null) obj[k] = (0, _xss2.default)(obj[k].toString().replace(/&quot;/g, '"'), { "whiteList": _.config.htmlWhiteList });
if (_typeof(obj[k]) === 'object' && obj[k] !== null) eachRecursive(obj[k]);else if (typeof obj[k] !== 'undefined' && obj[k] !== null) obj[k] = (0, _xss2.default)(obj[k].toString().replace(/&quot;/g, '"'), { 'whiteList': _.config.htmlWhiteList });
}
};

Expand All @@ -253,11 +247,8 @@ function dateIso(tplUrl) {

var newDateISO;
var dateISO;
var validate;

var saveJsonFile = tplUrl.json.path;
var saveFile = tplUrl['draft'].path;
var oldDateISO = _.fileAttr.get(saveFile).d;

switch (type) {
case 'draft':
Expand Down
8 changes: 4 additions & 4 deletions dist/cli/handlebars/abe/abeEngine.js
@@ -1,4 +1,4 @@
"use strict";
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
Expand All @@ -15,20 +15,20 @@ var abeEngine = function () {
function abeEngine(enforcer) {
_classCallCheck(this, abeEngine);

if (enforcer != singletonEnforcer) throw "Cannot construct Json singleton";
if (enforcer != singletonEnforcer) throw 'Cannot construct Json singleton';
this._content = {};
}

_createClass(abeEngine, [{
key: "content",
key: 'content',
get: function get() {
return this._content;
},
set: function set(content) {
this._content = content;
}
}], [{
key: "instance",
key: 'instance',
get: function get() {
if (!this[singleton]) {
this[singleton] = new abeEngine(singletonEnforcer);
Expand Down
4 changes: 2 additions & 2 deletions dist/cli/handlebars/abe/abeImport.js
Expand Up @@ -26,8 +26,8 @@ function abeImport(file, config, ctx) {

var config = JSON.parse(config);
var intlData = config.intlData;
var defaultPartials = __dirname.replace(/\/$/, "") + '/' + config.defaultPartials.replace(/\/$/, "");
var custom = config.custom !== '' ? config.root.replace(/\/$/, "") + '/' + config.custom.replace(/\/$/, "") : defaultPartials;
var defaultPartials = __dirname.replace(/\/$/, '') + '/' + config.defaultPartials.replace(/\/$/, '');
var custom = config.custom !== '' ? config.root.replace(/\/$/, '') + '/' + config.custom.replace(/\/$/, '') : defaultPartials;
var pathToPartial = custom + '/' + file + '.html';
try {
var stat = _fsExtra2.default.statSync(pathToPartial);
Expand Down
8 changes: 4 additions & 4 deletions dist/cli/handlebars/abe/compileAbe.js
Expand Up @@ -44,12 +44,12 @@ function compileAbe() {
}
if (typeof hash.type !== 'undefined' && hash.type !== null && hash.type === 'rich') {
var testXSS = (0, _xss2.default)(value.replace(/&quot;/g, '"'), {
"whiteList": _.config.htmlWhiteList,
'whiteList': _.config.htmlWhiteList,
stripIgnoreTag: true
});
return new _handlebars2.default.SafeString(testXSS);
}
return value.replace(/%27/, "'");
return value.replace(/%27/, '\'');
}

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

if (typeof hash.type !== 'undefined' && hash.type !== null && hash.type === 'rich') {
var testXSS = (0, _xss2.default)(value.replace(/&quot;/g, '"'), {
"whiteList": _.config.htmlWhiteList,
'whiteList': _.config.htmlWhiteList,
stripIgnoreTag: true
});
return new _handlebars2.default.SafeString(testXSS);
}
return value.replace(/%27/, "'");
return value.replace(/%27/, '\'');
}
20 changes: 10 additions & 10 deletions dist/cli/handlebars/abe/folders.js
@@ -1,7 +1,7 @@
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = folders;

Expand All @@ -12,13 +12,13 @@ var _recursiveFolder2 = _interopRequireDefault(_recursiveFolder);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function folders(obj, index, link) {
var res;
if (typeof link !== 'undefined' && link !== null && link !== 'null') {
var links = link.replace(/^\//, '').split('/');
links.pop();
res = (0, _recursiveFolder2.default)(obj, 1, '', links);
} else {
res = (0, _recursiveFolder2.default)(obj, 1);
}
return res;
var res;
if (typeof link !== 'undefined' && link !== null && link !== 'null') {
var links = link.replace(/^\//, '').split('/');
links.pop();
res = (0, _recursiveFolder2.default)(obj, 1, '', links);
} else {
res = (0, _recursiveFolder2.default)(obj, 1);
}
return res;
}
12 changes: 8 additions & 4 deletions dist/cli/handlebars/abe/listPage.js
Expand Up @@ -46,17 +46,21 @@ function listPage(file, index, text) {
var workflow = '';

workflow += '<td align="center" class="draft">';
if (typeof file.publish === "undefined" || file.publish === null || file.publish && file.draft && file.publish.date < file.draft.date) {
workflow += '<a href="/abe/' + file.abe_meta.template + '?filePath=' + file.draft.html + '" class="label label-default label-draft">draft</a>';
if (typeof file.draft !== 'undefined' && file.draft !== null) {
if (typeof file.publish === 'undefined' || file.publish === null || file.publish && file.publish.date < file.draft.date) {
workflow += '<a href="/abe/' + file.abe_meta.template + '?filePath=' + file.draft.html + '" class="label label-default label-draft">draft</a>';
} else {
workflow += '<a href="/abe/' + file.abe_meta.template + '?filePath=' + file.draft.html + '" class="hidden label label-default label-draft">draft</a>';
}
} else {
workflow += '<a href="/abe/' + file.abe_meta.template + '?filePath=' + file.draft.html + '" class="hidden label label-default label-draft">draft</a>';
workflow += '<a href="/abe/' + file.abe_meta.template + '?filePath=' + file.abe_meta.link + '" class="hidden label label-default label-draft">draft</a>';
}

workflow += '</td>';
workflow += '<td align="center" class="publish">';

if (file.publish) {
workflow += '<a href="/abe/' + file.abe_meta.template + '?filePath=' + file.abe_meta.link + '" class="checkmark label-published">&#10004;</a>';
workflow += '<a href="/abe/' + file.abe_meta.template + '?filePath=' + file.publish.html + '" class="checkmark label-published">&#10004;</a>';
}
workflow += '</td>';

Expand Down
10 changes: 5 additions & 5 deletions dist/cli/handlebars/abe/printInput.js
Expand Up @@ -86,17 +86,17 @@ function printInput() {

res += '</select>';
}
} else if (params.type.indexOf("rich") >= 0) {
} 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 + '"';

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) {
} else if (params.type.indexOf('file') >= 0) {
res += '<input class="form-control" ' + commonParams + ' name="' + params.key + '" type="file" />\n <span class="percent"></span>\n <input type="text" ' + commonParams + ' class="' + inputClass + ' hidden" />';
} else if (params.type.indexOf("textarea") >= 0) {
} else if (params.type.indexOf('textarea') >= 0) {
res += '<textarea class="' + inputClass + '" ' + commonParams + ' rows="4">' + params.value + '</textarea>';
} else if (params.type.indexOf("link") >= 0) {
} else if (params.type.indexOf('link') >= 0) {
res += '<div class="input-group">\n <div class="input-group-addon link">\n <span class="glyphicon glyphicon-link" aria-hidden="true"></span>\n </div>\n <input type="text" ' + commonParams + ' class="' + inputClass + '" />\n </div>';
} else if (params.type.indexOf("image") >= 0) {
} else if (params.type.indexOf('image') >= 0) {
res += '<div class="input-group img-upload">\n <div class="input-group-addon image">\n <span class="glyphicon glyphicon-picture" aria-hidden="true"></span>\n </div>\n <input type="text" ' + commonParams + ' class="' + inputClass + ' image-input" />\n <div class="upload-wrapper">\n <input class="form-control" ' + commonParams + ' name="' + params.key + '" type="file" title="upload an image"/>\n <span class="percent">\n <span class="glyphicon glyphicon-upload" aria-hidden="true"></span>\n </span>\n </div>\n </div>\n <div class="input-error"></div>';
} else {
res += '<div class="input-group">\n <div class="input-group-addon">\n <span class="glyphicon glyphicon-font" aria-hidden="true"></span>\n </div>\n <input type="text" ' + commonParams + ' class="' + inputClass + '" />\n </div>';
Expand Down
2 changes: 1 addition & 1 deletion dist/cli/handlebars/abe/sourceAttr.js
Expand Up @@ -15,7 +15,7 @@ function sourceAttr(val, params) {
var selected = '';

if ((typeof hiddenVal === 'undefined' ? 'undefined' : _typeof(hiddenVal)) === 'object' && Object.prototype.toString.call(hiddenVal) === '[object Object]') {
hiddenVal = JSON.stringify(hiddenVal).replace(/'/g, "&apos;");
hiddenVal = JSON.stringify(hiddenVal).replace(/'/g, '&apos;');

try {
var displayVal = eval('val.' + params.display);
Expand Down
22 changes: 11 additions & 11 deletions dist/cli/handlebars/utils/math.js
@@ -1,18 +1,18 @@
"use strict";
'use strict';

Object.defineProperty(exports, "__esModule", {
value: true
value: true
});
exports.default = math;
function math(lvalue, operator, rvalue, options) {
lvalue = parseFloat(lvalue);
rvalue = parseFloat(rvalue);
lvalue = parseFloat(lvalue);
rvalue = parseFloat(rvalue);

return {
"+": lvalue + rvalue,
"-": lvalue - rvalue,
"*": lvalue * rvalue,
"/": lvalue / rvalue,
"%": lvalue % rvalue
}[operator];
return {
'+': lvalue + rvalue,
'-': lvalue - rvalue,
'*': lvalue * rvalue,
'/': lvalue / rvalue,
'%': lvalue % rvalue
}[operator];
}

0 comments on commit 556c22e

Please sign in to comment.