Skip to content

Commit

Permalink
VERSION 2.14.5
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Jan 25, 2017
1 parent 0f2aff8 commit 6532d3b
Show file tree
Hide file tree
Showing 109 changed files with 26,972 additions and 1,176 deletions.
1,861 changes: 931 additions & 930 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 AdFab Connect
Copyright (c) 2015 Gregory Besson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
34 changes: 17 additions & 17 deletions README.md
@@ -1,23 +1,23 @@
[![Develop Branch Build Status](https://travis-ci.org/AdFabConnect/abejs.svg)](https://travis-ci.org/AdFabConnect/abejs)
[![Build status](https://ci.appveyor.com/api/projects/status/dv6yt84497wseuxc?svg=true)](https://ci.appveyor.com/project/gregorybesson/abejs)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/AdFabConnect/abejs/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/AdFabConnect/abejs/)
[![Coverage Status](https://coveralls.io/repos/github/AdFabConnect/abejs/badge.svg?branch=master)](https://coveralls.io/github/AdFabConnect/abejs?branch=master)
[![Dependency Status](https://www.versioneye.com/user/projects/57ea4badbd6fa600316f9f6c/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/57ea4badbd6fa600316f9f6c)
[![Inline docs](http://inch-ci.org/github/adfabconnect/abejs.svg?branch=master)](http://inch-ci.org/github/adfabconnect/abejs)
[![Latest Stable Version](https://img.shields.io/npm/v/abe-cli.svg)](https://www.npmjs.com/package/abe-cli)
[![Total Downloads](https://img.shields.io/npm/dt/abe-cli.svg)](https://www.npmjs.com/package/abe-cli)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/AdFabConnect/abejs/master/LICENSE)
[![Develop Branch Build Status](https://travis-ci.org/abecms/abecms.svg)](https://travis-ci.org/abecms/abecms)
[![Build status](https://ci.appveyor.com/api/projects/status/dv6yt84497wseuxc?svg=true)](https://ci.appveyor.com/project/gregorybesson/abecms)
[![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/abecms/abecms/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/abecms/abecms/)
[![Coverage Status](https://coveralls.io/repos/github/abecms/abecms/badge.svg?branch=master)](https://coveralls.io/github/abecms/abecms?branch=master)
[![Dependency Status](https://www.versioneye.com/user/projects/587a81915450ea0034dffa93/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/57ea4badbd6fa600316f9f6c)
[![Inline docs](http://inch-ci.org/github/abecms/abecms.svg?branch=master)](http://inch-ci.org/github/abecms/abecms)
[![Latest Stable Version](https://img.shields.io/npm/v/abecms.svg)](https://www.npmjs.com/package/abecms)
[![Total Downloads](https://img.shields.io/npm/dt/abecms.svg)](https://www.npmjs.com/package/abecms)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/abecms/abecms/master/LICENSE)
# Abe, A better engine

> Abe is your __static websites generator__ with revolutionnary __self-descriptive__ templates
[![NPM](https://nodei.co/npm/abe-cli.png?downloads=true&downloadRank=true)](https://nodei.co/npm/abe-cli/)
[![NPM](https://nodei.co/npm-dl/abe-cli.png?months=3&height=3)](https://nodei.co/npm/abe-cli/)
[![NPM](https://nodei.co/npm/abecms.png?downloads=true&downloadRank=true)](https://nodei.co/npm/abecms/)
[![NPM](https://nodei.co/npm-dl/abecms.png?months=3&height=3)](https://nodei.co/npm/abecms/)

# Demo
Deploy your own Abe demo on Heroku

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/abejs/demo)
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/abecms/demo)

# Presentation
I've designed this CMS because I wanted to simplify and optimize the way we're creating content. Wordpress is way too complex for what it does. Welcome to ABE (A Better Engine) : This CMS will make you create content in a snap and publish it on the web in no time !
Expand Down Expand Up @@ -96,8 +96,8 @@ See the complete [changelog](./CHANGELOG.md)
### 2.4.*
- The first unit tests are implemented
- Quality control with esLint added
- Continuous Integration with [Travis](https://travis-ci.org/AdFabConnect/abejs)
- Unit test coverage added : [coveralls](https://coveralls.io/github/AdFabConnect/abejs?branch=master)
- Continuous Integration with [Travis](https://travis-ci.org/abecms/abecms)
- Unit test coverage added : [coveralls](https://coveralls.io/github/abecms/abecms?branch=master)
- Select data become a first class citizen in Manager => perf X50 on page display including templates with select statements

### 2.3.*
Expand Down Expand Up @@ -133,7 +133,7 @@ New features :

# Getting started

With __npm__ : ```$ npm install -g abe-cli ```
With __npm__ : ```$ npm install -g abecms ```

## Unix

Expand Down Expand Up @@ -339,9 +339,9 @@ npm config set msvs_version 2015 --global
Create a blog directory (ie. "abesite") with the default project structure (see below). It will contain your blog.
git clone abe outside of your blog directory (not in abesite) :

```$ git clone https://github.com/AdFabConnect/abejs.git ```
```$ git clone https://github.com/abecms/abecms.git ```

```$ cd abejs ```
```$ cd abecms ```

```$ npm i ```

Expand Down
4 changes: 2 additions & 2 deletions docs/abe-form-create-override.md
Expand Up @@ -4,9 +4,9 @@ create a folder name "custom"

and create a new file named "create.html"

> info : https://github.com/AdFabConnect/abejs/blob/master/dist/server/views/partials/create.html
> info : https://github.com/abecms/abecms/blob/master/dist/server/views/partials/create.html
if you add the form attributes ```data-form-abe-create="true"``` default abejs javascript file will perform action on your custom form
if you add the form attributes ```data-form-abe-create="true"``` default abecms javascript file will perform action on your custom form

# create a new file

Expand Down
2 changes: 0 additions & 2 deletions docs/abe-plugins.md
Expand Up @@ -130,8 +130,6 @@ website/
- my_route.js ...
```

Plugin examples at [https://github.com/AdFabConnect/abe-plugins](https://github.com/AdFabConnect/abe-plugins)

Once you'll be satisfied with the way your module works, you'll then be able to create a regular npm module and install it on your project with the command abe install my_module

## frontend javascript
Expand Down
24 changes: 12 additions & 12 deletions package.json
@@ -1,11 +1,11 @@
{
"name": "abe-cli",
"version": "2.14.2",
"description": "Abe command line tool",
"name": "abecms",
"version": "2.14.5",
"description": "Abe: The lightning fast CMS",
"main": "src/server/app.js",
"repository": {
"type": "git",
"url": "git://github.com/AdFabConnect/abejs.git"
"url": "git://github.com/abecms/abecms.git"
},
"scripts": {
"lint": "eslint src --fix",
Expand All @@ -17,16 +17,16 @@
"test-e2e": "sleep 6 && node_modules/.bin/nightwatch --config nightwatch.conf.js",
"posttest-e2e": "kill -9 $(lsof -ti tcp:3003)",
"start": "node --debug --harmony ./dist/server/index.js",
"babel": "babelify --presets [ es2015 ] src/server/public/abejs/scripts/template-engine.js -o src/server/public/abejs/scripts/template-engine-compiled.js",
"watch": "./node_modules/.bin/parallelshell './node_modules/.bin/watchify -v -t [ babelify --presets [ es2015 ] ] src/server/public/abejs/scripts/template-engine.js -o src/server/public/abejs/scripts/template-engine-compiled.js' './node_modules/.bin/watchify -v -t [ babelify --presets [ es2015 ] ] src/server/public/abejs/scripts/admin.js -o src/server/public/abejs/scripts/admin-compiled.js' './node_modules/.bin/watchify -v -t [ babelify --presets [ es2015 ] ] src/server/public/abejs/scripts/user-login.js -o src/server/public/abejs/scripts/user-login-compiled.js' 'npm run watch:sass'",
"babel": "babelify --presets [ es2015 ] src/server/public/abecms/scripts/template-engine.js -o src/server/public/abecms/scripts/template-engine-compiled.js",
"watch": "./node_modules/.bin/parallelshell './node_modules/.bin/watchify -v -t [ babelify --presets [ es2015 ] ] src/server/public/abecms/scripts/template-engine.js -o src/server/public/abecms/scripts/template-engine-compiled.js' './node_modules/.bin/watchify -v -t [ babelify --presets [ es2015 ] ] src/server/public/abecms/scripts/admin.js -o src/server/public/abecms/scripts/admin-compiled.js' './node_modules/.bin/watchify -v -t [ babelify --presets [ es2015 ] ] src/server/public/abecms/scripts/user-login.js -o src/server/public/abecms/scripts/user-login-compiled.js' 'npm run watch:sass'",
"watch:sass": "./node_modules/.bin/watch 'npm run sass' ./src/server/sass",
"babel-app": "node_modules/.bin/babel-node --presets es2015",
"build": "node_modules/.bin/babel-node --presets es2015 src/cli/build/template.js",
"mvasset": "mkdirp dist/server/public/abejs && cp -r src/server/locale dist/server && cp -r src/server/views dist/server && cp -r src/server/public/abejs/css dist/server/public/abejs && cp -r src/server/public/abejs/fonts dist/server/public/abejs && cp -r src/server/public/abejs/image dist/server/public/abejs",
"mvasset": "mkdirp dist/server/public/abecms && cp -r src/server/locale dist/server && cp -r src/server/views dist/server && cp -r src/server/public/abecms/css dist/server/public/abecms && cp -r src/server/public/abecms/fonts dist/server/public/abecms && cp -r src/server/public/abecms/image dist/server/public/abecms",
"sass": "node ./src/tasks/sass.js",
"js:users": "browserify -t [ babelify --presets [ es2015 ] ] src/server/public/abejs/scripts/user-login.js -o src/server/public/abejs/scripts/user-login-compiled.js",
"js:admin": "browserify -t [ babelify --presets [ es2015 ] ] src/server/public/abejs/scripts/admin.js -o src/server/public/abejs/scripts/admin-compiled.js",
"js:engine": "browserify -t [ babelify --presets [ es2015 ] ] src/server/public/abejs/scripts/template-engine.js -o src/server/public/abejs/scripts/template-engine-compiled.js",
"js:users": "browserify -t [ babelify --presets [ es2015 ] ] src/server/public/abecms/scripts/user-login.js -o src/server/public/abecms/scripts/user-login-compiled.js",
"js:admin": "browserify -t [ babelify --presets [ es2015 ] ] src/server/public/abecms/scripts/admin.js -o src/server/public/abecms/scripts/admin-compiled.js",
"js:engine": "browserify -t [ babelify --presets [ es2015 ] ] src/server/public/abecms/scripts/template-engine.js -o src/server/public/abecms/scripts/template-engine-compiled.js",
"build:front": "npm run js:admin && npm run js:users && npm run js:engine && npm run sass",
"build:scripts": "npm run build:front && ./node_modules/.bin/babel --presets es2015,stage-0 -d dist/server src/server/ && ./node_modules/.bin/babel --presets es2015,stage-0 -d dist/cli src/cli/ && npm run mvasset",
"compile": "./node_modules/.bin/babel --presets es2015,stage-0 -d dist/ src/ && cp -r src/cli/core/config/config.json dist/cli/core/config/config.json",
Expand All @@ -35,7 +35,7 @@
"startdev": "npm run build:front && npm run compile && npm run mvasset && node src/tasks/nodemon.js & npm run watch --kill-others",
"startdevOnly": "npm run js:admin && npm run js:users && npm run js:engine && node src/tasks/nodemon.js & npm run watch --kill-others"
},
"author": "Adfab Connect",
"author": "Gregory Besson",
"license": "ISC",
"preferGlobal": true,
"bin": {
Expand Down Expand Up @@ -116,7 +116,7 @@
"istanbul": "^1.1.0-alpha.1",
"mocha": "^3.0.2",
"nightwatch": "^0.9.11",
"node-sass": "^3.7.0",
"node-sass": "^4.3.0",
"nodemon": "^1.8.1",
"parallelshell": "^2.0.0",
"selenium-download": "^2.0.7",
Expand Down
58 changes: 57 additions & 1 deletion src/cli/cms/data/attributes.js
@@ -1,7 +1,7 @@
import {
abeExtend
} from '../../'

import * as sourceAttr from '../../cms/editor/handlebars/sourceAttr'
/**
* Get All attributes from a Abe tag
* @return {Object} parsed attributes
Expand Down Expand Up @@ -71,4 +71,60 @@ export function sanitizeSourceAttribute(obj, jsonPage){
}

return obj
}

/**
* This function will take the value of an Abe attribute and analyze its content.
* If it contains a var {{variable.prop.value}}, it will extract its content with these rules
* element.[0].value
* element[0].value
* element.0.value
* will all be transformed into element[0].value and evaluated with the json
* If it contains a [] ie. {{variable[].value}} or {{variable.[].value}}
* It will return the array of values
* @param {String} value
* @return {String}
*/
export function getValueFromAttribute(value, json){
var result = value
if (value.indexOf('{{') > -1) {
var keys = sourceAttr.getKeys(value)
var isAr = false
Array.prototype.forEach.call(keys, (key) => {
var toEval = `${key.replace(/(\[|\.|\])/g, '\\$1')}`
var properties = key.split('.')
Array.prototype.forEach.call(properties, (prop, index) => {
if (prop.indexOf('[]') > 0) {
isAr = true
} else if (prop.indexOf('[]') == 0 && index > 0) {
properties[index - 1] += prop
properties.splice(index, 1)
isAr = true
} else if (prop.indexOf('[') == 0 && index > 0) {
properties[index - 1] += prop
properties.splice(index, 1)
} else if(/^\d+$/.test(prop) && index > 0){
properties[index - 1] += '[' + prop + ']'
properties.splice(index, 1)
}
})
key = properties.join('.')
try {
if(isAr){
result = []
var properties = key.split('[]')
var jsonAr = eval(`json.${properties[0]}`)
Array.prototype.forEach.call(jsonAr, (prop, index) => {
var resTemp = value
result.push(resTemp.replace(new RegExp(`\{\{${toEval}\}\}`, 'g'), eval(`prop${properties[1]}`)))
})
} else {
result = result.replace(new RegExp(`\{\{${toEval}\}\}`, 'g'), eval(`json.${key}`))
}
}catch(e) {
}
})
}

return result
}
3 changes: 1 addition & 2 deletions src/cli/cms/data/file.js
Expand Up @@ -58,8 +58,7 @@ export function getAllWithKeys(withKeys) {
fileObject = cmsData.file.getAbeMeta(fileObject, json)

Array.prototype.forEach.call(withKeys, (key) => {
var keyFirst = key.split('.')[0]
fileObject[keyFirst] = json[keyFirst]
fileObject[key] = json[key]
})

filesArr.push(fileObject)
Expand Down
22 changes: 13 additions & 9 deletions src/cli/cms/data/sql.js
Expand Up @@ -79,14 +79,12 @@ export function handleSqlRequest(str, jsonPage) {
var req = escapeAbeValuesFromStringRequest(str, jsonPage)
var request = parse(req)
var reconstructSql = ''

// SQL TYPE
var type = ''
if(request.type != null) {
type = request.type
}
reconstructSql += `${type} `

// SQL COLUMNS
var columns = []
if(request.columns != null) {
Expand All @@ -99,7 +97,6 @@ export function handleSqlRequest(str, jsonPage) {
}
}
reconstructSql += `${JSON.stringify(columns)} `

// SQL FROM
var from = []
if(request.from != null) {
Expand Down Expand Up @@ -416,7 +413,7 @@ export function getWhereValuesToCompare(where, jsonDoc, jsonOriginalDoc) {
}catch(e) {
// console.log('e', e)
}

if(where.operator === 'IN' || where.operator === 'NOT IN') {
if(value == null) {
// is the form of variableLeft something like elt.attribute or elt[].attribute?
Expand Down Expand Up @@ -447,9 +444,13 @@ export function getWhereValuesToCompare(where, jsonDoc, jsonOriginalDoc) {
if(matchRightVariable != null && matchRightVariable.length > 0) {
try {
var jsonOriginalValues = eval('jsonOriginalDoc.' + matchRightVariable[1])
Array.prototype.forEach.call(jsonOriginalValues, (jsonOriginalValue) => {
compare.push(eval('jsonOriginalValue.' + whereLeftColumn))
})
if( Object.prototype.toString.call(jsonOriginalValues) === '[object Array]' ) {
Array.prototype.forEach.call(jsonOriginalValues, (jsonOriginalValue) => {
compare.push(eval('jsonOriginalValue.' + whereLeftColumn))
})
} else {
compare.push(jsonOriginalValues)
}
}catch(e) {}
}
else{
Expand Down Expand Up @@ -486,22 +487,25 @@ export function getWhereValuesToCompare(where, jsonDoc, jsonOriginalDoc) {
}

export function isInStatementCorrect(values, isCorrect){
let hasPassedTest = false
if( Object.prototype.toString.call(values.left) === '[object Array]' ) {
Array.prototype.forEach.call(values.left, (left) => {
Array.prototype.forEach.call(values.right, (right) => {
if(left != null && left === right) {
isCorrect = !isCorrect
hasPassedTest = true
}
})
})
} else {
Array.prototype.forEach.call(values.right, (right) => {
if(values.left === right) {
isCorrect = !isCorrect
hasPassedTest = true
}
})
}

if(hasPassedTest) isCorrect = !isCorrect

return isCorrect
}

Expand Down
10 changes: 2 additions & 8 deletions src/cli/cms/operations/create.js
Expand Up @@ -13,9 +13,7 @@ var create = function(template, pathCreate, name, req, forceJson = {}, duplicate

var postUrl = path.join('/', pathCreate, name)
postUrl = coreUtils.slug.clean(postUrl)

var json = (forceJson) ? forceJson : {}

json = cmsData.metas.create(json, template, postUrl)

if (duplicate) {
Expand All @@ -25,13 +23,9 @@ var create = function(template, pathCreate, name, req, forceJson = {}, duplicate
var templateText = cmsTemplates.template.getTemplate(template)
json = cmsData.values.removeDuplicate(templateText, json)
}

var resHook = abeExtend.hooks.instance.trigger('beforeFirstSave', postUrl, req.body, json)
postUrl = resHook.postUrl
json = resHook.json

json = abeExtend.hooks.instance.trigger('beforeFirstSave', json, req.body)
var p2 = cmsOperations.post.draft(
postUrl,
json.abe_meta.link,
json,
'draft'
)
Expand Down
32 changes: 20 additions & 12 deletions src/cli/cms/templates/template.js
Expand Up @@ -61,6 +61,13 @@ export function getAbeImport(text) {
return partials
}

/**
* it will include recurively each encountered type=import
* and proceed to a foreach when the file={{some[]}} is an array of values
* @param {[type]} text [description]
* @param {[type]} json [description]
* @return {[type]} [description]
*/
export function includePartials(text, json) {
var abeImports = cmsTemplates.template.getAbeImport(text)

Expand All @@ -70,20 +77,18 @@ export function includePartials(text, json) {
var file = obj.file
var partial = ''
file = path.join(config.root, config.partials, file)
file = cmsData.attributes.getValueFromAttribute(file, json)

if (file.indexOf('{{') > -1) {
var keys = sourceAttr.getKeys(file)
Array.prototype.forEach.call(keys, (key) => {
try {
var toEval = `${key.replace(/(\[|\.|\])/g, '\\$1')}`
file = file.replace(new RegExp(`\{\{${toEval}\}\}`, 'g'), eval(`json.${key}`))
}catch(e) {
if(Object.prototype.toString.call(file) === '[object Array]' ) {
Array.prototype.forEach.call(file, (f) => {
if(coreUtils.file.exist(f)) {
partial += cmsTemplates.template.includePartials(fse.readFileSync(f, 'utf8'), json)
}
})
}

if(coreUtils.file.exist(file)) {
partial = cmsTemplates.template.includePartials(fse.readFileSync(file, 'utf8'), json)
} else {
if(coreUtils.file.exist(file)) {
partial = cmsTemplates.template.includePartials(fse.readFileSync(file, 'utf8'), json)
}
}
text = text.replace(cmsData.regex.escapeTextToRegex(abeImport, 'g'), partial)
})
Expand Down Expand Up @@ -272,7 +277,10 @@ export function getAbeRequestWhereKeysFromTemplates(templatesList) {
Array.prototype.forEach.call(templatesList, (file) => {
whereKeys = whereKeys.concat(cmsTemplates.template.execRequestColumns(file.template))
})
whereKeys = whereKeys.filter(function (item, pos) {return whereKeys.indexOf(item) == pos})
whereKeys = whereKeys.filter(function (item, pos) {
item = item.split('.')[0].split('[')[0]
return whereKeys.indexOf(item) == pos
})
resolve(whereKeys)
})

Expand Down

0 comments on commit 6532d3b

Please sign in to comment.