Skip to content

Commit

Permalink
Merge pull request #81 from AdFabConnect/bug_76
Browse files Browse the repository at this point in the history
Bug 76
  • Loading branch information
gregorybesson committed Dec 14, 2016
2 parents 5b5be35 + 8504e79 commit 7326eb0
Show file tree
Hide file tree
Showing 26 changed files with 57 additions and 103 deletions.
20 changes: 0 additions & 20 deletions README.md
Expand Up @@ -173,29 +173,9 @@ start server with nodemon (dev)

```$ abe servedev ```

OR

start server with pm2

open ./abe.json

```
{
"processName": "abe",
"port": "8000"
}
```
> default config

```$ abe prod ```

to stop pm2 in production

```$ abe stop ```


## Options

```
Expand Down
2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -17,7 +17,6 @@
"test-func": "sleep 6 && node_modules/.bin/nightwatch --config nightwatch.conf.js",
"posttest-func": "killall node",
"start": "node --debug --harmony ./dist/server/index.js",
"startpm2": "pm2 startOrRestart ./processes.json",
"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'",
"watch:sass": "./node_modules/.bin/watch 'npm run sass' ./src/server/sass",
Expand Down Expand Up @@ -88,7 +87,6 @@
"passport-http-bearer": "^1.0.1",
"passport-local": "^1.0.0",
"passport-oauth2-client-password": "^0.1.2",
"pm2": "^2.0.18",
"prettyjson": "^1.1.3",
"prompt": "^1.0.0",
"qs": "^6.0.1",
Expand Down
7 changes: 3 additions & 4 deletions src/cli/cms/data/regex.js
@@ -1,14 +1,13 @@

export let abeTag = /({{abe.*?[\s\S].*?}})/g;
//
export let abePattern = /[^"']({{abe.*?type=[\'|\"][text|rich|textarea]+[\'|\"][\s\S].*?}})/g;
export let abePattern = /[^"']({{abe.*?type=[\'|\"][text|rich|textarea]+[\'|\"][\s\S].*?}})/g
// This pattern finds all abe tags enclosed in a HTML tag attribute
// export let abeAsAttributePattern = /( [A-Za-z0-9\-\_]+=["|']{1}{{abe.*?}})/g;
// export let abeAsAttributePattern = /( [A-Za-z0-9\-\_]+=["|']{1})(.*?)({{abe.*?}})/g
export let abeAsAttributePattern = /( [A-Za-z0-9\-\_]+=["|']{1})([^=]*?)({{abe.*?["|'| ]}})["|']/g;
export let abeAsAttributePattern = /( [A-Za-z0-9\-\_]+=["|']{1})([^=]*?)({{abe.*?["|'| ]}})["|']/g
// This pattern finds all {{#each ...}}...{{/each}} blocks
// export let eachBlockPattern = />\s*(\{\{#each (\r|\t|\n|.)*?\/each\}\})/g;
export let eachBlockPattern = /(\{\{#each (\r|\t|\n|.)*?\/each\}\})/g;
export let eachBlockPattern = /(\{\{#each (\r|\t|\n|.)*?\/each\}\})/g
// This pattern finds all {{#each ...}}...{{/each}} blocks
export let blockPattern = /(\{\{#each.*\}\}[\s\S]*?\{\{\/each\}\})/g

Expand Down
2 changes: 1 addition & 1 deletion src/cli/cms/data/source.js
Expand Up @@ -78,7 +78,7 @@ export function urlList(obj, tplPath, match, jsonPage) {
if(pathSource[1] != null) {
pathSource = pathSource[1].split('/')
pathSource.shift()
pathSource = '/' + path.join('/')
pathSource = '/' + pathSource.join('/')
}else {
pathSource = '/'
}
Expand Down
7 changes: 0 additions & 7 deletions src/cli/cms/editor/handlebars/printBlock.js
@@ -1,11 +1,6 @@
import {printInput} from './printInput'
import abeEngine from './abeEngine'

import {
config
,cmsTemplates
} from '../../../../cli'

export default function printBlock (ctx, root) {
var res = ''
var precontrib = false
Expand Down Expand Up @@ -74,7 +69,5 @@ export default function printBlock (ctx, root) {
res += printInput(ctx[0], root)
}

// var template = cmsTemplates.Handlebars.compile(res)
// return new cmsTemplates.Handlebars.SafeString(template(ctx, {data: {intl: config.intlData}}))
return res
}
21 changes: 16 additions & 5 deletions src/cli/cms/editor/handlebars/printInput.js
Expand Up @@ -57,13 +57,24 @@ export function createInputSource(attributes, inputClass, params) {
lastValues = JSON.stringify(params.value).replace(/\'/g, '&quote;')
inputSource += `<select ${attributes} class="${inputClass}" last-values='${lastValues}'>`

if (!params.required) inputSource += '<option value=\'\'></option>'
// if (!params.required) inputSource += '<option value=\'\'></option>'
var options = ''
if(typeof params.source === 'object' && Object.prototype.toString.call(params.source) === '[object Array]') {
Array.prototype.forEach.call(params.source, (val) => {
inputSource += sourceOption(val, params)
options += sourceOption(val, params)
})
}else{
options += sourceOption(params.source, params)
}
else inputSource += sourceOption(params.source, params)

var defaultValueSelected = 'selected=selected'
if (options.indexOf('selected') > -1) {
defaultValueSelected = ''
}
if (params.required) inputSource += `<option value=\'\' value="" disabled ${defaultValueSelected}>Select ${params.desc.toLowerCase()}...</option>`
if (!params.required) inputSource += `<option value=\'\' value="" ${defaultValueSelected}></option>`
inputSource += options

