Skip to content

Commit

Permalink
refactoring: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Oct 7, 2016
1 parent 76ee421 commit e0892ac
Show file tree
Hide file tree
Showing 16 changed files with 21 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/cli/cms/data/revision.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function getDocumentRevision(docPath) {
return result
}

export function getStatusAndDateToFileName(date, file) {
export function getStatusAndDateToFileName(date) {
var res = date.substring(0, 4) + '-'
+ date.substring(4, 6) + '-'
+ date.substring(6, 11) + ':'
Expand Down
4 changes: 2 additions & 2 deletions src/cli/cms/operations/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path'
import {
fileUtils,
FileParser,
cleanSlug,
coreUtils,
cmsTemplate,
cmsOperations,
config,
Expand All @@ -17,7 +17,7 @@ var create = function(template, pathCreate, name, req, forceJson = {}, duplicate

var templatePath = fileUtils.getTemplatePath(template.replace(config.root, ''))
var filePath = path.join(pathCreate, name)
filePath = cleanSlug(filePath)
filePath = coreUtils.slug.clean(filePath)
filePath = fileUtils.getFilePath(filePath)

if(templatePath !== null && filePath !== null) {
Expand Down
7 changes: 3 additions & 4 deletions src/cli/cms/operations/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ import {Promise} from 'es6-promise'
import path from 'path'

import {
Util
,abeProcess
abeProcess
,FileParser
,cmsData
,config
,fileUtils
,Page
,cmsTemplate
,Hooks
,cleanSlug
,coreUtils
} from '../../'

export function checkRequired(text, json) {
Expand Down Expand Up @@ -55,7 +54,7 @@ export function checkRequired(text, json) {
export function save(url, tplPath, json = null, text = '', type = '', previousSave = null, realType = 'draft', publishAll = false) {
var dateStart = new Date()

url = cleanSlug(url)
url = coreUtils.slug.clean(url)

var p = new Promise((resolve) => {
var isRejectedDoc = false
Expand Down
2 changes: 2 additions & 0 deletions src/cli/core/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import * as sort from './sort'
import * as text from './text'
import locales from './locales'
import * as slug from './slug'

export {
sort
,text
,locales
,slug
}
7 changes: 2 additions & 5 deletions src/cli/core/utils/slugify.js → src/cli/core/utils/slug.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
fileUtils
} from '../../'

function cleanSlug(str) {
export function clean(str) {

if (typeof str === 'undefined' || str === null) return null
if (str.indexOf('.') === -1) { // no extension add one
Expand All @@ -21,7 +21,4 @@ function slugify(str) {
str = slug(str, {separateNumbers: false})
str = `${str}.${config.files.templates.extension}`
return str.toLowerCase()
}

export {cleanSlug as cleanSlug}
export default slugify
}
4 changes: 0 additions & 4 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import Page from './cms/Page'
import FileParser from './core/utils/file-parser'
import fileUtils from './core/utils/file-utils'
import folderUtils from './core/utils/folder-utils'
import slugify from './core/utils/slugify'
import {cleanSlug} from './core/utils/slugify'

// import {getTemplate} from './cms/templates/abe-template'
import Create from './cms/Create'
Expand Down Expand Up @@ -66,8 +64,6 @@ export {
,fse
,Handlebars
,clc
,slugify
,cleanSlug
,FileParser
,folderUtils
,fileUtils
Expand Down
1 change: 0 additions & 1 deletion src/server/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import {
Hooks,
Plugins,
Handlebars,
cleanSlug
} from '../../cli'

import locale from '../helpers/abe-locale'
Expand Down
4 changes: 2 additions & 2 deletions src/server/helpers/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
config,
Page,
cmsTemplate,
cleanSlug
coreUtils
} from '../../cli'

var page = function (req, res, next) {
var filePath = cleanSlug(req.query.filePath)
var filePath = coreUtils.slug.clean(req.query.filePath)
filePath = fileUtils.getFilePath(filePath)
var html = (req.query.html) ? true : false
var json = null
Expand Down
3 changes: 1 addition & 2 deletions src/server/middlewares/website.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import {
abeProcess,
Hooks,
Plugins,
Handlebars,
cleanSlug
Handlebars
} from '../../cli'

import locale from '../helpers/abe-locale'
Expand Down
1 change: 0 additions & 1 deletion src/server/routes/get-create.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
fileUtils,
FileParser,
cleanSlug,
config,
cmsOperations,
Hooks
Expand Down
5 changes: 2 additions & 3 deletions src/server/routes/get-delete.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {
FileParser,
Hooks,
cleanSlug
Hooks
} from '../../cli'

var route = function(req, res, next){
Hooks.instance.trigger('beforeRoute', req, res, next)
if(typeof res._header !== 'undefined' && res._header !== null) return

var filePath = cleanSlug(req.query.filePath)
var filePath = coreUtils.slug.clean(req.query.filePath)
var dirPath = FileParser.deleteFile(filePath)

var result = {
Expand Down
1 change: 0 additions & 1 deletion src/server/routes/get-list-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import hooksDefault from '../../hooks/hooks'
import {
fileUtils,
FileParser,
cleanSlug,
config,
Hooks,
Plugins
Expand Down
1 change: 0 additions & 1 deletion src/server/routes/get-list-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Handlebars from 'handlebars'
import {
fileUtils,
FileParser,
cleanSlug,
config,
save,
Hooks
Expand Down
4 changes: 2 additions & 2 deletions src/server/routes/get-unpublish.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
cleanSlug
coreUtils
,FileParser
,Hooks
} from '../../cli'
Expand All @@ -8,7 +8,7 @@ var route = function(req, res, next){
Hooks.instance.trigger('beforeRoute', req, res, next)
if(typeof res._header !== 'undefined' && res._header !== null) return

var filePath = cleanSlug(req.query.filePath)
var filePath = coreUtils.slug.clean(req.query.filePath)
FileParser.unpublishFile(filePath)

var result = {
Expand Down
4 changes: 2 additions & 2 deletions src/server/routes/post-publish.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
fileUtils,
cmsOperations,
cleanSlug,
coreUtils,
Hooks,
Manager
} from '../../cli'
Expand All @@ -10,7 +10,7 @@ var route = function(req, res, next){
Hooks.instance.trigger('beforeRoute', req, res, next)
if(typeof res._header !== 'undefined' && res._header !== null) return

var filePath = cleanSlug(req.body.filePath)
var filePath = coreUtils.slug.clean(req.body.filePath)
var p = new Promise((resolve) => {
cmsOperations.save.save(
fileUtils.getFilePath(filePath),
Expand Down
4 changes: 2 additions & 2 deletions test/url.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var chai = require('chai');

var cleanSlug = require('../src/cli').cleanSlug
var coreUtils = require('../src/cli').coreUtils
var fse = require('fs-extra')
var config = require('../src/cli').config
config.set({root: __dirname + '/fixtures'})
Expand All @@ -15,7 +15,7 @@ describe('Url', function() {
*/
it('configuration file', function() {
for(var key in urls){
chai.assert.equal(cleanSlug(key), urls[key] + config.files.templates.extension, key + 'slugified url did not match')
chai.assert.equal(coreUtils.slug.clean(key), urls[key] + config.files.templates.extension, key + 'slugified url did not match')
}
});

Expand Down

0 comments on commit e0892ac

Please sign in to comment.