Skip to content

Commit

Permalink
refactoring:fix bugs + linting
Browse files Browse the repository at this point in the history
  • Loading branch information
gregorybesson committed Oct 9, 2016
1 parent e79fdef commit 1195ed1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
20 changes: 20 additions & 0 deletions src/server/helpers/abe-locale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import fse from 'fs-extra'
import extend from 'extend'
import clc from 'cli-color'
import path from 'path'

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

var result = {}

var pathToLocale = path.join(__dirname, '../' + config.localeFolder, config.intlData.locales)
var files = fse.readdirSync(pathToLocale)

Array.prototype.forEach.call(files, (file) => {
var json = fse.readJsonSync(pathToLocale + '/' + file)
result = extend(true, result, json)
})

export default result
4 changes: 2 additions & 2 deletions src/server/helpers/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ var page = function (req, res, next) {

cmsData.source.getDataList(path.dirname(linkPath), text, json)
.then(() => {
var page = new Page(template, text, json, html)
var page = new Page(templateId, text, json, html)
res.set('Content-Type', 'text/html')
res.send(page.html)
}).catch(function(e) {
console.error(e)
})
}else {
text = cmsData.source.removeDataList(text)
var page = new Page(template, text, json, html)
var page = new Page(templateId, text, json, html)
res.set('Content-Type', 'text/html')
res.send(page.html)
}
Expand Down
15 changes: 1 addition & 14 deletions src/server/middlewares/website.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
import path from 'path'
import express from 'express'
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 {
coreUtils,
cmsData,
config,
Page,
abeProcess,
Hooks,
Plugins,
Handlebars
Hooks
} from '../../cli'

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

var middleware = function(req, res, next) {
if (req.originalUrl.indexOf('/abe/') > -1 || req.originalUrl.indexOf('/plugin/') > -1) {
return next()
Expand Down

0 comments on commit 1195ed1

Please sign in to comment.