Skip to content

Commit

Permalink
refactoring: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Oct 11, 2016
1 parent af37941 commit dc6b630
Show file tree
Hide file tree
Showing 31 changed files with 101 additions and 105 deletions.
2 changes: 1 addition & 1 deletion src/cli/cms/operations/post.js
Expand Up @@ -10,7 +10,7 @@ import {


export function unpublish(filePath) {
var filePath = coreUtils.slug.clean(filePath)
filePath = coreUtils.slug.clean(filePath)
var tplUrl = cmsData.file.fromUrl(path.join(config.publish.url, filePath))
if(coreUtils.file.exist(tplUrl.json.path)) {
var json = JSON.parse(JSON.stringify(cmsData.file.get(tplUrl.json.path)))
Expand Down
1 change: 0 additions & 1 deletion src/cli/cms/templates/handlebars/attrAbe.js
Expand Up @@ -8,6 +8,5 @@ import abeEngine from '../../../'
* @return {String} the value to print inside the attribut
*/
export default function attrAbe (attr, value) {
var content = abeEngine._content
return new Handlebars.SafeString(value)
}
2 changes: 1 addition & 1 deletion src/cli/process/update-json.js
Expand Up @@ -23,7 +23,7 @@ if(typeof pConfig.ABE_WEBSITE !== 'undefined' && pConfig.ABE_WEBSITE !== null) {
pConfig.FILEPATH = path.join(config.root, config.data.url, pConfig.FILEPATH ? pConfig.FILEPATH.replace(config.root) : '')

allJson = cmsData.file.getFiles(pConfig.FILEPATH, true, 20, /\.json/)
allJson = Hooks.instance.trigger('beforeUpdateJson', allJson)
Hooks.instance.trigger('beforeUpdateJson', allJson)

}else {
console.log('ABE_WEBSITE is not defined use node process.js ABE_WEBSITE=/pat/to/website')
Expand Down
1 change: 0 additions & 1 deletion src/server/app.js
Expand Up @@ -22,7 +22,6 @@ import {
notEmpty,
printJson,
className,
abe,
compileAbe,
listPage,
ifIn,
Expand Down
10 changes: 6 additions & 4 deletions src/server/controllers/editor.js
Expand Up @@ -42,8 +42,9 @@ function addToForm(match, text, json, util, arrayBlock, keyArray = null, i = 0)
var v = `{{${match}}}`,
obj = cmsData.attributes.getAll(v, json)

var realKey
if(typeof keyArray !== 'undefined' && keyArray !== null) {
var realKey = obj.key.replace(/[^\.]+?\./, '')
realKey = obj.key.replace(/[^\.]+?\./, '')

if(obj.key.indexOf(keyArray + '.') >= 0 && realKey.length > 0){
obj.keyArray = keyArray
Expand All @@ -58,7 +59,7 @@ function addToForm(match, text, json, util, arrayBlock, keyArray = null, i = 0)
}

}else if(util.dontHaveKey(obj.key) && cmsData.regex.isSingleAbe(v, text)) {
var realKey = obj.key.replace(/\./g, '-')
realKey = obj.key.replace(/\./g, '-')
obj.value = json[realKey]
json[obj.key] = add(obj, json, text, util)
}
Expand Down Expand Up @@ -94,6 +95,7 @@ function each(text, json, util, arrayBlock) {
var textEach, match

while (textEach = pattEach.exec(text)) {
var i
var keyArray = textEach[0].match(/#each (\n|.)*?\}/)
keyArray = keyArray[0].slice(6, keyArray[0].length - 1)

Expand All @@ -107,7 +109,7 @@ function each(text, json, util, arrayBlock) {

if(v.indexOf('abe') > -1){
if(json[keyArray]){
for (var i = 0; i < json[keyArray].length; i++) {
for (i = 0; i < json[keyArray].length; i++) {
addToForm(v, text, json, util, arrayBlock, keyArray, i)
}
}else{
Expand All @@ -124,7 +126,7 @@ function each(text, json, util, arrayBlock) {
length = arrayBlock[keyArray][index].length
}

for (var i = 0; i < length; i++) {
for (i = 0; i < length; i++) {
for (var j = 0; j < attrArray.length; j++) {
add(arrayBlock[keyArray][attrArray[j]][i], json, text, util)
}
Expand Down
13 changes: 0 additions & 13 deletions src/server/controllers/index.js
@@ -1,12 +1,5 @@
import express from 'express'
import fs from 'fs'
import fse from 'fs-extra'
import mkdirp from 'mkdirp'
import {minify} from 'html-minifier'
import extend from 'extend'
import * as abe from '../../cli'
import xss from 'xss'
import pkg from '../../../package'
import {
getCreate
,getDuplicate
Expand All @@ -29,17 +22,11 @@ import {
} from '../routes'

import {
config,
Page,
abeProcess,
Hooks,
Plugins,
Handlebars,
} from '../../cli'

import locale from '../helpers/abe-locale'
import pageHelper from '../helpers/page'

var router = express.Router()
Hooks.instance.trigger('afterHandlebarsHelpers', Handlebars)
Hooks.instance.trigger('beforeAddRoute', router)
Expand Down
1 change: 0 additions & 1 deletion src/server/helpers/abe-locale.js
@@ -1,6 +1,5 @@
import fse from 'fs-extra'
import extend from 'extend'
import clc from 'cli-color'
import path from 'path'

import {
Expand Down
2 changes: 1 addition & 1 deletion src/server/middlewares/website.js
Expand Up @@ -56,7 +56,7 @@ var middleware = function(req, res, next) {
return res.send(html)
}else if (req.originalUrl.indexOf('.' + config.files.templates.extension) > -1) {

var html = ''
html = ''

var page = path.join(config.root, config.publish.url, req.originalUrl)
if (coreUtils.file.exist(page)) {
Expand Down
5 changes: 3 additions & 2 deletions src/server/public/scripts/admin.js
@@ -1,4 +1,5 @@
import Handlebars from 'handlebars'
/*global document */

import FormCreate from './modules/FormCreate'
import FormList from './modules/FormList'

Expand All @@ -24,4 +25,4 @@ class Admin {
}
}

var admin = new Admin()
new Admin()
9 changes: 5 additions & 4 deletions src/server/public/scripts/devtool/Devtool.js
@@ -1,3 +1,5 @@
/*global document, $, window */

export class Devtool {

constructor() {
Expand Down Expand Up @@ -35,12 +37,11 @@ export class Devtool {
initDevtool(){
var baseWidth = this.getCookie('editorWidth')
if(typeof baseWidth !== 'undefined' && baseWidth !== null && baseWidth !== '') {
baseWidth = baseWidth
this.form.width(baseWidth)
this.form.attr('data-width', baseWidth)
this.updateBrowserSize()
}
this.ruler.on('mousedown', (e) => {
this.ruler.on('mousedown', () => {
this.body.addClass('resizing')
var newWidth
this.body.on('mousemove', (e) => {
Expand All @@ -61,11 +62,11 @@ export class Devtool {
setTimeout(() => { this.body.removeClass('resizing') }, 1000)
})

$('.close-engine').on('click', (e) => {
$('.close-engine').on('click', () => {
this.body.removeClass('engine-open')
this.form.width(0)
})
$('.open-engine').on('click', (e) => {
$('.open-engine').on('click', () => {
this.body.addClass('engine-open')
this.form.width(this.form.attr('data-width'))
})
Expand Down
12 changes: 6 additions & 6 deletions src/server/public/scripts/modules/EditorAutocomplete.js
@@ -1,10 +1,10 @@
/*global document */

import EditorUtils from '../modules/EditorUtils'
import Json from '../modules/EditorJson'
import Save from '../modules/EditorSave'
import {IframeNode, IframeCommentNode} from '../utils/iframe'
import {IframeCommentNode} from '../utils/iframe'
import Handlebars from 'handlebars'
import Nanoajax from 'nanoajax'
import qs from 'qs'
import on from 'on'

export default class EditorAutocomplete {
Expand Down Expand Up @@ -115,7 +115,7 @@ export default class EditorAutocomplete {
this.onReload._fire()
}

_documentClick(e) {
_documentClick() {
if(this._visible && !this._canSelect) {
if(typeof this._divWrapper.parentNode !== 'undefined' && this._divWrapper.parentNode !== null) {
this._hide()
Expand Down Expand Up @@ -227,7 +227,7 @@ export default class EditorAutocomplete {
cors: true,
method: 'get'
},
(code, responseText, request) => {
(code, responseText) => {
this._showAutocomplete(JSON.parse(responseText), target, val)
})
}else {
Expand Down Expand Up @@ -312,7 +312,7 @@ export default class EditorAutocomplete {
this._startAutocomplete(e.currentTarget)
}

_blur(e) {
_blur() {
this._canSelect = false
this._currentInput = null
this._hide()
Expand Down
5 changes: 2 additions & 3 deletions src/server/public/scripts/modules/EditorBlock.js
@@ -1,10 +1,11 @@
/*global document, abe, $, jQuery */

import {IframeNode, IframeCommentNode} from '../utils/iframe'
import {nextSibling} from '../utils/dom'
import Color from '../utils/color-picker'
import Link from '../utils/link-picker'
import RichText from '../utils/rich-texarea'
import Json from './EditorJson'
import EditorInputs from './EditorInputs'
import EditorUtils from './EditorUtils'
import on from 'on'

Expand Down Expand Up @@ -49,7 +50,6 @@ export default class EditorBlock {
, elem = target
, parent = null
, listGroup = null
, iframeRefAll = null
, blockAttr = ''
, wasFound = false
, startNumber = 0
Expand Down Expand Up @@ -84,7 +84,6 @@ export default class EditorBlock {
Array.prototype.forEach.call(listGroup.querySelectorAll('[data-block]'), (block) => {
var currentBlockAttr = block.getAttribute('data-block')
var nb = parseInt(currentBlockAttr.replace(blockAttr, ''))
// iframeRefAll = IframeNode('#page-template', `[data-abe-block="${currentBlockAttr}"]`)
if(wasFound){
Array.prototype.forEach.call(listGroup.querySelectorAll('.form-abe'), (el) => {
el.setAttribute('value', el.value)
Expand Down
7 changes: 3 additions & 4 deletions src/server/public/scripts/modules/EditorFiles.js
@@ -1,8 +1,7 @@
/*global document, FormData, CONFIG, XMLHttpRequest */

import EditorUtils from '../modules/EditorUtils'
import EditorInputs from '../modules/EditorInputs'
import {IframeNode} from '../utils/iframe'
import qs from 'qs'
import {Promise} from 'es6-promise'
import on from 'on'

export default class EditorFiles {
Expand Down Expand Up @@ -51,7 +50,7 @@ export default class EditorFiles {
percent.textContent = percentage.toFixed(0) + '%'
}
}
xhr.onerror = (e) => { console.log('An error occurred while submitting the form. Maybe your file is too big') }
xhr.onerror = () => { console.log('An error occurred while submitting the form. Maybe your file is too big') }
xhr.onload = () => {
var resp = JSON.parse(xhr.responseText)
if(resp.error){
Expand Down
9 changes: 5 additions & 4 deletions src/server/public/scripts/modules/EditorInputs.js
@@ -1,12 +1,12 @@
/*global document */

import EditorUtils from '../modules/EditorUtils'
import Json from '../modules/EditorJson'
import Save from '../modules/EditorSave'
import {IframeNode, IframeCommentNode} from '../utils/iframe'
import Handlebars from 'handlebars'
import RichText from '../utils/rich-texarea'
import Color from '../utils/color-picker'
import Link from '../utils/link-picker'
import qs from 'qs'
import on from 'on'

export default class EditorInputs {
Expand Down Expand Up @@ -149,8 +149,9 @@ export default class EditorInputs {
var attr = EditorUtils.getAttr(target)

if(typeof maxLength !== 'undefined' && maxLength !== null && maxLength !== '') {
var lastValues
if(count > maxLength) {
var lastValues = JSON.parse(target.getAttribute('last-values'))
lastValues = JSON.parse(target.getAttribute('last-values'))

Array.prototype.forEach.call(optionsChecked, function(optionChecked) {
var unselect = true
Expand All @@ -173,7 +174,7 @@ export default class EditorInputs {
}
})
}else {
var lastValues = '['
lastValues = '['
Array.prototype.forEach.call(optionsChecked, function(optionChecked) {
if(optionChecked.value !== '') {
if(optionChecked.value.indexOf('{') > -1 || optionChecked.value.indexOf('[') > -1) {
Expand Down
7 changes: 4 additions & 3 deletions src/server/public/scripts/modules/EditorJson.js
@@ -1,3 +1,5 @@
/*global document, json, window, CONFIG, alert, location */

import Nanoajax from 'nanoajax'
import qs from 'qs'
import {Promise} from 'es6-promise'
Expand Down Expand Up @@ -29,14 +31,13 @@ export default class Json {

save(type = 'draft', tplPath = null, filePath = null) {
this.saving._fire({type: type})
var p = new Promise((resolve, reject) => {
var p = new Promise((resolve) => {
if(!this.canSave){
resolve({})
this.canSave = true
return
}
var jsonSave = this.data
var abe_source = []

if(typeof json.abe_source !== 'undefined' && json.abe_source !== null) {
delete json.abe_source
Expand All @@ -57,7 +58,7 @@ export default class Json {
headers: this._headers,
method: 'post'
},
(code, responseText, request) => {
(code, responseText) => {
try{
var jsonRes = JSON.parse(responseText)
if(typeof jsonRes.error !== 'undefined' && jsonRes.error !== null) {
Expand Down

0 comments on commit dc6b630

Please sign in to comment.