Skip to content

Commit

Permalink
bug: editor html
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaslabbe committed Oct 28, 2016
1 parent 75e460e commit 73b8dca
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/server/public/scripts/modules/EditorReload.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ export default class Reload {
str = template(json)
doc.open()
doc.write(str)
doc.close()
doc.close()

setTimeout(function () {
var iframeDoc = IframeDocument('#page-template')
if(typeof iframeDoc !== 'undefined' && iframeDoc !== null
Expand Down
22 changes: 13 additions & 9 deletions src/server/routes/get-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ var route = function(req, res, next) {
abeExtend.hooks.instance.trigger('beforeRoute', req, res, next)
if(typeof res._header !== 'undefined' && res._header !== null) return

var debugJson = false
var isHome = true
var jsonPath = null
var linkPath = null
var templatePath = null
var template = null
var fileName = null
var folderPath = null

let p = new Promise((resolve) => {

if(filePath != null) {
fileName = filePath.split('/')
fileName = fileName[fileName.length-1]
fileName = fileName.replace(`.${config.files.templates.extension}`, '')
fileName = fileName[fileName.length-1].replace(`.${config.files.templates.extension}`, '')

folderPath = filePath.split('/')
folderPath.pop()
Expand All @@ -58,15 +58,15 @@ var route = function(req, res, next) {
if(typeof filePathTest !== 'undefined' && filePathTest !== null) {
jsonPath = filePathTest.path
linkPath = filePathTest.abe_meta.link
templatePath = filePathTest.abe_meta.template
template = filePathTest.abe_meta.template
}

if(jsonPath === null || !coreUtils.file.exist(jsonPath)) {
res.redirect('/abe/')
return
}

editor(templatePath, jsonPath, linkPath)
editor(template, jsonPath, linkPath)
.then((result) => {
resolve(result)
}).catch(function(e) {
Expand Down Expand Up @@ -96,7 +96,7 @@ var route = function(req, res, next) {

var _hasBlock = (obj) ? obj.hasBlock : false
var _hasSingleBlock = (obj) ? obj.hasSingleBlock : false
var _template = (filePath) ? '/abe/page/' + req.params[0] + `?filePath=${req.query.filePath}` : false
var _preview = (filePath) ? '/abe/page/' + req.params[0] + `?filePath=${req.query.filePath}` : false
var _form = (obj) ? obj.form : false
var _json = (obj) ? obj.json : false
var _text = (obj) ? obj.text : false
Expand All @@ -121,8 +121,7 @@ var route = function(req, res, next) {
abeUrl: '/abe/',
test: JSON.stringify(locale),
text: locale,
templatePath: req.params[0],
template: _template,
preview: _preview,
filename: fileName,
folderPath: folderPath,
hasSingleBlock: _hasSingleBlock,
Expand All @@ -141,7 +140,12 @@ var route = function(req, res, next) {
}
EditorVariables = abeExtend.hooks.instance.trigger('afterVariables', EditorVariables)

res.render(config.abeEngine, EditorVariables)
if (filePath.indexOf(`.json`) > -1) {
res.set('Content-Type', 'application/json')
res.send(JSON.stringify(_json))
}else {
res.render(config.abeEngine, EditorVariables)
}
}).catch((e) => {
console.log('error', e)
})
Expand Down
3 changes: 2 additions & 1 deletion src/server/views/partials/page.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- *************** right iframe preview *************** -->
<div class="no-gutter half-view iframe-wrapper">
{{#if template}}
{{#if isHome}}
{{else}}
<iframe id="page-template" data-iframe-src="{{template}}" src="about:blank" sandbox="allow-same-origin allow-scripts allow-popups allow-forms"></iframe>
{{/if}}
<div class="browser-size"></div>
Expand Down

0 comments on commit 73b8dca

Please sign in to comment.