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
# Conflicts:
#	dist/server/public/scripts/template-engine-compiled.js
  • Loading branch information
wonknu committed Aug 16, 2016
2 parents d6ec4b7 + b1782a5 commit 28321fe
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 158 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<<<<<<< HEAD
# Abe, A better engine

> Abe is your __static websites generator__ with revolutionnary __self-descriptive__ templates
Expand Down Expand Up @@ -257,4 +256,3 @@ Other environment variables are available (like PORT for defining a listening po

=======
# abe-test-plugin
>>>>>>> e23f4a0d4369f09cb9263d29673c21dfb5331de6
75 changes: 0 additions & 75 deletions dist/cli/controllers/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ var Page = function () {
}
}
Array.prototype.forEach.call(matches, function (match) {
text = _this._abeFunc(text, match);
if (!_this._onlyHTML) {
var getattr = (0, _.getAttr)(match, 'key').replace(/\./g, '-');
text = text.replace((0, _.escapeTextToRegex)(match, 'g'), ' data-abe-' + util.validDataAbe(getattr) + '="' + getattr + '" ' + match);
Expand Down Expand Up @@ -340,41 +339,6 @@ var Page = function () {

return text;
}

/**
* add handlebar {{if variable empty}} state if onlyHTML or "data-if-empty-clear" attribute
*
* @param {String} text html
* @param {String} key abe
* @param {String} tag name
* @param {String} match regex string to match
* @param {Boolean} onlyHTML boolean for generated html or browser
* @return {String} new text with if or data attributes
*/

}, {
key: '_abeClear',
value: function _abeClear(text, key, tag, match) {
var _this2 = this;

var hideTagRegex;
var hideHtmls = (0, _.getEnclosingTags)(text, match, tag);

Array.prototype.forEach.call(hideHtmls, function (hideHtml) {
if (_this2._onlyHTML) {
hideTagRegex = (0, _.escapeTextToRegex)(hideHtml, 'gm');
text = text.replace(hideTagRegex, '{{#if ' + key + '}}' + hideHtml + '{{/if}}');
} else {
var firstTag = /(<[^\s>]+)/.exec(hideHtml);
firstTag = firstTag[0];

var hideHtmlWithAttr = hideHtml.replace(firstTag, firstTag + ' data-if-empty-clear="' + key + '"');
text = text.replace((0, _.escapeTextToRegex)(hideHtml, 'g'), hideHtmlWithAttr);
}
});

return text;
}
}, {
key: '_addSource',
value: function _addSource(text, json) {
Expand Down Expand Up @@ -409,45 +373,6 @@ var Page = function () {
json = _.Hooks.instance.trigger('afterAddSourcePage', json, match[0]);
}
}

/**
* check if abe tag own a custom attribute
*
* @param {String} text html
* @param {String} tag name
* @param {String} match regex string to match
* @return {String} new text with if or data attributes
*
* for example :
*
* {{abe type="" if-empty="clear(something)"}}
*
* will call methode abeClear on this tag
*/

}, {
key: '_abeFunc',
value: function _abeFunc(text, match) {
var ifEmpty = (0, _.getAttr)(match, 'if-empty');
var key = (0, _.getAttr)(match, 'key');

if (ifEmpty !== '') {
var tag = /\(([^)]+)\)/g.exec(ifEmpty);
var func = /([^)]+)\(/g.exec(ifEmpty);

if (typeof func[1] !== 'undefined' && func[1] !== null) {
switch (func[1]) {
case 'clear':
if (typeof tag[1] !== 'undefined' && tag[1] !== null) {
text = this._abeClear(text, key, tag[1], match);
}
break;
}
}
}

return text;
}
}]);

return Page;
Expand Down
4 changes: 3 additions & 1 deletion dist/cli/handlebars/abe/listPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ function listPage(file, index, text) {
}

if (file.date) {
res += '<td align="center">\n ' + (0, _moment2.default)(file.date).format('YYYY-MM-DD') + '\n </td>';
var dateSearch = (0, _moment2.default)(file.date).format('YYYY-MM-DD');
var dateOrder = new Date(file.date).getTime();
res += '<td align="center" data-search="' + dateSearch + '" data-order="' + dateOrder + '">\n ' + dateSearch + '\n </td>';
}

