fixed post image uploading, cleaned up text editor styles (FINALLY), plugged in error page renderererer

pull/20/head
Ro 5 years ago
parent 84542228a3
commit 532748f688

@ -107,9 +107,19 @@ router.post('/write/:task?', feature_upload, (req, res) => {
id: req.body.page_uuid
});
} 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;

@ -38,11 +38,10 @@ router.get('/add/new', function(req, res) {
fs.readJSON('site/settings.json')
.then(settings => {
//use current index as id, then updated current index and page count
let pageID = 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;
fs.writeJson('site/settings.json', settings)
fs.writeJson('site/settings.json')
.then(() => {
res.render('page-edit', {
id: pageID,
@ -58,11 +57,11 @@ router.get('/add/new', function(req, res) {
});
})
.catch(err => {
console.error('SAVING', err);
res.render('error', { error: err });
});
})
.catch(err => {
console.log('READING', err);
res.render('error', { error: err });
});
} else {
res.redirect('/@/dashboard');

@ -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
a(href="/@/dashboard")
img#the-logo(src="/assets/images/global/the-logo.svg")
#right
-if(status)
include partials/dash-nav
block main-content
script(src='/assets/scripts/dashkit.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'), {
mode: 'dp-below',
format(date) {
console.log('RAW DATE', date);
return self.dateUtils.getDate('origin', date);
format() {
//return self.dateUtils.getDate('origin', date);
}
});
@ -115,7 +114,6 @@ export default class PostEditor {
: currentOption.setAttribute('data-active', 'false');
}
handleEditorOptions(e) {
let self = this;
switch (e) {
case EditorEvent.EDITOR_SAVE:
case EditorEvent.EDITOR_UPDATE:
@ -211,23 +209,12 @@ export default class PostEditor {
// Read in the image file as a data URL.
reader.readAsDataURL(f);
}
/**
if (e.target.id == 'featured-image-upload')
this.handleImageUpload(e.target.id, PostEditor.uploadFiles);
break;
*/
}
}
handleImageUpload(type, files) {
let url = '';
let eventType = '';
let url = '/api/v1/page/add-post-image';
let eventType = DataEvent.POST_IMAGE_ADDED;
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();
for (var i = 0; i < files.length; i++) {
var file = files[i];
@ -235,14 +222,12 @@ export default class PostEditor {
if (!file.type.match('image.*')) {
continue;
}
type == 'featured-image-upload'
? imageData.append('feature_image', file, file.name)
: imageData.append('post_image', file, file.name);
imageData.append('post_image', file, file.name);
}
data.request(url, eventType, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, imageData)
.then(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);
})
.catch(() => {

@ -49,6 +49,12 @@
@import 'main/_settings'
/**
-------------------------------
-- Error
-------------------------------
* */
@import 'main/_error'
/**
-------------------------------
-- Navigation
-------------------------------
* */

@ -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
width 100%
max-width 900px
max-width 880px
margin 0 auto
#edit-post-wrapper
width 98%
//width 98.7%
max-width 900px
margin 0 auto
border-radius 5px
background $primary - 10%
margin-bottom: 40px
overflow hidden
pre
margin 0
code
font-family $monoType
padding 5px
@ -217,6 +219,7 @@
display inline-block
width 100%
max-width 900px
min-height 200px
/**
-------------------------------

@ -70,6 +70,7 @@ svg.icons
a
text-decoration-color $highlight
font-weight: 400
label#the-title
font-size 1.2em

Loading…
Cancel
Save