2019-11-24 01:09:37 +01:00
|
|
|
import Book from '../../data/Book';
|
2019-11-23 17:40:51 +01:00
|
|
|
import StringUtils from '../../../src/com/utils/StringUtils';
|
|
|
|
import * as DataEvent from '../../../src/com/events/DataEvent';
|
2019-11-20 02:17:39 +01:00
|
|
|
import sanitize from 'sanitize-html';
|
|
|
|
import RightsManager, {
|
|
|
|
TASK_CREATE,
|
|
|
|
TASK_UPDATE,
|
|
|
|
OBJECT_POST
|
2019-11-23 17:40:51 +01:00
|
|
|
} from '../../../src/com/utils/RightsManager';
|
2019-11-20 02:17:39 +01:00
|
|
|
const express = require('express');
|
|
|
|
const router = express.Router();
|
|
|
|
const multer = require('multer');
|
|
|
|
const md = require('markdown-it')('commonmark');
|
|
|
|
const fs = require('fs-extra');
|
2019-11-24 01:09:37 +01:00
|
|
|
const moment = require('moment');
|
2019-11-20 02:17:39 +01:00
|
|
|
const rightsManager = new RightsManager();
|
2019-11-24 01:09:37 +01:00
|
|
|
const book = new Book();
|
2019-11-24 21:23:01 +01:00
|
|
|
const uploadPath =
|
|
|
|
'./public/assets/images/blog/' + moment().format('YYYY') + '/' + moment().format('MM');
|
2019-11-20 02:17:39 +01:00
|
|
|
const _ = require('lodash');
|
|
|
|
fs.ensureDir(uploadPath, () => {
|
|
|
|
// dir has now been created, including the directory it is to be placed in
|
|
|
|
});
|
|
|
|
var storage = multer.diskStorage({
|
|
|
|
destination: function(req, file, cb) {
|
|
|
|
cb(null, uploadPath);
|
|
|
|
},
|
|
|
|
filename: function(req, file, cb) {
|
|
|
|
var splice = file.originalname.split(':');
|
|
|
|
cb(null, splice[0]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var feature_upload = multer({
|
|
|
|
storage: storage
|
|
|
|
}).array('feature_image');
|
|
|
|
var post_upload = multer({
|
|
|
|
storage: storage
|
|
|
|
}).array('post_image');
|
|
|
|
|
|
|
|
/***
|
|
|
|
Retrieve Pages
|
|
|
|
*/
|
|
|
|
router.get('/', (req, res) => {
|
2019-11-24 01:09:37 +01:00
|
|
|
book.getPage().then(result => {
|
2019-11-20 02:17:39 +01:00
|
|
|
res.json(result);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-11-24 21:23:01 +01:00
|
|
|
/***
|
|
|
|
Update Page
|
|
|
|
*/
|
|
|
|
router.post('/write', feature_upload, (req, res) => {
|
|
|
|
console.log('FILEZ BRAH', req.files);
|
|
|
|
});
|
|
|
|
|
2019-11-20 02:17:39 +01:00
|
|
|
module.exports = router;
|