var workflow = '';
Expand Down
7 changes: 6 additions & 1 deletion dist/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.compileAbe = exports.dateUnslug = exports.dateSlug = exports.saveJson = exports.checkRequired = exports.Locales = exports.Plugins = exports.Hooks = exports.save = exports.Page = exports.removeDuplicateAttr = exports.log = exports.getTemplate = exports.cli = exports.config = exports.escapeTextToRegex = exports.getEnclosingTags = exports.getAttr = exports.ifCond = exports.ifIn = exports.printConfig = exports.cleanTab = exports.folders = exports.attrAbe = exports.abeEngine = exports.listPage = exports.moduloIf = exports.className = exports.printJson = exports.notEmpty = exports.printBlock = exports.translate = exports.abeProcess = exports.Sql = exports.Create = exports.testObj = exports.math = exports.abeImport = exports.printInput = exports.fileUtils = exports.folderUtils = exports.FileParser = exports.cleanSlug = exports.slugify = exports.abeDuplicate = exports.deep_value = exports.abeCreate = exports.Util = exports.Handlebars = exports.fse = exports.moment = exports.fileAttr = undefined;
exports.compileAbe = exports.dateUnslug = exports.dateSlug = exports.saveJson = exports.checkRequired = exports.Locales = exports.Plugins = exports.Hooks = exports.save = exports.Page = exports.removeDuplicateAttr = exports.log = exports.getTemplate = exports.cli = exports.config = exports.escapeTextToRegex = exports.getEnclosingTags = exports.getAttr = exports.ifCond = exports.ifIn = exports.printConfig = exports.cleanTab = exports.folders = exports.attrAbe = exports.abeEngine = exports.listPage = exports.moduloIf = exports.className = exports.printJson = exports.notEmpty = exports.printBlock = exports.translate = exports.abeProcess = exports.Sql = exports.Create = exports.testObj = exports.math = exports.abeImport = exports.printInput = exports.fileUtils = exports.folderUtils = exports.FileParser = exports.cleanSlug = exports.slugify = exports.abeDuplicate = exports.deep_value = exports.abeCreate = exports.Util = exports.clc = exports.Handlebars = exports.fse = exports.moment = exports.fileAttr = undefined;

var _fileAttr = require('./helpers/file-attr');

Expand All @@ -25,6 +25,10 @@ var _fsExtra = require('fs-extra');

var _fsExtra2 = _interopRequireDefault(_fsExtra);

var _cliColor = require('cli-color');

var _cliColor2 = _interopRequireDefault(_cliColor);

var _index = require('./handlebars/index');

var _handlebars = require('handlebars');
Expand Down Expand Up @@ -117,6 +121,7 @@ exports.fileAttr = _fileAttr2.default;
exports.moment = _moment2.default;
exports.fse = _fsExtra2.default;
exports.Handlebars = _handlebars2.default;
exports.clc = _cliColor2.default;
exports.Util = _abeUtils2.default;
exports.abeCreate = _abeCreate2.default;
exports.deep_value = _abeDeepVal2.default;
Expand Down
2 changes: 1 addition & 1 deletion dist/server/public/scripts/modules/EditorJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ var Json = function () {
return;
}
if (typeof jsonRes.reject !== 'undefined' && jsonRes.reject !== null) {
window.location.href = window.location.origin + window.location.pathname + '?filePath=' + jsonRes.reject;
location.reload();
return;
}
_this.data = jsonRes.json;
Expand Down
5 changes: 3 additions & 2 deletions dist/server/public/scripts/modules/EditorSave.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@ var EditorSave = function () {
var ext = filePathParam.split('.');
ext = ext[ext.length - 1];
filePathParam = filePathParam.replace(new RegExp('-abe-(.+?)(?=\.' + ext + ')'), '');
var reloadUrl = top.location.protocol + '//' + window.location.host + window.location.pathname + tplNameParam + filePathParam;
var reloadUrl = top.location.protocol + '//' + window.location.host + window.location.pathname + tplNameParam + filePathParam + top.location.hash;

target.classList.remove('loading');
target.classList.remove('done');
target.removeAttribute('disabled');
if (result.success === 1) window.location.href = reloadUrl;

if (result.success === 1) location.reload();
}).catch(function (e) {
console.error(e);
});
Expand Down
Loading

0 comments on commit 28321fe

Please sign in to comment.