Skip to content

Commit

Permalink
reset master (without refactor select)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Sep 21, 2016
1 parent a0a74eb commit eb32bc7
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 32 deletions.
6 changes: 3 additions & 3 deletions dist/cli/handlebars/abe/compileAbe.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ function compileAbe() {
var hash = arguments[0].hash;
hash.key = hash.key.replace(/\{\{@index\}\}/, '[{{@index}}]');
var value = content ? content[hash['dictionnary']][arguments[0].data.index][key] : hash.key;
if (typeof value === 'undefined' || typeof value === 'function' || value === null) {
value = '';
}
if (typeof hash.type !== 'undefined' && hash.type !== null && hash.type === 'rich') {
var testXSS = (0, _xss2.default)(value.replace(/"/g, '"'), {
"whiteList": _.config.htmlWhiteList,
stripIgnoreTag: true
});
return new _handlebars2.default.SafeString(testXSS);
}
if (typeof value === 'undefined' || typeof value === 'function' || value === null) {
value = '';
}
return value.replace(/%27/, "'");
}

Expand Down
8 changes: 4 additions & 4 deletions dist/cli/helpers/abe-create.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ var _cli = require('../../cli');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var create = function create(template, path, name, req) {
var create = function create(template, pathCreate, name, req) {
var forceJson = arguments.length <= 4 || arguments[4] === undefined ? {} : arguments[4];
var duplicate = arguments.length <= 5 || arguments[5] === undefined ? false : arguments[5];

var p = new Promise(function (resolve, reject) {
_cli.Hooks.instance.trigger('beforeCreate', template, path, name, req, forceJson);
_cli.Hooks.instance.trigger('beforeCreate', template, pathCreate, name, req, forceJson);

var templatePath = _cli.fileUtils.getTemplatePath(template.replace(_cli.config.root, ""));
var filePath = path.join(path, name);
var filePath = _path2.default.join(pathCreate, name);
filePath = (0, _cli.cleanSlug)(filePath);
filePath = _cli.fileUtils.getFilePath(filePath);

Expand All @@ -40,7 +40,7 @@ var create = function create(template, path, name, req) {
json = resHook.json;
text = resHook.text;

_cli.Hooks.instance.trigger('afterCreate', json, text, path, name, req, forceJson);
_cli.Hooks.instance.trigger('afterCreate', json, text, pathCreate, name, req, forceJson);
(0, _cli.save)(filePath, req.query.selectTemplate, json, text, 'draft', null, 'draft').then(function (resSave) {
_cli.Manager.instance.updateList();
filePath = resSave.htmlPath;
Expand Down
12 changes: 6 additions & 6 deletions dist/cli/helpers/abe-duplicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ var _cli = require('../../cli');

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var duplicate = function duplicate(oldFilePath, template, path, name, req) {
var duplicate = function duplicate(oldFilePath, template, newPath, name, req) {
var isUpdate = arguments.length <= 5 || arguments[5] === undefined ? false : arguments[5];

var p = new Promise(function (resolve, reject) {
_cli.Hooks.instance.trigger('beforeDuplicate', oldFilePath, template, path, name, req, isUpdate);
_cli.Hooks.instance.trigger('beforeDuplicate', oldFilePath, template, newPath, name, req, isUpdate);

if (typeof oldFilePath !== 'undefined' && oldFilePath !== null) {
var url = path.join(_cli.config.root, _cli.config.draft.url, oldFilePath);
var url = _path2.default.join(_cli.config.root, _cli.config.draft.url, oldFilePath);
var revisions = [];

if (!_cli.fileAttr.test(url)) {
Expand All @@ -45,16 +45,16 @@ var duplicate = function duplicate(oldFilePath, template, path, name, req) {
}

if (isUpdate) {
_cli.Hooks.instance.trigger('beforeUpdate', json, oldFilePath, template, path, name, req, isUpdate);
_cli.Hooks.instance.trigger('beforeUpdate', json, oldFilePath, template, newPath, name, req, isUpdate);
Array.prototype.forEach.call(revisions, function (revision) {
if (typeof revision.path !== 'undefined' && revision.path !== null) {
_cli.FileParser.deleteFile(revision.path);
}
});
}
_cli.Hooks.instance.trigger('afterDuplicate', json, oldFilePath, template, path, name, req, isUpdate);
_cli.Hooks.instance.trigger('afterDuplicate', json, oldFilePath, template, newPath, name, req, isUpdate);

var pCreate = (0, _cli.abeCreate)(template, path, name, req, json, isUpdate ? false : true);
var pCreate = (0, _cli.abeCreate)(template, newPath, name, req, json, isUpdate ? false : true);
pCreate.then(function (resSave) {
resolve(resSave);
}, function () {
Expand Down
4 changes: 3 additions & 1 deletion dist/cli/helpers/file-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,11 @@ var FileParser = function () {
var structure = _.config.structure.url;
var templates = _.config.templates.url;

if (_.folderUtils.isFolder(_path2.default.join(site.path, structure)) && _.folderUtils.isFolder(_path2.default.join(site.path, templates))) {
if (_.folderUtils.isFolder(_path2.default.join(site.path, structure))) {
site.folders = FileParser.getFolders(_path2.default.join(site.path, structure), false);
result.structure = site.folders;
}
if (_.folderUtils.isFolder(_path2.default.join(site.path, templates))) {
result.templates = result.templates.concat(FileParser.getFiles(_path2.default.join(site.path, templates), true, 10, new RegExp('.' + _.config.files.templates.extension)));
}

Expand Down
16 changes: 9 additions & 7 deletions dist/server/routes/post-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ var route = function route(req, res, next) {
file.fileRead.push(chunk);
});

if (mimetype !== 'image/jpeg' && mimetype !== 'image/png' && mimetype !== 'image/svg+xml') {
if (mimetype !== 'image/jpeg' && mimetype !== 'image/png' && mimetype !== 'image/svg+xml' && mimetype !== 'video/mp4') {
returnErr('unauthorized file');
} else if (ext !== 'jpg' && ext !== 'jpeg' && ext !== 'png' && ext !== 'svg') {
returnErr('not an image');
} else if (ext !== 'jpg' && ext !== 'jpeg' && ext !== 'png' && ext !== 'svg' && ext !== 'mp4') {
returnErr('not an valid asset');
}

file.on('end', function () {
Expand All @@ -74,8 +74,8 @@ var route = function route(req, res, next) {
var sfStat = _fsExtra2.default.statSync(filePath);

if (sfStat) {
var nb = filePath.match(/_([0-9]).(jpg|png|gif|svg)/);
if (nb && nb[1]) filePath = filePath.replace(/_([0-9])\.(jpg|png|gif|svg)/, '_' + (parseInt(nb[1]) + 1) + '.$2');else filePath = filePath.replace(/\.(jpg|png|gif|svg)/, '_1.$1');
var nb = filePath.match(/_([0-9]).(jpg|png|gif|svg|mp4)/);
if (nb && nb[1]) filePath = filePath.replace(/_([0-9])\.(jpg|png|gif|svg|mp4)/, '_' + (parseInt(nb[1]) + 1) + '.$2');else filePath = filePath.replace(/\.(jpg|png|gif|svg|mp4)/, '_1.$1');
createImage();
}
} catch (e) {
Expand Down Expand Up @@ -106,10 +106,12 @@ var route = function route(req, res, next) {
var openFile = _fsExtra2.default.readFileSync(filePath).toString();
if (openFile === '') throw new Error('');
clearInterval(interval);
resp = _cli.Hooks.instance.trigger('afterSaveImage', resp, req);
if (/\.(jpg|png|gif|svg)/.test(filePath)) resp = _cli.Hooks.instance.trigger('afterSaveImage', resp, req);
res.set('Content-Type', 'application/json');
res.send(JSON.stringify(resp));
} catch (e) {}
} catch (e) {
console.log('post upload finish', e);
}
};
tryUpload();
});
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": "abe-cli",
"version": "2.3.12",
"version": "2.3.14",
"description": "Abe command line tool",
"main": "src/server/app.js",
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions src/cli/handlebars/abe/compileAbe.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ export default function compileAbe(){
var hash = arguments[0].hash
hash.key = hash.key.replace(/\{\{@index\}\}/, '[{{@index}}]')
var value = ((content) ? content[hash['dictionnary']][arguments[0].data.index][key] : hash.key)
if(typeof value === 'undefined' || typeof value === 'function' || value === null) {
value = ''
}
if(typeof hash.type !== 'undefined' && hash.type !== null && hash.type === 'rich'){
var testXSS = xss(value.replace(/&quot;/g, '"'), {
"whiteList": config.htmlWhiteList,
stripIgnoreTag: true
})
return new Handlebars.SafeString(testXSS)
}
if(typeof value === 'undefined' || typeof value === 'function' || value === null) {
value = ''
}
return value.replace(/%27/, "'")
}

Expand Down
14 changes: 7 additions & 7 deletions src/server/routes/post-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ var route = function(req, res, next){
file.fileRead.push(chunk)
});

if (mimetype !== 'image/jpeg' && mimetype !== 'image/png' && mimetype !== 'image/svg+xml') {
if (mimetype !== 'image/jpeg' && mimetype !== 'image/png' && mimetype !== 'image/svg+xml' && mimetype !== 'video/mp4') {
returnErr('unauthorized file')
} else if (ext !== 'jpg' && ext !== 'jpeg' && ext !== 'png' && ext !== 'svg') {
returnErr('not an image')
} else if (ext !== 'jpg' && ext !== 'jpeg' && ext !== 'png' && ext !== 'svg' && ext !== 'mp4') {
returnErr('not an valid asset')
}

file.on('end', function() {
Expand All @@ -63,9 +63,9 @@ var route = function(req, res, next){
var sfStat = fse.statSync(filePath)

if(sfStat){
var nb = filePath.match(/_([0-9]).(jpg|png|gif|svg)/)
if(nb && nb[1]) filePath = filePath.replace(/_([0-9])\.(jpg|png|gif|svg)/, `_${parseInt(nb[1]) + 1}.$2`)
else filePath = filePath.replace(/\.(jpg|png|gif|svg)/, `_1.$1`)
var nb = filePath.match(/_([0-9]).(jpg|png|gif|svg|mp4)/)
if(nb && nb[1]) filePath = filePath.replace(/_([0-9])\.(jpg|png|gif|svg|mp4)/, `_${parseInt(nb[1]) + 1}.$2`)
else filePath = filePath.replace(/\.(jpg|png|gif|svg|mp4)/, `_1.$1`)
createImage()
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ var route = function(req, res, next){
var openFile = fse.readFileSync(filePath).toString()
if(openFile === '') throw new Error('')
clearInterval(interval)
resp = Hooks.instance.trigger('afterSaveImage', resp, req)
if(/\.(jpg|png|gif|svg)/.test(filePath)) resp = Hooks.instance.trigger('afterSaveImage', resp, req)
res.set('Content-Type', 'application/json')
res.send(JSON.stringify(resp))
}
Expand Down

0 comments on commit eb32bc7

Please sign in to comment.