inputSource += '</select>'
}
return inputSource
Expand Down Expand Up @@ -132,7 +143,7 @@ export function createInputTextarea(attributes, inputClass, params) {
return `<textarea class="${inputClass}" ${attributes} rows="4">${params.value}</textarea>`
}

export function createInputLink(attributes, inputClass, params) {
export function createInputLink(attributes, inputClass) {
return `<div class="input-group">
<div class="input-group-addon link">
<span class="glyphicon glyphicon-link" aria-hidden="true"></span>
Expand All @@ -157,7 +168,7 @@ export function createInputImage(attributes, inputClass, params) {
<div class="input-error"></div>`
}

export function createInputText(attributes, inputClass, params) {
export function createInputText(attributes, inputClass) {
return `<div class="input-group">
<div class="input-group-addon">
<span class="glyphicon glyphicon-font" aria-hidden="true"></span>
Expand Down
1 change: 0 additions & 1 deletion src/cli/cms/operations/create.js
@@ -1,6 +1,5 @@
import path from 'path'
import {
Manager,
coreUtils,
cmsTemplates,
cmsOperations,
Expand Down
1 change: 0 additions & 1 deletion src/cli/cms/operations/remove.js
Expand Up @@ -2,7 +2,6 @@ import fse from 'fs-extra'
import path from 'path'

import {
config,
abeExtend,
cmsData,
coreUtils,
Expand Down
7 changes: 1 addition & 6 deletions src/cli/cms/structure/structure.js
@@ -1,10 +1,5 @@
import path from 'path'

import {
coreUtils,
cmsStructure,
cmsData,
config
coreUtils
} from '../../'

export function editStructure(type, folderPath) {
Expand Down
1 change: 0 additions & 1 deletion src/cli/cms/templates/handlebars/attrAbe.js
@@ -1,5 +1,4 @@
import Handlebars from 'handlebars'
import abeEngine from '../../../'

/**
* Print properties inside html tag
Expand Down
1 change: 0 additions & 1 deletion src/cli/cms/templates/handlebars/isAuthorized.js
@@ -1,5 +1,4 @@
import {
config,
User
} from '../../../'

Expand Down
14 changes: 6 additions & 8 deletions src/cli/cms/templates/prepare.js
Expand Up @@ -35,24 +35,22 @@ export function addHasAbeAttr(text) {
export function getAbeAttributeData(match, text, htmlAttribute, abeTag) {
var valueOfAttritube
var key = cmsData.regex.getAttr(match, 'key')
var getattr
var res

if (cmsData.regex.isSingleAbe(match, text)) {
valueOfAttritube = key.replace(/\./g, '-')
key = cmsData.regex.validDataAbe(valueOfAttritube)
getattr = key.replace(/\./g, '-')
res = ' data-abe-attr-' + valueOfAttritube + '="' + htmlAttribute + '"' + ' data-abe-' + valueOfAttritube + '="' + getattr + '"' + abeTag
key = key.replace(/\./g, '-')
res = ' data-abe-attr-' + valueOfAttritube + '="' + htmlAttribute + '"' + ' data-abe-' + valueOfAttritube + '="' + key + '"' + abeTag
}else {
var valueOfAttritube = key.split('.')
valueOfAttritube = key.split('.')
var parentKey = valueOfAttritube.shift()
valueOfAttritube = `${parentKey}[index].${valueOfAttritube[0]}`
var valueOfAttritubeIndexed = valueOfAttritube.replace(/\[index\]/, '{{@index}}')
key = cmsData.regex.validDataAbe(valueOfAttritube)
getattr = key

res = ` data-abe-attr-${valueOfAttritube}="${htmlAttribute}" data-abe-${valueOfAttritube}="${getattr}"`
+ ` data-abe-attr-${valueOfAttritubeIndexed}="${htmlAttribute}" data-abe-${valueOfAttritubeIndexed}="${getattr}"${abeTag}`
res = ` data-abe-attr-${valueOfAttritube}="${htmlAttribute}" data-abe-${valueOfAttritube}="${key}"`
+ ` data-abe-attr-${valueOfAttritubeIndexed}="${htmlAttribute}" data-abe-${valueOfAttritubeIndexed}="${key}"${abeTag}`
}

return res
Expand Down Expand Up @@ -83,7 +81,7 @@ data-abe-image_key="image_key" src="{{abe type='image' key='image_key' tab='defa
* @param {[type]} template [description]
*/
export function addAbeDataAttrForHtmlAttributes(template, key) {
export function addAbeDataAttrForHtmlAttributes(template) {
var text = template.replace(/<([A-Za-z]+)/g, '\nABE_SPLIT<$1')
let abeTagIntoAttribute = text.match(cmsData.regex.abeAsAttributePattern)

Expand Down
24 changes: 12 additions & 12 deletions src/cli/core/manager/Manager.js
Expand Up @@ -70,18 +70,18 @@ class Manager {
try {
fse.accessSync(this._pathTemplate, fse.F_OK)
this._watchTemplateFolder = watch.createMonitor(this._pathTemplate, (monitor) => {
monitor.on('created', (f, stat) => {
monitor.on('created', () => {
this.getKeysFromSelect()
this.updateStructureAndTemplates()
this.events.template.emit('update')
})
monitor.on('changed', (f, curr, prev) => {
monitor.on('changed', () => {
this.getKeysFromSelect()
this.updateStructureAndTemplates()
this.events.template.emit('update')

})
monitor.on('removed', (f, stat) => {
monitor.on('removed', () => {
this.getKeysFromSelect()
this.updateStructureAndTemplates()
this.events.template.emit('update')
Expand All @@ -95,18 +95,18 @@ class Manager {
try {
fse.accessSync(this._pathPartials, fse.F_OK)
this._watchPartialsFolder = watch.createMonitor(this._pathPartials, (monitor) => {
monitor.on('created', (f, stat) => {
monitor.on('created', () => {
this.getKeysFromSelect()
this.updateStructureAndTemplates()
this.events.template.emit('update')
})
monitor.on('changed', (f, curr, prev) => {
monitor.on('changed', () => {
this.getKeysFromSelect()
this.updateStructureAndTemplates()
this.events.template.emit('update')

})
monitor.on('removed', (f, stat) => {
monitor.on('removed', () => {
this.getKeysFromSelect()
this.updateStructureAndTemplates()
this.events.template.emit('update')
Expand All @@ -119,15 +119,15 @@ class Manager {
try {
fse.accessSync(this._pathStructure, fse.F_OK)
this._watchStructure = watch.createMonitor(this._pathStructure, (monitor) => {
monitor.on('created', (f, stat) => {
monitor.on('created', () => {
this.updateStructureAndTemplates()
this.events.structure.emit('update')
})
monitor.on('changed', (f, curr, prev) => {
monitor.on('changed', () => {
this.updateStructureAndTemplates()
this.events.structure.emit('update')
})
monitor.on('removed', (f, stat) => {
monitor.on('removed', () => {
this.updateStructureAndTemplates()
this.events.structure.emit('update')
})
Expand All @@ -139,16 +139,16 @@ class Manager {
try {
fse.accessSync(this._pathReference, fse.F_OK)
this._watchReferenceFolder = watch.createMonitor(this._pathReference, (monitor) => {
monitor.on('created', (f, stat) => {
monitor.on('created', (f) => {
this.updateReferences(f)
this.events.reference.emit('update')
})
monitor.on('changed', (f, curr, prev) => {
monitor.on('changed', (f) => {
this.updateReferences(f)
this.events.reference.emit('update')

})
monitor.on('removed', (f, stat) => {
monitor.on('removed', () => {
this.updateReferences()
this.events.reference.emit('update')
})
Expand Down
1 change: 0 additions & 1 deletion src/cli/core/utils/file.js
@@ -1,7 +1,6 @@
import Promise from 'bluebird'
import path from 'path'
import mkdirp from 'mkdirp'
import execPromise from 'child-process-promise'
var fse = Promise.promisifyAll(require('fs-extra'))

import {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/extend/process.js
Expand Up @@ -40,7 +40,7 @@ var abeProcess = function(name, args = []) {
}

if(typeof proc !== 'undefined' && proc !== null) {
proc.on('message', function(msg) {
proc.on('message', function() {
abeExtend.lock.remove(name)
proc.kill()
})
Expand Down
6 changes: 1 addition & 5 deletions src/cli/index.js
Expand Up @@ -4,8 +4,6 @@ import fse from 'fs-extra'
import mkdirp from 'mkdirp'
import clc from 'cli-color'

import handlebarsHelperSlugify from 'handlebars-helper-slugify'

import {
translate,
cleanTab,
Expand All @@ -16,9 +14,7 @@ import {
moduloIf,
attrAbe,
ifIn,
ifCond,
isTrue,
truncate
ifCond
} from './cms/templates/index'

import {
Expand Down
3 changes: 1 addition & 2 deletions src/cli/users/utils.js
Expand Up @@ -237,7 +237,7 @@ export function getAll() {
return User.manager.instance.get()
}

export function getUserWorkflow(status, role) {
export function getUserWorkflow(status) {
var flows = []

function addFlow (flow, type, action) {
Expand All @@ -249,7 +249,6 @@ export function getUserWorkflow(status, role) {
}

if (config.users.enable) {
var before = null
var found = null
Array.prototype.forEach.call(config.users.workflow, (flow) => {

Expand Down
10 changes: 2 additions & 8 deletions src/index.js
@@ -1,17 +1,11 @@
#!/usr/bin/env node
import {Promise} from 'bluebird'
import Create from './cli/cms/Create'
import plugins from './cli/extend/plugins'
import {exec} from 'child_process'
import {spawn} from 'child_process'
import execPromise from 'child-process-promise'
import mkdirp from 'mkdirp'
import fse from 'fs-extra'
import path from 'path'
import program from 'commander'
import pkg from '../package'
import pm2 from 'pm2'
import clc from 'cli-color'

program
.version(pkg.version)
Expand Down Expand Up @@ -50,7 +44,7 @@ program
}

generate.on('close', (code) => {
console.log(clc.cyan('child process exited with code') + ' ' + code)
console.log('child process exited with code ' + code)
process.exit(0)
})
}).on('--help', function() {
Expand All @@ -64,7 +58,7 @@ program
.command('create [path]')
.alias('c')
.description('create new abe project')
.action(function(dest, options){
.action(function(dest){
dest = (dest != null) ? dest : ''
var dir = path.join(process.cwd(), dest)
if(process.env.ROOT) {
Expand Down

0 comments on commit 7326eb0

Please sign in to comment.