Skip to content

Commit

Permalink
Merge remote-tracking branch 'abecms/master' into visual_group
Browse files Browse the repository at this point in the history
  • Loading branch information
wonknu committed Mar 27, 2017
2 parents d7a0861 + 9f3725d commit 4a8f604
Show file tree
Hide file tree
Showing 32 changed files with 317 additions and 115 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -19,6 +19,9 @@ before_install:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo apt-get install -y libappindicator1 fonts-liberation; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then sudo dpkg -i google-chrome*.deb; fi
- if [ $TRAVIS_OS_NAME == osx ]; then rm '/usr/local/bin/f2py'; fi
- if [ $TRAVIS_OS_NAME == osx ]; then rm -r '/usr/local/lib/python2.7/site-packages/numpy'; fi
- if [ $TRAVIS_OS_NAME == osx ]; then brew install homebrew/science/opencv; fi
install:
- npm install
- npm run install-selenium
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
* [[`c5ebc689d6`](https://github.com/abecms/abecms/commit/c5ebc689d6)] - **enhancement**: The republish all button only appear when necessary. (gregorybesson)
* [[`efb756c00a`](https://github.com/abecms/abecms/commit/efb756c00a)] - **feature**: Auto-republish for blogs containing less than 500 posts (gregorybesson)
* [[`533fc2a89f`](https://github.com/abecms/abecms/commit/533fc2a89f)] - **doc**: CHANGELOG update (gregorybesson)
* [[`9bad6b9607`](https://github.com/abecms/abecms/commit/9bad6b9607)] - **fix**: scrollTo (gregorybesson)
* [[`7f2507e035`](https://github.com/abecms/abecms/commit/7f2507e035)] - **fix**: scrollTo (gregorybesson)
* [[`a5e63cc521`](https://github.com/abecms/abecms/commit/a5e63cc521)] - Merge branch 'master' of https://github.com/abecms/abecms (gregorybesson)
Expand Down
1 change: 1 addition & 0 deletions src/cli/users/utils.js
Expand Up @@ -196,6 +196,7 @@ export function isAbeRestrictedUrl(currentRoute) {
if( currentRoute.indexOf('/abe/users/forgot') > -1
|| currentRoute.indexOf('/abe/users/login') > -1
|| currentRoute.indexOf('/abe/users/reset') > -1
|| currentRoute.indexOf('/abe/rest/') > -1
|| !/^\/abe\//.test(currentRoute)) {
return false
}
Expand Down
6 changes: 6 additions & 0 deletions src/server/app.js
Expand Up @@ -145,6 +145,12 @@ app.use(middleLogin)
app.use(middleWebsite)
app.use(express.static(__dirname + '/public'))

app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});

cmsTemplates.assets.copy()

let publish = path.join(config.root, config.publish.url)
Expand Down
4 changes: 2 additions & 2 deletions src/server/controllers/editor.js
Expand Up @@ -9,7 +9,7 @@ import {
abeExtend
} from '../../cli'

function add(obj, json, text, util) {
export function add(obj, json, text, util) {
var value = obj.value

if(obj.key.indexOf('[') > -1) {
Expand Down Expand Up @@ -44,7 +44,7 @@ function add(obj, json, text, util) {

util.add(obj)

return value
return obj.value
}

function getDataIdWithNoSlash(key) {
Expand Down
54 changes: 29 additions & 25 deletions src/server/controllers/index.js
@@ -1,31 +1,32 @@
import express from 'express'
import * as abe from '../../cli'
import {
postCreate
,postDuplicate
,postUpdate
,getListUrl
,getListWorkflow
,postListUrlSave
,getListHooks
,getMain
,getPage
,postPage
,getGeneratePost
,operations
,getSaveConfig
,postUpload
,postSqlRequest
,postReference
,getReference
,postStructure
,getStructure
,getPaginate
,getThumbs
,getImage
,users
,getHome
,postProfile
postCreate,
postDuplicate,
postUpdate,
getListUrl,
getListWorkflow,
postListUrlSave,
getListHooks,
getMain,
getPage,
postPage,
getGeneratePost,
operations,
getSaveConfig,
postUpload,
postSqlRequest,
postReference,
getReference,
postStructure,
getStructure,
getPaginate,
getThumbs,
getImage,
users,
getHome,
postProfile,
rest
} from '../routes'

import {
Expand All @@ -38,6 +39,9 @@ var router = express.Router()
abeExtend.hooks.instance.trigger('afterHandlebarsHelpers', Handlebars)
abeExtend.hooks.instance.trigger('beforeAddRoute', router)

router.get('/abe/rest/posts*', rest.posts)
router.get('/abe/rest/post*', rest.post)

router.get('/abe/users/forgot', users.getForgot)
router.get('/abe/users/list', users.getList)
router.get('/abe/users/login', users.getLogin)
Expand Down
44 changes: 4 additions & 40 deletions src/server/middlewares/website.js
Expand Up @@ -8,49 +8,13 @@ import {
} from '../../cli'

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

if (req.originalUrl === '' || req.originalUrl === '/' || req.originalUrl.indexOf('.') === -1) {
var pathWebsite = path.join(config.root, config.publish.url, req.originalUrl)
try {
var directory = fse.lstatSync(pathWebsite)
if (!directory.isDirectory()) {
return next()
}
} catch (e) {
return next()
}
var files = coreUtils.file.getFilesSync(pathWebsite, false)
var folders = coreUtils.file.getFoldersSync(pathWebsite, false)
var html = '<ul>'
html += '<li><a href="/abe/editor">abe</abe></li>'
html += '<br />'
if (req.originalUrl !== '/' && req.originalUrl !== '') {
var parent = req.originalUrl.replace(/\/$/, '').split('/')
parent.pop()
parent = parent.join('/') + '/'
html += '<li><a href="' + parent + '">../</abe></li>'
}

if(typeof folders !== 'undefined' && folders !== null) {
Array.prototype.forEach.call(folders, (folder) => {
var url = folder.path.replace(path.join(config.root,config.publish.url), '')
html += '<li><a href="' + url + '">/' + path.basename(folder.path) + '</a></li>'
})
}
if(typeof files !== 'undefined' && files !== null) {
Array.prototype.forEach.call(files, (file) => {
var url = file.replace(path.join(config.root,config.publish.url), '')
html += '<li><a href="' + url + '">' + path.basename(file) + '</a></li>'
})
}
html += '</ul>'

res.set('Content-Type', 'text/html')
return res.send(html)
}else if (req.originalUrl.indexOf('.' + config.files.templates.extension) > -1) {
res.redirect('/abe')
} else if (req.originalUrl.indexOf('.' + config.files.templates.extension) > -1) {

html = ''

Expand All @@ -65,7 +29,7 @@ var middleware = function(req, res, next) {
res.set('Content-Type', 'text/html')
return res.send(html)

}else {
} else {
return next()
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/public/abecms/css/styles.css

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/server/public/abecms/libs/slider-home.js
@@ -1,5 +1,4 @@
var tweets = twitterFetcher.fetch({
// "profile": {"screenName": 'rihanna'},
"profile": {"screenName": 'abe_cms'},
"domId": 'tweets-slider',
"maxTweets": 10,
Expand Down
4 changes: 3 additions & 1 deletion src/server/routes/get-generate-posts.js
Expand Up @@ -21,6 +21,8 @@ var count = 0
var route = function(req, res) {
// if event-stream
if (req.accepts('text/event-stream')) {
// Approximately 24 days...
req.socket.setTimeout(0x7FFFFFFF);
res.writeHead(200, {
'Content-Type': 'text/event-stream',
'Cache-Control': 'no-cache',
Expand All @@ -38,7 +40,7 @@ var route = function(req, res) {
res.app.removeListener("generate-posts", evt)
}, false);

}else { // if get
} else { // if get
var result
var proc = abeExtend.process('generate-posts', [''], (data) => {
res.app.emit("generate-posts", data)
Expand Down
7 changes: 7 additions & 0 deletions src/server/routes/get-home.js
Expand Up @@ -10,6 +10,13 @@ import {
User
} from '../../cli'

/**
* This route returns the homepage HTML
* @param {[type]} req [description]
* @param {[type]} res [description]
* @param {Function} next [description]
* @return {[type]} [description]
*/
var route = function(req, res, next) {
var manager = {}
manager.home = {files: []}
Expand Down
6 changes: 6 additions & 0 deletions src/server/routes/get-image.js
Expand Up @@ -2,6 +2,12 @@ import {
cmsMedia
} from '../../cli'

/**
* This route returns all the images associated with a name. JSON format
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
var route = function(req, res){
res.set('Content-Type', 'application/json')
res.send(JSON.stringify(cmsMedia.image.getAssociatedImageFileFromThumb(req.query.name)))
Expand Down
7 changes: 7 additions & 0 deletions src/server/routes/get-list-hooks.js
Expand Up @@ -7,6 +7,13 @@ import {
,coreUtils
} from '../../cli'

/**
* This route returns the hooks list as html
* @param {[type]} req [description]
* @param {[type]} res [description]
* @param {Function} next [description]
* @return {[type]} [description]
*/
var route = function(req, res, next) {
var html = ''

Expand Down
8 changes: 8 additions & 0 deletions src/server/routes/get-list-url.js
Expand Up @@ -7,6 +7,14 @@ import {
,config
} from '../../cli'

/**
* This route returns all the available routes in HTML format
* @param {[type]} router [description]
* @param {[type]} req [description]
* @param {[type]} res [description]
* @param {Function} next [description]
* @return {[type]} [description]
*/
var route = function(router, req, res, next) {
abeExtend.hooks.instance.trigger('beforeRoute', req, res, next)
var routes = router.stack
Expand Down
8 changes: 8 additions & 0 deletions src/server/routes/get-list-workflow.js
Expand Up @@ -7,6 +7,14 @@ import {
,config
} from '../../cli'

/**
* this route returns the workflow list in HTML format
* @param {[type]} router [description]
* @param {[type]} req [description]
* @param {[type]} res [description]
* @param {Function} next [description]
* @return {[type]} [description]
*/
var route = function(router, req, res, next) {
abeExtend.hooks.instance.trigger('beforeRoute', req, res, next)
var routes = router.stack
Expand Down
9 changes: 9 additions & 0 deletions src/server/routes/get-main.js
Expand Up @@ -23,6 +23,7 @@ function renderAbeAdmin(EditorVariables, obj, filePath) {
files: []//Manager.instance.getList()
}

manager.nbPosts = Manager.instance.getList().length
manager.list = Manager.instance.getStructureAndTemplates()
manager.editConfig = EditorVariables.express.req.app.get('config')
manager.config = JSON.stringify(config)
Expand Down Expand Up @@ -79,6 +80,13 @@ function renderAbeAdmin(EditorVariables, obj, filePath) {
}
}

/**
* This route returns the editor page as HTML
* @param {[type]} req [description]
* @param {[type]} res [description]
* @param {Function} next [description]
* @return {[type]} [description]
*/
var route = function(req, res, next) {
var filePath = req.originalUrl.replace('/abe/editor', '')
if (filePath === '' || filePath === '/') {
Expand Down Expand Up @@ -128,6 +136,7 @@ var route = function(req, res, next) {
folderPath = path.dirname(filePath)

EditorVariables.isHome = false
EditorVariables.isEditor = true
var filePathTest = cmsData.revision.getDocumentRevision(filePath)
if(typeof filePathTest !== 'undefined' && filePathTest !== null) {
jsonPath = filePathTest.path
Expand Down
7 changes: 7 additions & 0 deletions src/server/routes/get-page.js
Expand Up @@ -4,6 +4,13 @@ import {

import pageHelper from '../helpers/page'

/**
* This route returns the post as draft in HTML format
* @param {[type]} req [description]
* @param {[type]} res [description]
* @param {Function} next [description]
* @return {[type]} [description]
*/
var route = function(req, res, next) {
abeExtend.hooks.instance.trigger('beforeRoute', req, res, next)
if(typeof res._header !== 'undefined' && res._header !== null) return
Expand Down
7 changes: 7 additions & 0 deletions src/server/routes/get-paginate.js
Expand Up @@ -4,6 +4,13 @@ import {
Manager
} from '../../cli'

/**
* This route returns filtered list of posts in JSON format
* @param {[type]} req [description]
* @param {[type]} res [description]
* @param {Function} next [description]
* @return {[type]} [description]
*/
var route = function(req, res, next){
var start = 0
var length = 25
Expand Down
6 changes: 6 additions & 0 deletions src/server/routes/get-reference.js
Expand Up @@ -8,6 +8,12 @@ import {
Handlebars
} from '../../cli'

/**
* This route returns the references files in HTML format
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
var route = function(req, res){
var manager = {}
manager.home = {files: []}
Expand Down
7 changes: 7 additions & 0 deletions src/server/routes/get-save-config.js
Expand Up @@ -3,6 +3,13 @@ import {
abeExtend
} from '../../cli'

/**
* This route saves the config en returns result as JSON
* @param {[type]} req [description]
* @param {[type]} res [description]
* @param {Function} next [description]
* @return {[type]} [description]
*/
var route = function(req, res, next){
abeExtend.hooks.instance.trigger('beforeRoute', req, res, next)
if(typeof res._header !== 'undefined' && res._header !== null) return
Expand Down
6 changes: 6 additions & 0 deletions src/server/routes/get-structure.js
Expand Up @@ -8,6 +8,12 @@ import {
Handlebars
} from '../../cli'

/**
* This route returns the structure as HTML
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
var route = function(req, res){
var manager = {}
manager.home = {files: []}
Expand Down
6 changes: 6 additions & 0 deletions src/server/routes/get-thumbs.js
Expand Up @@ -2,6 +2,12 @@ import {
Manager
} from '../../cli'

/**
* This route returns the list of uploaded images in JSON format
* @param {[type]} req [description]
* @param {[type]} res [description]
* @return {[type]} [description]
*/
var route = function(req, res){
res.set('Content-Type', 'application/json')
res.send(JSON.stringify({thumbs: Manager.instance.getThumbsList()}))
Expand Down

0 comments on commit 4a8f604

Please sign in to comment.