cleaned up dependecies, initiated db-less post editing methodology
This commit is contained in:
parent
d536871fd4
commit
7897a8bca9
20 changed files with 87 additions and 285 deletions
|
@ -1,5 +1,4 @@
|
||||||
import DateUtils from '../../../src/com/utils/DateUtils';
|
import Book from '../../data/Book';
|
||||||
import Pages from '../../data/Book';
|
|
||||||
import StringUtils from '../../../src/com/utils/StringUtils';
|
import StringUtils from '../../../src/com/utils/StringUtils';
|
||||||
import * as DataEvent from '../../../src/com/events/DataEvent';
|
import * as DataEvent from '../../../src/com/events/DataEvent';
|
||||||
import sanitize from 'sanitize-html';
|
import sanitize from 'sanitize-html';
|
||||||
|
@ -13,14 +12,11 @@ const router = express.Router();
|
||||||
const multer = require('multer');
|
const multer = require('multer');
|
||||||
const md = require('markdown-it')('commonmark');
|
const md = require('markdown-it')('commonmark');
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const dateUtils = new DateUtils();
|
const moment = require('moment');
|
||||||
const rightsManager = new RightsManager();
|
const rightsManager = new RightsManager();
|
||||||
const pagesUtil = new Pages();
|
const book = new Book();
|
||||||
const uploadPath =
|
const uploadPath = './public/assets/images/blog/' + moment().format('YYYY');
|
||||||
'./public/assets/images/blog/' +
|
'/' + moment().format('MM');
|
||||||
dateUtils.getDate('year', new Date()) +
|
|
||||||
'/' +
|
|
||||||
dateUtils.getDate('month', new Date());
|
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
fs.ensureDir(uploadPath, () => {
|
fs.ensureDir(uploadPath, () => {
|
||||||
//console.log(err) // => null
|
//console.log(err) // => null
|
||||||
|
@ -47,7 +43,7 @@ var post_upload = multer({
|
||||||
Retrieve Pages
|
Retrieve Pages
|
||||||
*/
|
*/
|
||||||
router.get('/', (req, res) => {
|
router.get('/', (req, res) => {
|
||||||
pagesUtil.grab().then(result => {
|
book.getPage().then(result => {
|
||||||
res.json(result);
|
res.json(result);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import DateUtils from '../../../src/com/utils/DateUtils';
|
|
||||||
import Book from '../../data/Book';
|
import Book from '../../data/Book';
|
||||||
var express = require('express');
|
const express = require('express');
|
||||||
var router = express.Router();
|
const router = express.Router();
|
||||||
var hljs = require('highlight.js/lib/highlight');
|
const hljs = require('highlight.js/lib/highlight');
|
||||||
var hljs_md = require('highlight.js/lib/languages/markdown');
|
const hljs_md = require('highlight.js/lib/languages/markdown');
|
||||||
hljs.registerLanguage('markdown', hljs_md);
|
hljs.registerLanguage('markdown', hljs_md);
|
||||||
const dateUtils = new DateUtils();
|
const moment = require('moment');
|
||||||
const book = new Book();
|
const book = new Book();
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// POSTS
|
// POSTS
|
||||||
|
@ -39,12 +38,7 @@ router.get('/add/new', function(req, res) {
|
||||||
user_status: true,
|
user_status: true,
|
||||||
welcome: 'New Post',
|
welcome: 'New Post',
|
||||||
mode: 'admin',
|
mode: 'admin',
|
||||||
date:
|
date: '',
|
||||||
dateUtils.getDate('year', new Date()) +
|
|
||||||
'-' +
|
|
||||||
dateUtils.getDate('month', new Date()) +
|
|
||||||
'-' +
|
|
||||||
dateUtils.getDate('day', new Date()),
|
|
||||||
status: ['false', 'false', 'false'],
|
status: ['false', 'false', 'false'],
|
||||||
edit: false
|
edit: false
|
||||||
});
|
});
|
||||||
|
@ -61,13 +55,6 @@ router.get('/edit/:id', function(req, res) {
|
||||||
book.getPage(id)
|
book.getPage(id)
|
||||||
.then(page => {
|
.then(page => {
|
||||||
let pretty = hljs.highlight('markdown', page.content).value;
|
let pretty = hljs.highlight('markdown', page.content).value;
|
||||||
let sexydate =
|
|
||||||
dateUtils.getDate('year', page.metadata.created) +
|
|
||||||
'-' +
|
|
||||||
dateUtils.getDate('month', page.metadata.created) +
|
|
||||||
'-' +
|
|
||||||
dateUtils.getDate('day', page.metadata.created);
|
|
||||||
|
|
||||||
res.render('page-edit', {
|
res.render('page-edit', {
|
||||||
id: page.metadata.id,
|
id: page.metadata.id,
|
||||||
title: 'Edit Page',
|
title: 'Edit Page',
|
||||||
|
@ -75,7 +62,7 @@ router.get('/edit/:id', function(req, res) {
|
||||||
welcome: 'Edit Page',
|
welcome: 'Edit Page',
|
||||||
mode: 'admin',
|
mode: 'admin',
|
||||||
page: page.metadata,
|
page: page.metadata,
|
||||||
date: sexydate,
|
date: moment(page.metadata.created).format('YYYY MMM DD'),
|
||||||
colored: pretty,
|
colored: pretty,
|
||||||
feature: page.metadata.feature,
|
feature: page.metadata.feature,
|
||||||
status: [
|
status: [
|
||||||
|
|
27
package-lock.json
generated
27
package-lock.json
generated
|
@ -5063,9 +5063,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"moment": {
|
"moment": {
|
||||||
"version": "2.22.2",
|
"version": "2.24.0",
|
||||||
"resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz",
|
"resolved": "https://registry.npmjs.org/moment/-/moment-2.24.0.tgz",
|
||||||
"integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y="
|
"integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg=="
|
||||||
},
|
},
|
||||||
"moment-timezone": {
|
"moment-timezone": {
|
||||||
"version": "0.5.26",
|
"version": "0.5.26",
|
||||||
|
@ -6029,6 +6029,27 @@
|
||||||
"uuid": "^3.3.2"
|
"uuid": "^3.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"request-promise": {
|
||||||
|
"version": "4.2.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/request-promise/-/request-promise-4.2.5.tgz",
|
||||||
|
"integrity": "sha512-ZgnepCykFdmpq86fKGwqntyTiUrHycALuGggpyCZwMvGaZWgxW6yagT0FHkgo5LzYvOaCNvxYwWYIjevSH1EDg==",
|
||||||
|
"requires": {
|
||||||
|
"bluebird": "^3.5.0",
|
||||||
|
"request-promise-core": "1.1.3",
|
||||||
|
"stealthy-require": "^1.1.1",
|
||||||
|
"tough-cookie": "^2.3.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"request-promise-core": {
|
||||||
|
"version": "1.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.3.tgz",
|
||||||
|
"integrity": "sha512-QIs2+ArIGQVp5ZYbWD5ZLCY29D5CfWizP8eWnm8FoGD1TX61veauETVQbrV60662V0oFBkrDOuaBI8XgtuyYAQ==",
|
||||||
|
"requires": {
|
||||||
|
"lodash": "^4.17.15"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"request-promise-core": {
|
"request-promise-core": {
|
||||||
"version": "1.1.1",
|
"version": "1.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz",
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
"markdown-it": "^8.4.1",
|
"markdown-it": "^8.4.1",
|
||||||
"markdown-yaml-metadata-parser": "^2.0.3",
|
"markdown-yaml-metadata-parser": "^2.0.3",
|
||||||
"memorystore": "^1.6.1",
|
"memorystore": "^1.6.1",
|
||||||
|
"moment": "^2.24.0",
|
||||||
"morgan": "latest",
|
"morgan": "latest",
|
||||||
"multer": "latest",
|
"multer": "latest",
|
||||||
"nodemailer": "latest",
|
"nodemailer": "latest",
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
"pug": "latest",
|
"pug": "latest",
|
||||||
"reframe.js": "^2.2.5",
|
"reframe.js": "^2.2.5",
|
||||||
"request": "^2.88.0",
|
"request": "^2.88.0",
|
||||||
|
"request-promise": "^4.2.5",
|
||||||
"sanitize-html": "^1.20.1",
|
"sanitize-html": "^1.20.1",
|
||||||
"sequelize": "^4.44.3",
|
"sequelize": "^4.44.3",
|
||||||
"sequelize-cli": "^5.5.1",
|
"sequelize-cli": "^5.5.1",
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_JSON } from './utils/DataUtils';
|
import DataUtils from './utils/DataUtils';
|
||||||
import * as DataEvent from './events/DataEvent';
|
import Manager from './controllers/DashManager';
|
||||||
//import DashManager from './controllers/DashManager';
|
import request from 'request-promise';
|
||||||
|
import * as DataEvent from '../com/events/DataEvent';
|
||||||
//import DBUtils from '../../../../../brain/utils/tools/DBUtils';
|
//import DBUtils from '../../../../../brain/utils/tools/DBUtils';
|
||||||
|
const utils = new DataUtils();
|
||||||
const dataUtils = new DataUtils();
|
const settings = require('../../site/settings.json');
|
||||||
|
|
||||||
export default class Base {
|
export default class Base {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -22,7 +23,7 @@ export default class Base {
|
||||||
.getElementById('login-btn')
|
.getElementById('login-btn')
|
||||||
.addEventListener('click', e => this.handleLogin(e));
|
.addEventListener('click', e => this.handleLogin(e));
|
||||||
} else {
|
} else {
|
||||||
//let dm = new DashManager();
|
let manager = new Manager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -31,33 +32,23 @@ export default class Base {
|
||||||
handleLogin(e) {
|
handleLogin(e) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let authForm = dataUtils.formDataToJSON(document.getElementById('login'));
|
let authForm = utils.formDataToJSON(document.getElementById('login'));
|
||||||
dataUtils
|
|
||||||
.request(
|
request({
|
||||||
'/api/v1/auth/login',
|
method: 'POST',
|
||||||
DataEvent.AUTH_STATUS,
|
uri: settings.base_url + '/api/v1/auth/login',
|
||||||
REQUEST_TYPE_POST,
|
body: authForm,
|
||||||
CONTENT_TYPE_JSON,
|
json: true
|
||||||
authForm
|
})
|
||||||
)
|
.then(res => {
|
||||||
.then(r => {
|
if (res.type === DataEvent.REQUEST_LAME) {
|
||||||
let response = JSON.parse(r.request['response']);
|
e.target.innerHTML = res.message;
|
||||||
if (response.type === DataEvent.REQUEST_LAME) {
|
|
||||||
e.target.innerHTML = response.message;
|
|
||||||
setTimeout(() => {
|
|
||||||
e.target.innerHTML = 'TRY IT AGAIN, HOMIE';
|
|
||||||
}, 1500);
|
|
||||||
//console.log('NOPE', response.message);
|
|
||||||
//self.dashManager = new DashManager();
|
|
||||||
} else {
|
} else {
|
||||||
e.target.innerHTML = response.message;
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location = '/@/dashboard';
|
window.location = '/@/dashboard';
|
||||||
}, 500);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
//console.log(err);
|
//console.log('ERROR', err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
import DataUtils, {
|
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_JSON } from '../../../src/com/utils/DataUtils';
|
||||||
REQUEST_TYPE_POST,
|
import * as DataEvent from '../../../src/com/events/DataEvent';
|
||||||
CONTENT_TYPE_JSON
|
|
||||||
} from '../../../brain/utils/tools/DataUtils';
|
|
||||||
import * as DataEvent from '../../../brain/utils/events/DataEvent';
|
|
||||||
export default class Mailer {
|
export default class Mailer {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
import DataUtils, {
|
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_JSON } from '../../../src/com/utils/DataUtils';
|
||||||
REQUEST_TYPE_POST,
|
import * as DataEvent from '../../../src/com/events/DataEvent';
|
||||||
CONTENT_TYPE_JSON
|
import DBUtils from '../../../src/com/utils/DBUtils';
|
||||||
} from '../../../brain/utils/tools/DataUtils';
|
|
||||||
import DateUtils from '../../../brain/utils/tools/DateUtils';
|
|
||||||
import * as DataEvent from '../../../brain/utils/events/DataEvent';
|
|
||||||
import DBUtils from '../../../brain/utils/tools/DBUtils';
|
|
||||||
export default class NavActions {
|
export default class NavActions {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {
|
constructor() {
|
||||||
this.dataUtils = new DataUtils();
|
this.dataUtils = new DataUtils();
|
||||||
this.dateUtils = new DateUtils();
|
|
||||||
this.dbutils = new DBUtils();
|
this.dbutils = new DBUtils();
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
import DataUtils, {
|
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_JSON } from '../utils/DataUtils';
|
||||||
REQUEST_TYPE_POST,
|
import StringUtils from '../utils/StringUtils';
|
||||||
CONTENT_TYPE_JSON
|
import DBUtils from '../utils/DBUtils';
|
||||||
} from '../../../brain/utils/tools/DataUtils';
|
|
||||||
import StringUtils from '../../../brain/utils/tools/StringUtils';
|
|
||||||
import DateUtils from '../../../brain/utils/tools/DateUtils';
|
|
||||||
import DBUtils from '../../../brain/utils/tools/DBUtils';
|
|
||||||
var uuidv4 = require('uuid/v4');
|
var uuidv4 = require('uuid/v4');
|
||||||
import * as DataEvent from '../../../brain/utils/events/DataEvent';
|
import * as DataEvent from '../events/DataEvent';
|
||||||
export default class PostActions {
|
export default class PostActions {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
import DataUtils, {
|
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_JSON } from '../../../src/com/utils/DataUtils';
|
||||||
REQUEST_TYPE_POST,
|
import * as DataEvent from '../../../src/com/events/DataEvent';
|
||||||
CONTENT_TYPE_JSON
|
|
||||||
} from '../../../brain/utils/tools/DataUtils';
|
|
||||||
import DateUtils from '../../../brain/utils/tools/DateUtils';
|
|
||||||
import * as DataEvent from '../../../brain/utils/events/DataEvent';
|
|
||||||
export default class SettingsActions {
|
export default class SettingsActions {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
constructor() {
|
constructor() {
|
||||||
this.dataUtils = new DataUtils();
|
this.dataUtils = new DataUtils();
|
||||||
this.dateUtils = new DateUtils();
|
|
||||||
}
|
}
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// methods
|
// methods
|
||||||
|
|
|
@ -19,7 +19,7 @@ export default class DashManager {
|
||||||
chooseDisplay(section, page) {
|
chooseDisplay(section, page) {
|
||||||
this.currentDisplay = '';
|
this.currentDisplay = '';
|
||||||
switch (section) {
|
switch (section) {
|
||||||
case 'posts':
|
case 'page':
|
||||||
this.currentDisplay = new PostIndex(page);
|
this.currentDisplay = new PostIndex(page);
|
||||||
break;
|
break;
|
||||||
case 'settings':
|
case 'settings':
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import NavActions from '../actions/NavActions';
|
import NavActions from '../actions/NavActions';
|
||||||
import DBUtils from '../../../brain/utils/tools/DBUtils';
|
import DBUtils from '../../../src/com/utils/DBUtils';
|
||||||
export default class NavIndex {
|
export default class NavIndex {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
//TOOLS
|
//TOOLS
|
||||||
import DataUtils, {
|
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_FORM } from '../../../src/com/utils/DataUtils';
|
||||||
REQUEST_TYPE_POST,
|
import * as DataEvent from '../../../src/com/events/DataEvent';
|
||||||
CONTENT_TYPE_FORM
|
|
||||||
} from '../../../brain/utils/tools/DataUtils';
|
|
||||||
import * as DataEvent from '../../../brain/utils/events/DataEvent';
|
|
||||||
import PostActions from '../actions/PostActions';
|
import PostActions from '../actions/PostActions';
|
||||||
import * as EditorEvent from '../../../brain/utils/events/EditorEvent';
|
import * as EditorEvent from '../../../src/com/events/EditorEvent';
|
||||||
import TinyDatePicker from 'tiny-date-picker';
|
import TinyDatePicker from 'tiny-date-picker';
|
||||||
import DateUtils from '../../../brain/utils/tools/DateUtils';
|
import TextEditor from '../../../src/com/ui/TextEditor';
|
||||||
import TextEditor from '../../../brain/utils/ui/TextEditor';
|
import DBUtils, { FINAL_KEY } from '../../../src/com/utils/DBUtils';
|
||||||
import DBUtils, { FINAL_KEY } from '../../../brain/utils/tools/DBUtils';
|
|
||||||
export default class PostEditor {
|
export default class PostEditor {
|
||||||
//TODO - FIX POST FEATURE URLS IN DB
|
//TODO - FIX POST FEATURE URLS IN DB
|
||||||
|
|
||||||
|
@ -19,7 +15,6 @@ export default class PostEditor {
|
||||||
constructor() {
|
constructor() {
|
||||||
let self = this;
|
let self = this;
|
||||||
this.dataUtils = new DataUtils();
|
this.dataUtils = new DataUtils();
|
||||||
this.dateUtils = new DateUtils();
|
|
||||||
this.urlPieces = document.URL.split('/');
|
this.urlPieces = document.URL.split('/');
|
||||||
this.dbUtils = new DBUtils();
|
this.dbUtils = new DBUtils();
|
||||||
this.post = [];
|
this.post = [];
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import SettingsActions from '../actions/SettingsActions';
|
import SettingsActions from '../actions/SettingsActions';
|
||||||
import DataUtils, {
|
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_FORM } from '../../../src/com/utils/DataUtils';
|
||||||
REQUEST_TYPE_POST,
|
import * as DataEvent from '../../../src/com/events/DataEvent';
|
||||||
CONTENT_TYPE_FORM
|
|
||||||
} from '../../../brain/utils/tools/DataUtils';
|
|
||||||
import * as DataEvent from '../../../brain/utils/events/DataEvent';
|
|
||||||
import Mailer from '../actions/Mailer';
|
import Mailer from '../actions/Mailer';
|
||||||
export default class SettingsIndex {
|
export default class SettingsIndex {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import * as DataEvent from '../../../brain/tools/events/DataEvent';
|
import * as DataEvent from '../events/DataEvent';
|
||||||
import DateUtils from '../../../brain/tools/utils/DateUtils';
|
|
||||||
import { position } from 'caret-pos';
|
import { position } from 'caret-pos';
|
||||||
import EventEmitter from '../../../brain/tools/events/EventEmitter';
|
import EventEmitter from '../events/EventEmitter';
|
||||||
import * as EditorEvent from '../../../brain/tools/events/EditorEvent';
|
import * as EditorEvent from '../events/EditorEvent';
|
||||||
class TextEditor extends EventEmitter {
|
class TextEditor extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* Text Editor UI Component
|
* Text Editor UI Component
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_JSON } from '../tools/DataUtils';
|
import DataUtils, { REQUEST_TYPE_POST, CONTENT_TYPE_JSON } from './DataUtils';
|
||||||
import Dexie from 'dexie';
|
import Dexie from 'dexie';
|
||||||
import * as DataEvent from '../events/DataEvent';
|
import * as DataEvent from '../events/DataEvent';
|
||||||
export var COUNT;
|
export var COUNT;
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
class DOMUtils {
|
|
||||||
//--------------------------
|
|
||||||
// constructor
|
|
||||||
//--------------------------
|
|
||||||
constructor() {}
|
|
||||||
//--------------------------
|
|
||||||
// methods
|
|
||||||
//--------------------------
|
|
||||||
getWindowXY() {
|
|
||||||
var w = window,
|
|
||||||
d = document,
|
|
||||||
e = d.documentElement,
|
|
||||||
g = d.getElementsByTagName('body')[0],
|
|
||||||
x = w.innerWidth || e.clientWidth || g.clientWidth,
|
|
||||||
y = w.innerHeight || e.clientHeight || g.clientHeight;
|
|
||||||
|
|
||||||
var dimensions = {
|
|
||||||
windowHeight: y,
|
|
||||||
windowWidth: x
|
|
||||||
};
|
|
||||||
return dimensions;
|
|
||||||
}
|
|
||||||
//--------------------------
|
|
||||||
// event handlers
|
|
||||||
//--------------------------
|
|
||||||
}
|
|
||||||
export default DOMUtils;
|
|
|
@ -5,7 +5,7 @@ export const REQUEST_TYPE_DELETE = 'DELETE';
|
||||||
export const CONTENT_TYPE_JSON = 'json';
|
export const CONTENT_TYPE_JSON = 'json';
|
||||||
export const CONTENT_TYPE_FORM = 'x-www-form-urlencoded';
|
export const CONTENT_TYPE_FORM = 'x-www-form-urlencoded';
|
||||||
import EventEmitter from '../events/EventEmitter';
|
import EventEmitter from '../events/EventEmitter';
|
||||||
class DataUtils extends EventEmitter {
|
export default class DataUtils extends EventEmitter {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// constructor
|
// constructor
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -15,46 +15,7 @@ class DataUtils extends EventEmitter {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// methods
|
// methods
|
||||||
//--------------------------
|
//--------------------------
|
||||||
request(
|
|
||||||
requestURL,
|
|
||||||
eventType,
|
|
||||||
requestType = REQUEST_TYPE_GET,
|
|
||||||
contentType = CONTENT_TYPE_JSON,
|
|
||||||
requestData = null
|
|
||||||
) {
|
|
||||||
var self = this;
|
|
||||||
return new Promise(function(resolve, reject) {
|
|
||||||
var request = new XMLHttpRequest();
|
|
||||||
request.upload.onprogress = self.handleLoadProgress;
|
|
||||||
request.open(requestType, requestURL, true);
|
|
||||||
request.onload = () => {
|
|
||||||
if (request.status == 200) {
|
|
||||||
resolve({
|
|
||||||
request,
|
|
||||||
eventType
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
reject({
|
|
||||||
request,
|
|
||||||
eventType
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {
|
|
||||||
switch (contentType) {
|
|
||||||
case CONTENT_TYPE_JSON:
|
|
||||||
request.setRequestHeader('Content-type', 'application/' + contentType);
|
|
||||||
request.send(JSON.stringify(requestData));
|
|
||||||
break;
|
|
||||||
case CONTENT_TYPE_FORM:
|
|
||||||
request.send(requestData);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
request.send();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
imgLoad(url) {
|
imgLoad(url) {
|
||||||
'use strict';
|
'use strict';
|
||||||
// Create new promise with the Promise() constructor;
|
// Create new promise with the Promise() constructor;
|
||||||
|
@ -141,4 +102,3 @@ class DataUtils extends EventEmitter {
|
||||||
//console.log(percentComplete);
|
//console.log(percentComplete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default DataUtils;
|
|
||||||
|
|
|
@ -1,102 +0,0 @@
|
||||||
class DateUtils {
|
|
||||||
//--------------------------
|
|
||||||
// constructor
|
|
||||||
//--------------------------
|
|
||||||
constructor() {}
|
|
||||||
|
|
||||||
//--------------------------
|
|
||||||
// methods
|
|
||||||
//--------------------------
|
|
||||||
getMKtime() {
|
|
||||||
var time =
|
|
||||||
new Date(
|
|
||||||
new Date().getFullYear(),
|
|
||||||
new Date().getMonth(),
|
|
||||||
new Date().getDate(),
|
|
||||||
new Date().getHours(),
|
|
||||||
new Date().getMinutes(),
|
|
||||||
new Date().getSeconds(),
|
|
||||||
0
|
|
||||||
).getTime() / 1000;
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
convertMKtime(seconds) {
|
|
||||||
var date = new Date(seconds * 1000);
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
getDate(type, rawdate) {
|
|
||||||
var day =
|
|
||||||
rawdate != null || rawdate != ''
|
|
||||||
? String(new Date(rawdate).getUTCDate())
|
|
||||||
: String(new Date().getUTCDate());
|
|
||||||
var month =
|
|
||||||
rawdate != null || rawdate != ''
|
|
||||||
? String(new Date(rawdate).getUTCMonth() + 1)
|
|
||||||
: String(new Date().getUTCMonth() + 1);
|
|
||||||
var year =
|
|
||||||
rawdate != null || rawdate != ''
|
|
||||||
? String(new Date(rawdate).getUTCFullYear())
|
|
||||||
: String(new Date().getUTCFullYear());
|
|
||||||
var hour =
|
|
||||||
rawdate != null || rawdate != ''
|
|
||||||
? String(new Date(rawdate).getUTCHours())
|
|
||||||
: String(new Date().getUTCHours());
|
|
||||||
var minute =
|
|
||||||
rawdate != null || rawdate != ''
|
|
||||||
? String(new Date(rawdate).getUTCMinutes())
|
|
||||||
: String(new Date().getUTCMinutes());
|
|
||||||
var seconds =
|
|
||||||
rawdate != null || rawdate != ''
|
|
||||||
? String(new Date(rawdate).getUTCSeconds())
|
|
||||||
: String(new Date().getUTCSeconds());
|
|
||||||
var millisecond =
|
|
||||||
rawdate != null || rawdate != ''
|
|
||||||
? String(new Date(rawdate).getUTCMilliseconds())
|
|
||||||
: String(new Date().getUTCMilliseconds());
|
|
||||||
var offset =
|
|
||||||
rawdate != null || rawdate != ''
|
|
||||||
? String(new Date(rawdate).getTimezoneOffset())
|
|
||||||
: String(new Date().getTimezoneOffset());
|
|
||||||
if (day.length == 1) day = String('0' + day);
|
|
||||||
if (month.length == 1) month = String('0' + month);
|
|
||||||
offset = String(offset / 60);
|
|
||||||
if (offset.length == 1) offset = String('0' + offset);
|
|
||||||
switch (type) {
|
|
||||||
case 'day':
|
|
||||||
return day;
|
|
||||||
|
|
||||||
case 'month':
|
|
||||||
return month;
|
|
||||||
case 'year':
|
|
||||||
return year;
|
|
||||||
case 'stamp':
|
|
||||||
return String(
|
|
||||||
year +
|
|
||||||
'-' +
|
|
||||||
month +
|
|
||||||
'-' +
|
|
||||||
day +
|
|
||||||
' ' +
|
|
||||||
hour +
|
|
||||||
':' +
|
|
||||||
minute +
|
|
||||||
':' +
|
|
||||||
seconds +
|
|
||||||
'.' +
|
|
||||||
millisecond +
|
|
||||||
'-' +
|
|
||||||
offset
|
|
||||||
);
|
|
||||||
default:
|
|
||||||
return String(year + '-' + month + '-' + day);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------
|
|
||||||
// event handlers
|
|
||||||
//--------------------------
|
|
||||||
}
|
|
||||||
|
|
||||||
export default DateUtils;
|
|
|
@ -105,7 +105,7 @@
|
||||||
background $primary - 15%
|
background $primary - 15%
|
||||||
border-radius 3px 0 0 3px
|
border-radius 3px 0 0 3px
|
||||||
display inline-block
|
display inline-block
|
||||||
padding 2.9px
|
padding 5.2px
|
||||||
color $secondary
|
color $secondary
|
||||||
|
|
||||||
#post-options
|
#post-options
|
||||||
|
|
|
@ -13,7 +13,7 @@ a
|
||||||
color $secondary + 10%
|
color $secondary + 10%
|
||||||
|
|
||||||
svg.icons
|
svg.icons
|
||||||
width 30px
|
width 25px
|
||||||
fill $secondary
|
fill $secondary
|
||||||
|
|
||||||
#loader
|
#loader
|
||||||
|
|
Loading…
Reference in a new issue