Skip to content

Commit

Permalink
feature: It's now possible to customize the look and feel of the admi…
Browse files Browse the repository at this point in the history
…n from a plugin (using a custom directory)
  • Loading branch information
gregorybesson committed Jun 15, 2017
1 parent f36ec29 commit b6256ac
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cli/cms/editor/handlebars/abeImport.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ export default function abeImport (file, config, ctx) {
}
if (coreUtils.file.exist(pathToPartial)) {
var html = fse.readFileSync(pathToPartial, 'utf8')
}else {
} else {
html = ''
}

var pluginsCustoms = abeExtend.plugins.instance.getCustoms()
Array.prototype.forEach.call(pluginsCustoms, (pluginCustom) => {
var checkFile = path.join(pluginCustom, `${file}.html`)
if (coreUtils.file.exist(checkFile)) {
html += fse.readFileSync(checkFile, 'utf8')
}
})

var pluginsPartials = abeExtend.plugins.instance.getPartials()
Array.prototype.forEach.call(pluginsPartials, (pluginPartials) => {
var checkFile = path.join(pluginPartials, `${file}.html`)
Expand Down
22 changes: 22 additions & 0 deletions src/cli/extend/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Plugins {
pluginId = path.basename(pluginId)

let plugHook = path.join(dir, pluginId, config.hooks.url, 'hooks.js')
let plugCustom = path.join(dir, pluginId, 'custom')
let plugPartials = path.join(dir, pluginId, 'partials')
let plugTemplates = path.join(dir, pluginId, 'templates')
let plugProcess = path.join(dir, pluginId, 'process')
Expand Down Expand Up @@ -94,6 +95,16 @@ class Plugins {
}catch(e) {
plugin.hooks = null
}

try {
var directoryCustom = fse.lstatSync(plugCustom)
if (directoryCustom.isDirectory()) {
plugin.custom = plugCustom
}
}catch(e) {
plugin.custom = null
}
console.log(plugin)

try {
var directoryPartials = fse.lstatSync(plugPartials)
Expand Down Expand Up @@ -215,6 +226,17 @@ class Plugins {
return partials
}

getCustoms() {
var customs = []
Array.prototype.forEach.call(this._plugins, (plugin) => {
if(typeof plugin.custom !== 'undefined' && plugin.custom !== null) {
customs.push(plugin.custom)
}
})

return customs
}

getRoutes() {
var routes = []
Array.prototype.forEach.call(this._plugins, (plugin) => {
Expand Down

0 comments on commit b6256ac

Please sign in to comment.