forked from projects/fipamo
fixed post image uploading, cleaned up text editor styles (FINALLY), plugged in error page renderererer
This commit is contained in:
parent
84542228a3
commit
532748f688
9 changed files with 66 additions and 29 deletions
|
@ -107,9 +107,19 @@ router.post('/write/:task?', feature_upload, (req, res) => {
|
||||||
id: req.body.page_uuid
|
id: req.body.page_uuid
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.json({ type: DataEvent.PAGE_UPDATED, message: 'Page Has been saved' });
|
res.json({ type: DataEvent.PAGE_UPDATED, message: 'Page saved, boss' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
router.post('/add-post-image', post_upload, function(req, res) {
|
||||||
|
//console.log(req.body);
|
||||||
|
var image = req.files[0].path;
|
||||||
|
return res.json({
|
||||||
|
type: DataEvent.POST_IMAGE_ADDED,
|
||||||
|
message: 'Added Image',
|
||||||
|
url: '/' + image.substr(7, image.length)
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
module.exports = router;
|
module.exports = router;
|
||||||
|
|
|
@ -38,11 +38,10 @@ router.get('/add/new', function(req, res) {
|
||||||
fs.readJSON('site/settings.json')
|
fs.readJSON('site/settings.json')
|
||||||
.then(settings => {
|
.then(settings => {
|
||||||
//use current index as id, then updated current index and page count
|
//use current index as id, then updated current index and page count
|
||||||
|
|
||||||
let pageID = settings.library_stats.current_index;
|
let pageID = settings.library_stats.current_index;
|
||||||
settings.library_stats.current_index = ++settings.library_stats.current_index;
|
settings.library_stats.current_index = ++settings.library_stats.current_index;
|
||||||
settings.library_stats.total_pages = ++settings.library_stats.total_pages;
|
settings.library_stats.total_pages = ++settings.library_stats.total_pages;
|
||||||
fs.writeJson('site/settings.json', settings)
|
fs.writeJson('site/settings.json')
|
||||||
.then(() => {
|
.then(() => {
|
||||||
res.render('page-edit', {
|
res.render('page-edit', {
|
||||||
id: pageID,
|
id: pageID,
|
||||||
|
@ -58,11 +57,11 @@ router.get('/add/new', function(req, res) {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.error('SAVING', err);
|
res.render('error', { error: err });
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log('READING', err);
|
res.render('error', { error: err });
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.redirect('/@/dashboard');
|
res.redirect('/@/dashboard');
|
||||||
|
|
8
brain/views/error.pug
Normal file
8
brain/views/error.pug
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
extends frame
|
||||||
|
block main-content
|
||||||
|
#error-index
|
||||||
|
br
|
||||||
|
label#message Ok, so this is... awkward
|
||||||
|
br
|
||||||
|
label#error= error
|
||||||
|
|
|
@ -22,6 +22,9 @@ html(xmlns='http://www.w3.org/1999/xhtml', lang='en', xml:lang="en")
|
||||||
#left
|
#left
|
||||||
a(href="/@/dashboard")
|
a(href="/@/dashboard")
|
||||||
img#the-logo(src="/assets/images/global/the-logo.svg")
|
img#the-logo(src="/assets/images/global/the-logo.svg")
|
||||||
|
#right
|
||||||
|
-if(status)
|
||||||
|
include partials/dash-nav
|
||||||
block main-content
|
block main-content
|
||||||
script(src='/assets/scripts/dashkit.min.js' type="text/javascript")
|
script(src='/assets/scripts/dashkit.min.js' type="text/javascript")
|
||||||
script(src='/assets/scripts/dash.min.js' type="text/javascript")
|
script(src='/assets/scripts/dash.min.js' type="text/javascript")
|
||||||
|
|
|
@ -56,9 +56,8 @@ export default class PostEditor {
|
||||||
);
|
);
|
||||||
TinyDatePicker(document.getElementById('post-date'), {
|
TinyDatePicker(document.getElementById('post-date'), {
|
||||||
mode: 'dp-below',
|
mode: 'dp-below',
|
||||||
format(date) {
|
format() {
|
||||||
console.log('RAW DATE', date);
|
//return self.dateUtils.getDate('origin', date);
|
||||||
return self.dateUtils.getDate('origin', date);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -115,7 +114,6 @@ export default class PostEditor {
|
||||||
: currentOption.setAttribute('data-active', 'false');
|
: currentOption.setAttribute('data-active', 'false');
|
||||||
}
|
}
|
||||||
handleEditorOptions(e) {
|
handleEditorOptions(e) {
|
||||||
let self = this;
|
|
||||||
switch (e) {
|
switch (e) {
|
||||||
case EditorEvent.EDITOR_SAVE:
|
case EditorEvent.EDITOR_SAVE:
|
||||||
case EditorEvent.EDITOR_UPDATE:
|
case EditorEvent.EDITOR_UPDATE:
|
||||||
|
@ -211,23 +209,12 @@ export default class PostEditor {
|
||||||
// Read in the image file as a data URL.
|
// Read in the image file as a data URL.
|
||||||
reader.readAsDataURL(f);
|
reader.readAsDataURL(f);
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
if (e.target.id == 'featured-image-upload')
|
|
||||||
this.handleImageUpload(e.target.id, PostEditor.uploadFiles);
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleImageUpload(type, files) {
|
handleImageUpload(type, files) {
|
||||||
let url = '';
|
let url = '/api/v1/page/add-post-image';
|
||||||
let eventType = '';
|
let eventType = DataEvent.POST_IMAGE_ADDED;
|
||||||
let self = this;
|
let self = this;
|
||||||
type == 'featured-image-upload'
|
|
||||||
? (url = '/api/post/add-feature-image')
|
|
||||||
: (url = '/api/post/add-post-image');
|
|
||||||
type == 'featured-image-upload'
|
|
||||||
? (eventType = DataEvent.FEATURE_IMAGE_ADDED)
|
|
||||||
: (eventType = DataEvent.POST_IMAGE_ADDED);
|
|
||||||
var imageData = new FormData();
|
var imageData = new FormData();
|
||||||
for (var i = 0; i < files.length; i++) {
|
for (var i = 0; i < files.length; i++) {
|
||||||
var file = files[i];
|
var file = files[i];
|
||||||
|
@ -235,14 +222,12 @@ export default class PostEditor {
|
||||||
if (!file.type.match('image.*')) {
|
if (!file.type.match('image.*')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
type == 'featured-image-upload'
|
imageData.append('post_image', file, file.name);
|
||||||
? imageData.append('feature_image', file, file.name)
|
|
||||||
: imageData.append('post_image', file, file.name);
|
|
||||||
}
|
}
|
||||||
data.request(url, eventType, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, imageData)
|
data.request(url, eventType, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, imageData)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
let r = JSON.parse(response.request['response']);
|
let r = JSON.parse(response.request['response']);
|
||||||
if (r.message == DataEvent.POST_IMAGE_ADDED)
|
if (r.type == DataEvent.POST_IMAGE_ADDED)
|
||||||
self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, r.url);
|
self.editor.notify(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, r.url);
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|
|
@ -49,6 +49,12 @@
|
||||||
@import 'main/_settings'
|
@import 'main/_settings'
|
||||||
/**
|
/**
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
-- Error
|
||||||
|
-------------------------------
|
||||||
|
* */
|
||||||
|
@import 'main/_error'
|
||||||
|
/**
|
||||||
|
-------------------------------
|
||||||
-- Navigation
|
-- Navigation
|
||||||
-------------------------------
|
-------------------------------
|
||||||
* */
|
* */
|
||||||
|
|
22
src/styles/main/_error.styl
Normal file
22
src/styles/main/_error.styl
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
#error-index
|
||||||
|
width 100%
|
||||||
|
max-width 900px
|
||||||
|
margin 0 auto;
|
||||||
|
padding: 10px
|
||||||
|
height 100%
|
||||||
|
z-index 10
|
||||||
|
position relative
|
||||||
|
label#title
|
||||||
|
font-size 100px
|
||||||
|
color $highlight
|
||||||
|
font-weight: 500
|
||||||
|
|
||||||
|
label#message
|
||||||
|
font-size 50px
|
||||||
|
color $tertiary
|
||||||
|
font-weight: 500
|
||||||
|
|
||||||
|
label#error
|
||||||
|
font-size 25px
|
||||||
|
color $eventLame
|
||||||
|
font-weight: 500
|
|
@ -190,17 +190,19 @@
|
||||||
|
|
||||||
#edit-post
|
#edit-post
|
||||||
width 100%
|
width 100%
|
||||||
max-width 900px
|
max-width 880px
|
||||||
margin 0 auto
|
margin 0 auto
|
||||||
|
|
||||||
#edit-post-wrapper
|
#edit-post-wrapper
|
||||||
width 98%
|
//width 98.7%
|
||||||
max-width 900px
|
max-width 900px
|
||||||
margin 0 auto
|
|
||||||
border-radius 5px
|
border-radius 5px
|
||||||
background $primary - 10%
|
background $primary - 10%
|
||||||
|
margin-bottom: 40px
|
||||||
|
overflow hidden
|
||||||
|
|
||||||
pre
|
pre
|
||||||
|
margin 0
|
||||||
code
|
code
|
||||||
font-family $monoType
|
font-family $monoType
|
||||||
padding 5px
|
padding 5px
|
||||||
|
@ -217,6 +219,7 @@
|
||||||
display inline-block
|
display inline-block
|
||||||
width 100%
|
width 100%
|
||||||
max-width 900px
|
max-width 900px
|
||||||
|
min-height 200px
|
||||||
|
|
||||||
/**
|
/**
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
|
@ -70,6 +70,7 @@ svg.icons
|
||||||
|
|
||||||
a
|
a
|
||||||
text-decoration-color $highlight
|
text-decoration-color $highlight
|
||||||
|
font-weight: 400
|
||||||
|
|
||||||
label#the-title
|
label#the-title
|
||||||
font-size 1.2em
|
font-size 1.2em
|
||||||
|
|
Loading…
Reference in a new issue