changed reference 'entry' to 'post'; implemented status states for posts (featured, page, published)

This commit is contained in:
Ro 2018-11-10 18:08:00 -05:00
parent e75b50d804
commit 625bab02e5
24 changed files with 470 additions and 325 deletions

View file

@ -57,7 +57,6 @@ var back = require('./routes/back/index');
//api //api
var folioLibrary = require('./api/content/folio'); var folioLibrary = require('./api/content/folio');
var blogLibrary = require('./api/content/posts');
var projectLibrary = require('./api/content/project'); var projectLibrary = require('./api/content/project');
var bookmarkLibrary = require('./api/content/bookmarks'); var bookmarkLibrary = require('./api/content/bookmarks');
var postLibrary = require('./api/content/posts'); var postLibrary = require('./api/content/posts');
@ -67,8 +66,7 @@ var mailer = require('./api/content/mailer');
app.use('/api/folio', folioLibrary); app.use('/api/folio', folioLibrary);
app.use('/api/projects', projectLibrary); app.use('/api/projects', projectLibrary);
app.use('/api/bookmarks', bookmarkLibrary); app.use('/api/bookmarks', bookmarkLibrary);
app.use('/api/posts', postLibrary); app.use('/api/post', postLibrary);
app.use('/api/blog', blogLibrary);
// PAGES // PAGES
app.use('/', front); app.use('/', front);

View file

@ -19,12 +19,12 @@ module.exports = function (sequelize, DataTypes) {
unique: false, unique: false,
allowNull: true allowNull: true
}, },
entry_html: { html: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
unique: false, unique: false,
allowNull: true allowNull: true
}, },
entry_plaintext: { plaintext: {
type: DataTypes.TEXT, type: DataTypes.TEXT,
unique: false, unique: false,
allowNull: true allowNull: true

View file

@ -55,9 +55,9 @@ router.get('/settings/', function (req, res) {
//-------------------------- //--------------------------
// ENTRIES // POSTS
//-------------------------- //--------------------------
router.get('/entries/:page?', function (req, res) { router.get('/posts/:page?', function (req, res) {
var pageNum = req.params.page; var pageNum = req.params.page;
if (pageNum == "" || pageNum == null) pageNum = 1; if (pageNum == "" || pageNum == null) pageNum = 1;
var offset = ((pageNum * 5) - 5); var offset = ((pageNum * 5) - 5);
@ -81,8 +81,8 @@ router.get('/entries/:page?', function (req, res) {
//console.log(e) //console.log(e)
} }
} }
res.render('dash/entries-index', { res.render('dash/posts-index', {
title: 'Dashbord Entries', title: 'Dashbord | Posts',
mode: 'admin', mode: 'admin',
items: pageItems, items: pageItems,
page_index: pageNum, page_index: pageNum,
@ -102,10 +102,10 @@ router.get('/entries/:page?', function (req, res) {
//-------------------------- //--------------------------
// BLOG POST ADD DISPLAY // BLOG POST ADD DISPLAY
//-------------------------- //--------------------------
router.get('/entries/add/new', function (req, res) { router.get('/posts/add/new', function (req, res) {
if (req.session.user) { if (req.session.user) {
res.render('dash/entry-edit', { res.render('dash/post-edit', {
title: 'Add New Entry', title: 'Make New Post',
mode: 'admin', mode: 'admin',
date: DateUtils.getDate('year', new Date()) + "-" + DateUtils.getDate('month', new Date()) + "-" + DateUtils.getDate('day', new Date()), date: DateUtils.getDate('year', new Date()) + "-" + DateUtils.getDate('month', new Date()) + "-" + DateUtils.getDate('day', new Date()),
edit: false edit: false
@ -117,32 +117,33 @@ router.get('/entries/add/new', function (req, res) {
//-------------------------- //--------------------------
// BLOG POST EDIT DISPLAY // BLOG POST EDIT DISPLAY
//-------------------------- //--------------------------
router.get('/entries/edit/:id', function (req, res) { router.get('/posts/edit/:id', function (req, res) {
if (req.session.user) { if (req.session.user) {
Models.Post.findOne({ Models.Post.findOne({
where: { where: {
slug: req.params.id slug: req.params.id
} }
}).then(entry => { }).then(post => {
let featured_img = JSON.parse(entry.feature_image); let featured_img = JSON.parse(post.feature_image);
let featured = 'null'; let featured = 'null';
if (featured_img.length != 0) if (featured_img.length != 0)
featured = featured_img[0].substr(7, featured_img[0].length); featured = featured_img[0].substr(7, featured_img[0].length);
let pretty = hljs.highlight('markdown', entry.entry_plaintext).value; let pretty = hljs.highlight('markdown', post.plaintext).value;
let sexydate let sexydate
if (entry.origin_date == "" || entry.origin_date == null) if (post.origin_date == "" || post.origin_date == null)
sexydate = DateUtils.getDate('year', entry.created_at) + "-" + DateUtils.getDate('month', entry.created_at) + "-" + DateUtils.getDate('day', entry.created_at) sexydate = DateUtils.getDate('year', post.created_at) + "-" + DateUtils.getDate('month', post.created_at) + "-" + DateUtils.getDate('day', post.created_at)
else else
sexydate = entry.origin_date sexydate = post.origin_date
res.render('dash/entry-edit', { res.render('dash/post-edit', {
title: 'Edit Entry', title: 'Edit Post',
mode: 'admin', mode: 'admin',
post: entry, post: post,
date: sexydate, date: sexydate,
colored: pretty, colored: pretty,
html: entry.entry_plaintext, html: post.plaintext,
feature: featured, feature: featured,
status:[String(post.page), String(post.featured), String(post.published)],
edit: true edit: true
}); });
}).then(function (value) { }).then(function (value) {

View file

@ -2138,45 +2138,46 @@ select {
-- Blog -- Blog
------------------------------- -------------------------------
**/ **/
#entries-index { #post-index {
width: 100%; width: 100%;
max-width: 900px; max-width: 900px;
margin: 0 auto; margin: 0 auto;
} }
#entries-index #entries-index-wrapper { #post-index #post-index-wrapper {
padding: 0.75rem; padding: 0.75rem;
} }
#entries-index #entries-index-wrapper a { #post-index #post-index-wrapper a {
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
padding: 3px; padding: 3px;
} }
#entries-index #entries-index-wrapper a.add-new-post { #post-index #post-index-wrapper a.add-new-post {
background: #fc6399; background: #fc6399;
border-radius: 3px; border-radius: 3px;
padding: 3px; padding: 3px;
color: #f2f1ef; color: #f2f1ef;
width: 110px; width: 115px;
text-align: center;
margin-bottom: 10px; margin-bottom: 10px;
} }
#entries-index #entries-index-wrapper a.add-new-post svg { #post-index #post-index-wrapper a.add-new-post svg {
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
} }
#entries-index #entries-index-wrapper a.add-new-post label { #post-index #post-index-wrapper a.add-new-post label {
padding: 5px; padding: 5px;
} }
#entries-index #entries-index-wrapper a.add-new-post span { #post-index #post-index-wrapper a.add-new-post span {
font-size: 0.8em; font-size: 0.8em;
color: #62809b; color: #62809b;
} }
#entries-index #entries-index-wrapper a.add-new-post:hover { #post-index #post-index-wrapper a.add-new-post:hover {
background: #344453; background: #344453;
} }
#entries-index #entries-index-wrapper #entries-list { #post-index #post-index-wrapper #posts-list {
color: #f2f1ef; color: #f2f1ef;
} }
#entries-index #entries-index-wrapper #entries-list a.entry-list-link { #post-index #post-index-wrapper #posts-list a.post-list-link {
display: inline-block; display: inline-block;
vertical-align: top; vertical-align: top;
padding: 3px; padding: 3px;
@ -2186,31 +2187,31 @@ select {
line-height: 0.8em; line-height: 0.8em;
margin: 0 0 20px 0; margin: 0 0 20px 0;
} }
#entries-index #entries-index-wrapper #entries-list a.entry-list-link span { #post-index #post-index-wrapper #posts-list a.post-list-link span {
font-size: 0.7em; font-size: 0.7em;
font-family: 'Apercu-Mono'; font-family: 'Apercu-Mono';
} }
#entries-edit-index { #post-edit-index {
width: 100%; width: 100%;
} }
#entries-edit-index #entries-edit-index-wrapper { #post-edit-index #post-edit-index-wrapper {
width: 100%; width: 100%;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-header { #post-edit-index #post-edit-index-wrapper #post-header {
max-width: 900px; max-width: 900px;
margin: 0 auto; margin: 0 auto;
padding: 0.75rem; padding: 0.75rem;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-header #entry-title #entry_title { #post-edit-index #post-edit-index-wrapper #post-header #post-title #post_title {
background: #354554; background: #354554;
font-family: 'Apercu'; font-family: 'Apercu';
width: 100%; width: 97.6%;
height: 140px; height: 140px;
font-size: 1.5em; font-size: 1.5em;
color: #f2f1ef; color: #f2f1ef;
padding: 5px; padding: 5px;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-header #entry-title #entry-date { #post-edit-index #post-edit-index-wrapper #post-header #post-title #post-date {
background: #32414e; background: #32414e;
border-radius: 0 3px 3px 0; border-radius: 0 3px 3px 0;
width: 105px; width: 105px;
@ -2220,7 +2221,7 @@ select {
vertical-align: top; vertical-align: top;
text-align: center; text-align: center;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-header #entry-title label { #post-edit-index #post-edit-index-wrapper #post-header #post-title label {
background: #2f3d4a; background: #2f3d4a;
border-radius: 3px 0 0 3px; border-radius: 3px 0 0 3px;
display: inline-block; display: inline-block;
@ -2228,7 +2229,44 @@ select {
color: #b2cce5; color: #b2cce5;
line-height: 30px; line-height: 30px;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-header #entry-meta #entry_tags { #post-edit-index #post-edit-index-wrapper #post-header #post-title #post-options {
display: inline-block;
vertical-align: top;
width: 49%;
padding: 0 0 0 3px;
}
#post-edit-index #post-edit-index-wrapper #post-header #post-title #post-options button:nth-child(1) {
border-radius: 3px 0 0 3px;
}
#post-edit-index #post-edit-index-wrapper #post-header #post-title #post-options button:nth-child(4) {
border-radius: 0 3px 3px 0;
}
#post-edit-index #post-edit-index-wrapper #post-header #post-title #post-options button {
width: 25%;
height: 39px;
-moz-transition: all 0.3s linear;
-webkit-transition: all 0.3s linear;
-o-transition: all 0.3s linear;
transition: all 0.3s linear;
margin: 0;
border-radius: 0;
display: inline-block;
vertical-align: top;
text-align: center;
}
#post-edit-index #post-edit-index-wrapper #post-header #post-title #post-options button[data-active='false'] {
background: #b2cce5;
}
#post-edit-index #post-edit-index-wrapper #post-header #post-title #post-options button[data-active='false'] svg {
fill: #374857;
}
#post-edit-index #post-edit-index-wrapper #post-header #post-title #post-options button[data-active='true'] {
background: #f5ab35;
}
#post-edit-index #post-edit-index-wrapper #post-header #post-title #post-options button[data-active='true'] svg {
fill: #553604;
}
#post-edit-index #post-edit-index-wrapper #post-header #post-meta #post_tags {
background: #354554; background: #354554;
font-family: 'Apercu'; font-family: 'Apercu';
width: 97.6%; width: 97.6%;
@ -2236,14 +2274,14 @@ select {
color: #b2cce5; color: #b2cce5;
padding: 5px; padding: 5px;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-header #entry-meta #featured-click, #post-edit-index #post-edit-index-wrapper #post-header #post-meta #featured-click,
#entries-edit-index #entries-edit-index-wrapper #entry-header #entry-meta #post-image { #post-edit-index #post-edit-index-wrapper #post-header #post-meta #post-image {
display: none; display: none;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-feature { #post-edit-index #post-edit-index-wrapper #post-feature {
width: 100%; width: 100%;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-feature #featured-image-drop { #post-edit-index #post-edit-index-wrapper #post-feature #featured-image-drop {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
@ -2254,35 +2292,48 @@ select {
vertical-align: middle; vertical-align: middle;
font-family: 'Apercu-Mono'; font-family: 'Apercu-Mono';
} }
#entries-edit-index #entries-edit-index-wrapper #entry-feature #featured-image-drop label { #post-edit-index #post-edit-index-wrapper #post-feature #featured-image-drop label {
cursor: pointer; cursor: pointer;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-feature #featured-image-drop img { #post-edit-index #post-edit-index-wrapper #post-feature #featured-image-drop img {
width: 100%; width: 100%;
margin: 0;
padding: 0;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-feature #featured-new-image-btn { #post-edit-index #post-edit-index-wrapper #post-feature #featured-new-image-btn {
position: absolute; position: absolute;
margin: 20px; margin: 20px;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-feature #featured-new-image-btn #new-upload-link { #post-edit-index #post-edit-index-wrapper #post-feature #featured-new-image-btn #new-upload-link {
padding-top: 4px; padding-top: 4px;
background: #f2f1ef; background: #f2f1ef;
} }
#entries-edit-index #entries-edit-index-wrapper #entry-feature #featured-new-image-btn #new-upload-link svg { #post-edit-index #post-edit-index-wrapper #post-feature #featured-new-image-btn #new-upload-link svg {
fill: #fc6399; fill: #fc6399;
} }
#entries-edit-index #entries-edit-index-wrapper #edit-content { #post-edit-index #post-edit-index-wrapper #edit-post {
width: 100%; width: 100%;
max-width: 900px; max-width: 900px;
margin: 0 auto; margin: 0 auto;
} }
#entries-edit-index #entries-edit-index-wrapper #edit-content #edit-content-wrapper pre code { #post-edit-index #post-edit-index-wrapper #edit-post #edit-post-wrapper {
width: 98%;
max-width: 900px;
margin: 0 auto;
border-radius: 5px;
background: #32414e;
}
#post-edit-index #post-edit-index-wrapper #edit-post #edit-post-wrapper pre code {
padding: 5px;
border-radius: 5px;
line-height: 1.6em; line-height: 1.6em;
font-size: 1.25em; font-size: 1.25em;
color: #bebebe; color: #bebebe;
word-wrap: normal; word-wrap: normal;
white-space: pre-wrap; white-space: pre-wrap;
line-break: normal; line-break: normal;
display: inline-block;
width: 100%;
} }
.dp-modal { .dp-modal {
position: fixed; position: fixed;
@ -2614,7 +2665,7 @@ select {
#edit-control button { #edit-control button {
background: #b2cce5; background: #b2cce5;
width: 10%; width: 10%;
height: 35px; height: 39px;
-moz-transition: all 0.3s linear; -moz-transition: all 0.3s linear;
-webkit-transition: all 0.3s linear; -webkit-transition: all 0.3s linear;
-o-transition: all 0.3s linear; -o-transition: all 0.3s linear;
@ -2691,15 +2742,6 @@ select {
text-decoration: line-through; text-decoration: line-through;
font-style: italic; font-style: italic;
} }
#edit-content-wrapper {
width: 98%;
max-width: 900px;
margin: 0 auto;
border-radius: 5px;
}
#edit-content-wrapper code {
border-radius: 5px;
}
.hljs { .hljs {
display: block; display: block;
overflow-x: auto; overflow-x: auto;

File diff suppressed because one or more lines are too long

View file

@ -591,7 +591,7 @@ function () {
var _default = StringUtils; var _default = StringUtils;
exports.default = _default; exports.default = _default;
},{}],"tasks/EntryTasks.jsx":[function(require,module,exports) { },{}],"actions/PostActions.jsx":[function(require,module,exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
@ -615,14 +615,14 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var EntryTasks = var PostActions =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
//-------------------------- //--------------------------
// constructor // constructor
//-------------------------- //--------------------------
function EntryTasks() { function PostActions() {
_classCallCheck(this, EntryTasks); _classCallCheck(this, PostActions);
var folio = []; var folio = [];
this.dataUtils = new _DataUtils.default(); this.dataUtils = new _DataUtils.default();
@ -631,7 +631,7 @@ function () {
//-------------------------- //--------------------------
_createClass(EntryTasks, [{ _createClass(PostActions, [{
key: "start", key: "start",
value: function start() {} value: function start() {}
}, { }, {
@ -660,21 +660,24 @@ function () {
var txt = document.createElement("textarea"); var txt = document.createElement("textarea");
txt.innerHTML = document.getElementById('edit-text-code').innerHTML; txt.innerHTML = document.getElementById('edit-post-text').innerHTML;
postData.append("title", document.getElementById('entry_title').value); postData.append("title", document.getElementById('post_title').value);
postData.append('slug', new _StringUtils.default().cleanString(document.getElementById('entry_title').value)); postData.append('slug', new _StringUtils.default().cleanString(document.getElementById('post_title').value));
postData.append("entry_plaintext", txt.value); postData.append("post_plaintext", txt.value);
postData.append("origin_date", document.getElementById('entry-date').value); postData.append("origin_date", document.getElementById('post-date').value);
postData.append("tags", document.getElementById('entry_tags').value); postData.append("tags", document.getElementById('post_tags').value);
postData.append("status_page", document.getElementById('option-page').getAttribute('data-active'));
postData.append("status_feature", document.getElementById('option-feature').getAttribute('data-active'));
postData.append("status_published", document.getElementById('option-published').getAttribute('data-active'));
var postURL; var postURL;
var postEventType; var postEventType;
if (edit) { if (edit) {
var postID = document.getElementById('option-update').getAttribute('data-id'); var postID = document.getElementById('edit-update').getAttribute('data-id');
postURL = "/api/blog/update/" + postID; postURL = "/api/post/update/" + postID;
postEventType = DataEvent.POST_UPDATED; postEventType = DataEvent.POST_UPDATED;
} else { } else {
postURL = "/api/blog/add"; postURL = "/api/post/add";
postEventType = DataEvent.POST_ADDED; postEventType = DataEvent.POST_ADDED;
} }
@ -693,9 +696,9 @@ function () {
key: "deletePost", key: "deletePost",
value: function deletePost() { value: function deletePost() {
var self = this; var self = this;
var postID = document.getElementById('option-update').getAttribute('data-id'); var postID = document.getElementById('edit-update').getAttribute('data-id');
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
self.dataUtils.request("/api/blog/delete/" + postID, DataEvent.POST_DELETED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_FORM).then(function (response) { self.dataUtils.request("/api/post/delete/" + postID, DataEvent.POST_DELETED, _DataUtils.REQUEST_TYPE_POST, _DataUtils.CONTENT_TYPE_FORM).then(function (response) {
resolve({ resolve({
response: response response: response
}); });
@ -704,30 +707,17 @@ function () {
err: err err: err
}); });
}); });
}); }); //this.dataUtils.re
this.dataUtils.re;
}
}, {
key: "validateForm",
value: function validateForm() {
var valid = false;
if (this.entry_form.title.value == "" || this.entry_form.price.value == "" || this.entry_form.description == "") {
return valid;
} else {
valid = true;
return valid;
}
} //-------------------------- } //--------------------------
// event handlers // event handlers
//-------------------------- //--------------------------
}]); }]);
return EntryTasks; return PostActions;
}(); }();
exports.default = EntryTasks; exports.default = PostActions;
},{"../tools/utilities/DataUtils":"tools/utilities/DataUtils.jsx","../tools/events/DataEvent":"tools/events/DataEvent.jsx","../tools/utilities/StringUtils":"tools/utilities/StringUtils.jsx"}],"tools/events/EditorEvent.jsx":[function(require,module,exports) { },{"../tools/utilities/DataUtils":"tools/utilities/DataUtils.jsx","../tools/events/DataEvent":"tools/events/DataEvent.jsx","../tools/utilities/StringUtils":"tools/utilities/StringUtils.jsx"}],"tools/events/EditorEvent.jsx":[function(require,module,exports) {
"use strict"; "use strict";
@ -1457,13 +1447,13 @@ function (_EventEmitter) {
case DataEvent.POST_UPDATED: case DataEvent.POST_UPDATED:
document.getElementById('submit-update').classList.add('icon-hide'); document.getElementById('submit-update').classList.add('icon-hide');
document.getElementById('submit-good').classList.remove('icon-hide'); document.getElementById('submit-good').classList.remove('icon-hide');
document.getElementById('option-update').classList.remove('submit-start'); document.getElementById('edit-update').classList.remove('submit-start');
document.getElementById('option-update').classList.add('submit-cool'); document.getElementById('edit-update').classList.add('submit-cool');
setTimeout(function (f) { setTimeout(function (f) {
document.getElementById('submit-update').classList.remove('icon-hide'); document.getElementById('submit-update').classList.remove('icon-hide');
document.getElementById('submit-good').classList.add('icon-hide'); document.getElementById('submit-good').classList.add('icon-hide');
document.getElementById('option-update').classList.add('submit-start'); document.getElementById('edit-update').classList.add('submit-start');
document.getElementById('option-update').classList.remove('submit-cool'); document.getElementById('edit-update').classList.remove('submit-cool');
}, 2000); }, 2000);
break; break;
@ -1505,50 +1495,50 @@ function (_EventEmitter) {
range.deleteContents(); range.deleteContents();
switch (e.target.id) { switch (e.target.id) {
case "option-bold": case "edit-bold":
range.insertNode(document.createTextNode("**" + pulled + "**")); range.insertNode(document.createTextNode("**" + pulled + "**"));
break; break;
case "option-italic": case "edit-italic":
range.insertNode(document.createTextNode("*" + pulled + "*")); range.insertNode(document.createTextNode("*" + pulled + "*"));
break; break;
case "option-strikethrough": case "edit-strikethrough":
range.insertNode(document.createTextNode("<del>" + pulled + "</del>")); range.insertNode(document.createTextNode("<del>" + pulled + "</del>"));
break; break;
case "option-header1": case "edit-header1":
range.insertNode(document.createTextNode("# " + pulled)); range.insertNode(document.createTextNode("# " + pulled));
break; break;
case "option-header2": case "edit-header2":
range.insertNode(document.createTextNode("## " + pulled)); range.insertNode(document.createTextNode("## " + pulled));
break; break;
case "option-header3": case "edit-header3":
range.insertNode(document.createTextNode("### " + pulled)); range.insertNode(document.createTextNode("### " + pulled));
break; break;
case "option-image": case "edit-image":
this.caretPos = (0, _caretPos.position)(this.textEditor).pos; this.caretPos = (0, _caretPos.position)(this.textEditor).pos;
this.emitEvent(EditorEvent.EDITOR_UPLOAD_POST_IMAGE); this.emitEvent(EditorEvent.EDITOR_UPLOAD_POST_IMAGE);
break; break;
case "submit-save": case "submit-save":
case "option-save": case "edit-save":
this.emitEvent(EditorEvent.EDITOR_SAVE); this.emitEvent(EditorEvent.EDITOR_SAVE);
break; break;
case "submit-update": case "submit-update":
case "option-update": case "edit-update":
this.emitEvent(EditorEvent.EDITOR_UPDATE); this.emitEvent(EditorEvent.EDITOR_UPDATE);
break; break;
case "option-link": case "edit-link":
range.insertNode(document.createTextNode("[" + pulled + "](PASTE URL HERE)")); range.insertNode(document.createTextNode("[" + pulled + "](PASTE URL HERE)"));
break; break;
case "option-delete": case "edit-delete":
this.emitEvent(EditorEvent.EDITOR_DELETE); this.emitEvent(EditorEvent.EDITOR_DELETE);
break; break;
@ -2772,7 +2762,7 @@ var global = arguments[3];
}))); })));
},{}],"controllers/DashEntry.jsx":[function(require,module,exports) { },{}],"controllers/PostEditor.jsx":[function(require,module,exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
@ -2786,7 +2776,7 @@ var DataEvent = _interopRequireWildcard(require("../tools/events/DataEvent"));
var Ease = _interopRequireWildcard(require("../tools/effects/Animate")); var Ease = _interopRequireWildcard(require("../tools/effects/Animate"));
var _EntryTasks = _interopRequireDefault(require("../tasks/EntryTasks")); var _PostActions = _interopRequireDefault(require("../actions/PostActions"));
var EditorEvent = _interopRequireWildcard(require("../tools/events/EditorEvent")); var EditorEvent = _interopRequireWildcard(require("../tools/events/EditorEvent"));
@ -2806,16 +2796,16 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var Entry = var PostEditor =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
//-------------------------- //--------------------------
// constructor // constructor
//-------------------------- //--------------------------
function Entry() { function PostEditor() {
var _this = this; var _this = this;
_classCallCheck(this, Entry); _classCallCheck(this, PostEditor);
reframe('iframe'); reframe('iframe');
var self = this; var self = this;
@ -2823,8 +2813,8 @@ function () {
this.dataUtils = new _DataUtils.default(); this.dataUtils = new _DataUtils.default();
this.dateUtils = new _DateUtils.default(); this.dateUtils = new _DateUtils.default();
if (document.getElementById('edit-text-code')) { if (document.getElementById('edit-post-text')) {
this.editor = new _TextEditor.default(document.getElementById('edit-text-code'), document.getElementById('header').offsetHeight + document.getElementById('entry-header').offsetHeight + document.getElementById('entry-feature').offsetHeight); this.editor = new _TextEditor.default(document.getElementById('edit-post-text'), document.getElementById('header').offsetHeight + document.getElementById('post-header').offsetHeight + document.getElementById('post-feature').offsetHeight);
this.editor.addListener(EditorEvent.EDITOR_DELETE, function (f) { this.editor.addListener(EditorEvent.EDITOR_DELETE, function (f) {
return _this.handleEditorOptions(EditorEvent.EDITOR_DELETE); return _this.handleEditorOptions(EditorEvent.EDITOR_DELETE);
}, false); }, false);
@ -2840,7 +2830,7 @@ function () {
document.getElementById('post-image').addEventListener('change', function (e) { document.getElementById('post-image').addEventListener('change', function (e) {
return _this.handlePostImageAdd(e); return _this.handlePostImageAdd(e);
}, false); }, false);
(0, _tinyDatePicker.default)(document.getElementById('entry-date'), { (0, _tinyDatePicker.default)(document.getElementById('post-date'), {
mode: 'dp-below', mode: 'dp-below',
format: function format(date) { format: function format(date) {
//return date; //return date;
@ -2855,9 +2845,11 @@ function () {
//-------------------------- //--------------------------
_createClass(Entry, [{ _createClass(PostEditor, [{
key: "start", key: "start",
value: function start() { value: function start() {
var _this2 = this;
var self = this; var self = this;
new Ease.default().object({ new Ease.default().object({
targets: document.getElementById('loader'), targets: document.getElementById('loader'),
@ -2890,27 +2882,60 @@ function () {
document.getElementById('featured-click').click(); document.getElementById('featured-click').click();
}); });
} }
var optionButtons = document.querySelectorAll('.post-option-btn');
for (var i = 0, length = optionButtons.length; i < length; i++) {
optionButtons[i].addEventListener('click', function (e) {
return _this2.handlePostOptions(e);
}, false);
}
} }
} //-------------------------- } //--------------------------
// event handlers // event handlers
//-------------------------- //--------------------------
}, {
key: "handlePostOptions",
value: function handlePostOptions(e) {
var currentOption;
switch (e.target.id) {
case "option-page-icon":
case "option-page":
currentOption = document.getElementById('option-page');
break;
case "option-feature-icon":
case "option-feature":
currentOption = document.getElementById('option-feature');
break;
case "option-published-icon":
case "option-published":
currentOption = document.getElementById('option-published');
break;
}
var active = currentOption.getAttribute('data-active');
active == 'false' ? currentOption.setAttribute('data-active', 'true') : currentOption.setAttribute('data-active', 'false');
}
}, { }, {
key: "handleEditorOptions", key: "handleEditorOptions",
value: function handleEditorOptions(e) { value: function handleEditorOptions(e) {
var _this2 = this; var _this3 = this;
switch (e) { switch (e) {
case EditorEvent.EDITOR_SAVE: case EditorEvent.EDITOR_SAVE:
case EditorEvent.EDITOR_UPDATE: case EditorEvent.EDITOR_UPDATE:
var edit = false; var edit = false;
if (e == EditorEvent.EDITOR_UPDATE) edit = true; if (e == EditorEvent.EDITOR_UPDATE) edit = true;
new _EntryTasks.default().submitPost(edit, Entry.uploadFiles).then(function (response) { new _PostActions.default().submitPost(edit, PostEditor.uploadFiles).then(function (response) {
var note = JSON.parse(response['response']['request'].response); var note = JSON.parse(response['response']['request'].response);
_this2.editor.notify(note.message, note.postID); _this3.editor.notify(note.message, note.postID);
if (note.message == DataEvent.POST_ADDED) window.location = "/@/dashboard/entries/edit/" + note.postID; if (note.message == DataEvent.POST_ADDED) window.location = "/@/dashboard/posts/edit/" + note.postID;
}).catch(function (err) { }).catch(function (err) {
console.log(err); console.log(err);
}); });
@ -2918,9 +2943,9 @@ function () {
case EditorEvent.EDITOR_DELETE: case EditorEvent.EDITOR_DELETE:
if (confirm('Aye! You know you\'re deleting this post, right?')) { if (confirm('Aye! You know you\'re deleting this post, right?')) {
new _EntryTasks.default().deletePost().then(function (response) { new _PostActions.default().deletePost().then(function (response) {
var note = JSON.parse(response['response']['request'].response); var note = JSON.parse(response['response']['request'].response);
window.location = "/@/dashboard/entries/"; //console.log(note); window.location = "/@/dashboard/posts/"; //console.log(note);
}).catch(function (err) { }).catch(function (err) {
console.log(err); console.log(err);
}); });
@ -2947,9 +2972,9 @@ function () {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); //console.log("IMAGES " + e.target.files); e.preventDefault(); //console.log("IMAGES " + e.target.files);
Entry.uploadFiles = e.target.files; PostEditor.uploadFiles = e.target.files;
for (var i = 0, f; f = Entry.uploadFiles[i]; i++) { for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) {
// Only process image files. // Only process image files.
if (!f.type.match('image.*')) { if (!f.type.match('image.*')) {
continue; continue;
@ -2960,11 +2985,14 @@ function () {
reader.onload = function (theFile) { reader.onload = function (theFile) {
return function (f) { return function (f) {
// Render thumbnail. // Render thumbnail.
var span = document.createElement('span'); var image = document.createElement('img');
image.src = f.target.result;
image.title = escape(theFile.name);
var span = document.createElement('div');
span.innerHTML = ['<img src="', f.target.result, '" title="', escape(theFile.name), '"/>'].join(''); //document.getElementById('featured-image-drop').insertBefore(span, null); span.innerHTML = ['<img src="', f.target.result, '" title="', escape(theFile.name), '"/>'].join(''); //document.getElementById('featured-image-drop').insertBefore(span, null);
document.getElementById('featured-image-drop').innerHTML = ''; document.getElementById('featured-image-drop').innerHTML = '';
document.getElementById('featured-image-drop').appendChild(span); document.getElementById('featured-image-drop').appendChild(image);
}; };
}(f); // Read in the image file as a data URL. }(f); // Read in the image file as a data URL.
@ -2977,9 +3005,9 @@ function () {
value: function handleDrop(e) { value: function handleDrop(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
Entry.uploadFiles = e.dataTransfer.files; //console.log(MemberArea.uploadFiles.length); PostEditor.uploadFiles = e.dataTransfer.files; //console.log(MemberArea.uploadFiles.length);
for (var i = 0, f; f = Entry.uploadFiles[i]; i++) { for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) {
// Only process image files. // Only process image files.
if (!f.type.match('image.*')) { if (!f.type.match('image.*')) {
continue; continue;
@ -3029,12 +3057,12 @@ function () {
} }
}]); }]);
return Entry; return PostEditor;
}(); }();
exports.default = Entry; exports.default = PostEditor;
Entry.uploadFiles = []; PostEditor.uploadFiles = [];
},{"../tools/utilities/DataUtils":"tools/utilities/DataUtils.jsx","../tools/events/DataEvent":"tools/events/DataEvent.jsx","../tools/effects/Animate":"tools/effects/Animate.jsx","../tasks/EntryTasks":"tasks/EntryTasks.jsx","../tools/events/EditorEvent":"tools/events/EditorEvent.jsx","../tools/utilities/TextEditor":"tools/utilities/TextEditor.jsx","tiny-date-picker":"../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js","../tools/utilities/DateUtils":"tools/utilities/DateUtils.jsx"}],"controllers/DisplayManager.jsx":[function(require,module,exports) { },{"../tools/utilities/DataUtils":"tools/utilities/DataUtils.jsx","../tools/events/DataEvent":"tools/events/DataEvent.jsx","../tools/effects/Animate":"tools/effects/Animate.jsx","../actions/PostActions":"actions/PostActions.jsx","../tools/events/EditorEvent":"tools/events/EditorEvent.jsx","../tools/utilities/TextEditor":"tools/utilities/TextEditor.jsx","tiny-date-picker":"../../../../node_modules/tiny-date-picker/dist/tiny-date-picker.js","../tools/utilities/DateUtils":"tools/utilities/DateUtils.jsx"}],"controllers/DisplayManager.jsx":[function(require,module,exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
@ -3044,7 +3072,7 @@ exports.default = void 0;
var _DataUtils = _interopRequireWildcard(require("../tools/utilities/DataUtils.jsx")); var _DataUtils = _interopRequireWildcard(require("../tools/utilities/DataUtils.jsx"));
var _DashEntry = _interopRequireDefault(require("./DashEntry")); var _PostEditor = _interopRequireDefault(require("./PostEditor"));
var _Animate = _interopRequireDefault(require("../tools/effects/Animate.jsx")); var _Animate = _interopRequireDefault(require("../tools/effects/Animate.jsx"));
@ -3108,9 +3136,8 @@ function () {
this.currentDisplay = ''; //console.log(section+" "+page) this.currentDisplay = ''; //console.log(section+" "+page)
switch (section) { switch (section) {
case 'entries': case 'posts':
this; this.currentDisplay = new _PostEditor.default();
this.currentDisplay = new _DashEntry.default();
break; break;
default: default:
@ -3129,7 +3156,7 @@ function () {
}(); }();
exports.default = DisplayManager; exports.default = DisplayManager;
},{"../tools/utilities/DataUtils.jsx":"tools/utilities/DataUtils.jsx","./DashEntry":"controllers/DashEntry.jsx","../tools/effects/Animate.jsx":"tools/effects/Animate.jsx"}],"Base.jsx":[function(require,module,exports) { },{"../tools/utilities/DataUtils.jsx":"tools/utilities/DataUtils.jsx","./PostEditor":"controllers/PostEditor.jsx","../tools/effects/Animate.jsx":"tools/effects/Animate.jsx"}],"Base.jsx":[function(require,module,exports) {
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
@ -3240,7 +3267,7 @@ var parent = module.bundle.parent;
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') { if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
var hostname = "" || location.hostname; var hostname = "" || location.hostname;
var protocol = location.protocol === 'https:' ? 'wss' : 'ws'; var protocol = location.protocol === 'https:' ? 'wss' : 'ws';
var ws = new WebSocket(protocol + '://' + hostname + ':' + "60962" + '/'); var ws = new WebSocket(protocol + '://' + hostname + ':' + "57869" + '/');
ws.onmessage = function (event) { ws.onmessage = function (event) {
var data = JSON.parse(event.data); var data = JSON.parse(event.data);

File diff suppressed because one or more lines are too long

View file

@ -1,61 +0,0 @@
extends frame
block main-content
-var post_title = ''
-var post_plaintext = ''
-var post_feature = 'null'
-var post_tags = ''
-var post_id = ''
-var post_date = date
if(edit)
-post_title = post.title
-post_plaintext = post.entry_plaintext
-post_feature = feature
-post_tags = post.tags
-post_date = date
#entries-edit-index
#entries-edit-index-wrapper
//h2 EDIT
=post_title
#entry-feature
//label FEATURE IMAGE
if(post_feature == 'null')
#featured-image-drop
| DRAG AND DROP IMAGE OR
label(for="featured-click") CLICK TO CHOOSE
else
#featured-new-image-btn
button#new-upload-link
svg#new-upload-link(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-image-inverted')
#featured-image-drop
img(src=post_feature)
#entry-header.columns
#entry-title.column
textarea(id="entry_title" type='text', name='entry_title' class='post-edit', placeholder='title', required, autofocus)
=post_title
label Date Posted
input(id="entry-date" type="text" value=post_date)
br
#entry-meta.column
textarea(id='entry_tags' type='text', name='entry_tags' class='form-control', placeholder='tags [comma seperated]', autofocus)
=post_tags
include partials/editor
input(id="featured-click" type="file" name="featured-click")
input(id="post-image" type="file" name="post-image")
#edit-content
#edit-content-wrapper
pre
code#edit-text-code(contenteditable="true") !{colored}

View file

@ -1,36 +1,36 @@
#edit-control #edit-control
button#option-bold.content-editor-btn-text.editor-button(title="bold") button#edit-bold.content-editor-btn-text.editor-button(title="bold")
| B | B
button#option-italic.content-editor-btn-text.editor-button(title="italics") button#edit-italic.content-editor-btn-text.editor-button(title="italics")
| I | I
button#option-strikethrough.content-editor-btn-text.editor-button(title="strikethrough") button#edit-strikethrough.content-editor-btn-text.editor-button(title="strikethrough")
| S | S
button#option-link.content-editor-btn-icon.editor-button(title="insert link") button#edit-link.content-editor-btn-icon.editor-button(title="insert link")
svg#option-link(viewBox="0 0 20 20" class="icons") svg#edit-link(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-link') use(xlink:href='/dash/assets/images/sprite.svg#entypo-link')
button#option-header1.content-editor-btn-text.editor-button(title="header 1") button#edit-header1.content-editor-btn-text.editor-button(title="header 1")
| H1 | H1
button#option-header2.content-editor-btn-text.editor-button(title="header 2") button#edit-header2.content-editor-btn-text.editor-button(title="header 2")
| H2 | H2
button#option-header3.content-editor-btn-text.editor-button(title="header 3") button#edit-header3.content-editor-btn-text.editor-button(title="header 3")
| H3 | H3
button#option-image.content-editor-btn-icon.editor-button(title='insert image') button#edit-image.content-editor-btn-icon.editor-button(title='insert image')
svg#option-image(viewBox="0 0 20 20" class="icons") svg#edit-image(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-image') use#edit-image(xlink:href='/dash/assets/images/sprite.svg#entypo-image')
if(edit) if(edit)
button#option-update.post-sumbit-btn.submit-start.editor-button(data-action='blog-update' data-id=post.id type='submit') button#edit-update.post-sumbit-btn.submit-start.editor-button(data-action='blog-update' data-id=post.id type='submit')
svg#submit-update(viewBox="0 0 20 20" class="icons") svg#submit-update(viewBox="0 0 20 20" class="icons")
use#submit-update(xlink:href='/dash/assets/images/sprite.svg#entypo-save' data-action='blog-update' data-id=post.id) use#submit-update(xlink:href='/dash/assets/images/sprite.svg#entypo-save' data-action='blog-update' data-id=post.id)
svg#submit-good.icon-hide(viewBox="0 0 20 20" class="icons") svg#submit-good.icon-hide(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-thumbs-up') use(xlink:href='/dash/assets/images/sprite.svg#entypo-thumbs-up')
svg#submit-error.icon-hide(viewBox="0 0 20 20" class="icons") svg#submit-error.icon-hide(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-thumbs-down') use(xlink:href='/dash/assets/images/sprite.svg#entypo-thumbs-down')
button#option-delete.content-editor-btn-icon.editor-button.submit-delete(for="post-delete" title='delete post') button#edit-delete.content-editor-btn-icon.editor-button.submit-delete(for="post-delete" title='delete post')
svg#option-delete(viewBox="0 0 20 20" class="icons") svg#option-delete(viewBox="0 0 20 20" class="icons")
use#option-delete(xlink:href='/dash/assets/images/sprite.svg#entypo-cross') use#option-delete(xlink:href='/dash/assets/images/sprite.svg#entypo-cross')
else else
button#option-save.post-sumbit-btn.submit-start.editor-button(data-action='blog-add' type='submit') button#edit-save.post-sumbit-btn.submit-start.editor-button(data-action='blog-add' type='submit')
svg#submit-save(viewBox="0 0 20 20" class="icons") svg#submit-save(viewBox="0 0 20 20" class="icons")
use#submit-save(xlink:href='/dash/assets/images/sprite.svg#entypo-plus' data-action='blog-add') use#submit-save(xlink:href='/dash/assets/images/sprite.svg#entypo-plus' data-action='blog-add')

View file

@ -3,10 +3,10 @@
svg(viewBox="0 0 20 20" class="icons") svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-cog') use(xlink:href='/dash/assets/images/sprite.svg#entypo-cog')
label Settings label Settings
a#entries(href="/@/dashboard/entries") a#entries(href="/@/dashboard/posts")
svg(viewBox="0 0 20 20" class="icons") svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-book') use(xlink:href='/dash/assets/images/sprite.svg#entypo-book')
label Entries label Posts
a#bookmarks(href="") a#bookmarks(href="")
svg(viewBox="0 0 20 20" class="icons") svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-bookmarks') use(xlink:href='/dash/assets/images/sprite.svg#entypo-bookmarks')
@ -25,7 +25,7 @@
br br
- var index = 0; - var index = 0;
- for ( index; index < items.length; index++) - for ( index; index < items.length; index++)
a(href="/@/dashboard/entries/edit/"+items[index].slug id=items[index].uuid) a(href="/@/dashboard/posts/edit/"+items[index].slug id=items[index].uuid)
= items[index].title = items[index].title
br br
br br

73
themes/dash/post-edit.pug Normal file
View file

@ -0,0 +1,73 @@
extends frame
block main-content
-var post_title = ''
-var post_plaintext = ''
-var post_feature = 'null'
-var post_tags = ''
-var post_id = ''
-var post_date = date
-var post_status = ['false', 'false', 'false', '']
if(edit)
-post_title = post.title
-post_plaintext = post.plaintext
-post_feature = feature
-post_tags = post.tags
-post_date = date
-post_status = status
#post-edit-index
#post-edit-index-wrapper
//h2 EDIT
=post_title
#post-feature
//label FEATURE IMAGE
if(post_feature == 'null')
#featured-image-drop
| DRAG AND DROP IMAGE OR
label(for="featured-click") CLICK TO CHOOSE
else
#featured-new-image-btn
button#new-upload-link
svg#new-upload-link(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-image-inverted')
#featured-image-drop
img(src=post_feature)
#post-header.columns
#post-title.column
textarea(id="post_title" type='text', name='post_title' class='post-edit', placeholder='title', required, autofocus)
=post_title
label Date Posted
input(id="post-date" type="text" value=post_date)
#post-options
button#option-page.option-inactive.post-option-btn(data-active= status[0])
svg#option-page-icon(viewBox="0 0 20 20" class="icons")
use#option-page-icon(xlink:href='/dash/assets/images/sprite.svg#entypo-pin')
button#option-feature.option-inactive.post-option-btn(data-active= status[1])
svg#option-feature-icon(viewBox="0 0 20 20" class="icons")
use#option-feature-icon(xlink:href='/dash/assets/images/sprite.svg#entypo-star')
button#option-published.option-inactive.post-option-btn(data-active= status[2])
svg#option-published-icon(viewBox="0 0 20 20" class="icons")
use#option-published-icon(xlink:href='/dash/assets/images/sprite.svg#entypo-globe')
button#option-preview.option-inactive(data-active="false")
svg#option-preview-icon(viewBox="0 0 20 20" class="icons")
use#option-preview-icon(xlink:href='/dash/assets/images/sprite.svg#entypo-eye')
#post-meta.column
textarea(id='post_tags' type='text', name='post_tags' class='form-control', placeholder='tags [comma seperated]', autofocus)
=post_tags
include partials/editor
input(id="featured-click" type="file" name="featured-click")
input(id="post-image" type="file" name="post-image")
#edit-post
#edit-post-wrapper
pre
code#edit-post-text(contenteditable="true") !{colored}

View file

@ -1,17 +1,17 @@
extends frame extends frame
block main-content block main-content
#entries-index #post-index
#entries-index-wrapper #post-index-wrapper
h2 Entries h2 Entries
a.add-new-post(href="/@/dashboard/entries/add/new") a.add-new-post(href="/@/dashboard/posts/add/new")
svg#new-upload-link(viewBox="0 0 20 20" class="icons") svg#new-upload-link(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-new-message') use(xlink:href='/dash/assets/images/sprite.svg#entypo-plus')
| NEW POST | NEW POST
#entries-list #posts-list
- var index = 0; - var index = 0;
- for ( index; index < items.length; index++) - for ( index; index < items.length; index++)
- var date = new Date(items[index].created_at) - var date = new Date(items[index].created_at)
a.entry-list-link(href="/@/dashboard/entries/edit/"+items[index].slug id=items[index].uuid) a.post-list-link(href="/@/dashboard/posts/edit/"+items[index].slug id=items[index].uuid)
= items[index].title = items[index].title
br br
span= date.getFullYear()+"-"+date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes() span= date.getFullYear()+"-"+date.getMonth()+"-"+date.getDate()+" "+date.getHours()+":"+date.getMinutes()
@ -21,13 +21,13 @@ block main-content
- if(prev <= 0) prev = page_count - if(prev <= 0) prev = page_count
br br
a.page-btns(href="/@/dashboard/entries/"+prev) a.page-btns(href="/@/dashboard/posts/"+prev)
svg(viewBox="0 0 20 20" class="icons") svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-chevron-left') use(xlink:href='/dash/assets/images/sprite.svg#entypo-chevron-left')
span.paginate= "PAGE "+page_index+" OF "+page_count span.paginate= "PAGE "+page_index+" OF "+page_count
a.page-btns(href="/@/dashboard/entries/"+next) a.page-btns(href="/@/dashboard/posts/"+next)
svg(viewBox="0 0 20 20" class="icons") svg(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-chevron-right') use(xlink:href='/dash/assets/images/sprite.svg#entypo-chevron-right')

View file

@ -1,7 +1,7 @@
import DataUtils, { REQUEST_TYPE_GET, REQUEST_TYPE_PUT, REQUEST_TYPE_POST, REQUEST_TYPE_DELETE, CONTENT_TYPE_JSON, CONTENT_TYPE_FORM } from '../tools/utilities/DataUtils'; import DataUtils, { REQUEST_TYPE_GET, REQUEST_TYPE_PUT, REQUEST_TYPE_POST, REQUEST_TYPE_DELETE, CONTENT_TYPE_JSON, CONTENT_TYPE_FORM } from '../tools/utilities/DataUtils';
import * as DataEvent from '../tools/events/DataEvent'; import * as DataEvent from '../tools/events/DataEvent';
import StringUtils from '../tools/utilities/StringUtils'; import StringUtils from '../tools/utilities/StringUtils';
class EntryTasks { class PostActions {
//-------------------------- //--------------------------
// constructor // constructor
//-------------------------- //--------------------------
@ -35,21 +35,25 @@ class EntryTasks {
//var category = document.getElementById("content_category"); //var category = document.getElementById("content_category");
//let project_form = document.forms.namedItem("folio-project"); //let project_form = document.forms.namedItem("folio-project");
var txt = document.createElement("textarea"); var txt = document.createElement("textarea");
txt.innerHTML = document.getElementById('edit-text-code').innerHTML; txt.innerHTML = document.getElementById('edit-post-text').innerHTML;
postData.append("title", document.getElementById('entry_title').value); postData.append("title", document.getElementById('post_title').value);
postData.append('slug', new StringUtils().cleanString(document.getElementById('entry_title').value)); postData.append('slug', new StringUtils().cleanString(document.getElementById('post_title').value));
postData.append("entry_plaintext", txt.value); postData.append("post_plaintext", txt.value);
postData.append("origin_date", document.getElementById('entry-date').value); postData.append("origin_date", document.getElementById('post-date').value);
postData.append("tags", document.getElementById('entry_tags').value); postData.append("tags", document.getElementById('post_tags').value);
postData.append("status_page", document.getElementById('option-page').getAttribute('data-active'));
postData.append("status_feature", document.getElementById('option-feature').getAttribute('data-active'));
postData.append("status_published", document.getElementById('option-published').getAttribute('data-active'));
let postURL; let postURL;
let postEventType; let postEventType;
if (edit) { if (edit) {
let postID = document.getElementById('option-update').getAttribute('data-id'); let postID = document.getElementById('edit-update').getAttribute('data-id');
postURL = "/api/blog/update/" + postID; postURL = "/api/post/update/" + postID;
postEventType = DataEvent.POST_UPDATED; postEventType = DataEvent.POST_UPDATED;
} else { } else {
postURL = "/api/blog/add"; postURL = "/api/post/add";
postEventType = DataEvent.POST_ADDED; postEventType = DataEvent.POST_ADDED;
} }
self.dataUtils.request(postURL, postEventType, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, postData) self.dataUtils.request(postURL, postEventType, REQUEST_TYPE_POST, CONTENT_TYPE_FORM, postData)
@ -67,9 +71,9 @@ class EntryTasks {
deletePost(){ deletePost(){
let self = this; let self = this;
let postID = document.getElementById('option-update').getAttribute('data-id'); let postID = document.getElementById('edit-update').getAttribute('data-id');
return new Promise(function(resolve, reject){ return new Promise(function(resolve, reject){
self.dataUtils.request("/api/blog/delete/" + postID, DataEvent.POST_DELETED, REQUEST_TYPE_POST, CONTENT_TYPE_FORM) self.dataUtils.request("/api/post/delete/" + postID, DataEvent.POST_DELETED, REQUEST_TYPE_POST, CONTENT_TYPE_FORM)
.then((response) => { .then((response) => {
resolve({ resolve({
response response
@ -80,20 +84,10 @@ class EntryTasks {
}); });
}) })
}) })
this.dataUtils.re //this.dataUtils.re
}
validateForm() {
let valid = false;
if (this.entry_form.title.value == "" || this.entry_form.price.value == "" || this.entry_form.description == "") {
return valid;
} else {
valid = true;
return valid;
}
} }
//-------------------------- //--------------------------
// event handlers // event handlers
//-------------------------- //--------------------------
} }
export { EntryTasks as default } export { PostActions as default }

View file

@ -7,7 +7,7 @@ import DataUtils, {
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,
CONTENT_TYPE_FORM CONTENT_TYPE_FORM
} from '../tools/utilities/DataUtils.jsx'; } from '../tools/utilities/DataUtils.jsx';
import Entry from './DashEntry'; import PostEditor from './PostEditor';
import Animate from '../tools/effects/Animate.jsx'; import Animate from '../tools/effects/Animate.jsx';
class DisplayManager { class DisplayManager {
//-------------------------- //--------------------------
@ -52,9 +52,8 @@ class DisplayManager {
this.currentDisplay = ''; this.currentDisplay = '';
//console.log(section+" "+page) //console.log(section+" "+page)
switch (section) { switch (section) {
case 'entries': case 'posts':
this this.currentDisplay = new PostEditor();
this.currentDisplay = new Entry();
break; break;
default: default:

View file

@ -10,14 +10,14 @@ import DataUtils, {
import * as DataEvent from '../tools/events/DataEvent'; import * as DataEvent from '../tools/events/DataEvent';
import Animate from '../tools/effects/Animate'; import Animate from '../tools/effects/Animate';
import * as Ease from '../tools/effects/Animate'; import * as Ease from '../tools/effects/Animate';
import EntryTasks from '../tasks/EntryTasks'; import PostActions from '../actions/PostActions';
import * as EditorEvent from '../tools/events/EditorEvent'; import * as EditorEvent from '../tools/events/EditorEvent';
import TextEditor from '../tools/utilities/TextEditor'; import TextEditor from '../tools/utilities/TextEditor';
import TinyDatePicker from 'tiny-date-picker'; import TinyDatePicker from 'tiny-date-picker';
import DateUtils from '../tools/utilities/DateUtils'; import DateUtils from '../tools/utilities/DateUtils';
class Entry { class PostEditor {
//-------------------------- //--------------------------
// constructor // constructor
//-------------------------- //--------------------------
@ -27,21 +27,18 @@ class Entry {
this.uploadFiles; this.uploadFiles;
this.dataUtils = new DataUtils(); this.dataUtils = new DataUtils();
this.dateUtils = new DateUtils(); this.dateUtils = new DateUtils();
if (document.getElementById('edit-post-text')) {
if (document.getElementById('edit-text-code')) { this.editor = new TextEditor(document.getElementById('edit-post-text'),
this.editor = new TextEditor(document.getElementById('edit-text-code'),
document.getElementById('header').offsetHeight + document.getElementById('header').offsetHeight +
document.getElementById('entry-header').offsetHeight + document.getElementById('post-header').offsetHeight +
document.getElementById('entry-feature').offsetHeight document.getElementById('post-feature').offsetHeight
); );
this.editor.addListener(EditorEvent.EDITOR_DELETE, f => this.handleEditorOptions(EditorEvent.EDITOR_DELETE), false) this.editor.addListener(EditorEvent.EDITOR_DELETE, f => this.handleEditorOptions(EditorEvent.EDITOR_DELETE), false)
this.editor.addListener(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPLOAD_POST_IMAGE), false) this.editor.addListener(EditorEvent.EDITOR_UPLOAD_POST_IMAGE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPLOAD_POST_IMAGE), false)
this.editor.addListener(EditorEvent.EDITOR_UPDATE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPDATE), false) this.editor.addListener(EditorEvent.EDITOR_UPDATE, f => this.handleEditorOptions(EditorEvent.EDITOR_UPDATE), false)
this.editor.addListener(EditorEvent.EDITOR_SAVE, f => this.handleEditorOptions(EditorEvent.EDITOR_SAVE), false) this.editor.addListener(EditorEvent.EDITOR_SAVE, f => this.handleEditorOptions(EditorEvent.EDITOR_SAVE), false)
document.getElementById('post-image').addEventListener('change', e => this.handlePostImageAdd(e), false); document.getElementById('post-image').addEventListener('change', e => this.handlePostImageAdd(e), false);
TinyDatePicker(document.getElementById('post-date'), {
TinyDatePicker(document.getElementById('entry-date'), {
mode: 'dp-below', mode: 'dp-below',
format(date) { format(date) {
//return date; //return date;
@ -89,12 +86,40 @@ class Entry {
document.getElementById('featured-click').click(); document.getElementById('featured-click').click();
}) })
} }
var optionButtons = document.querySelectorAll('.post-option-btn');
for (var i = 0, length = optionButtons.length; i < length; i++) {
optionButtons[i].addEventListener('click', e => this.handlePostOptions(e), false);
}
} }
} }
//-------------------------- //--------------------------
// event handlers // event handlers
//-------------------------- //--------------------------
handlePostOptions(e) {
let currentOption;
switch (e.target.id) {
case "option-page-icon":
case "option-page":
currentOption = document.getElementById('option-page');
break;
case "option-feature-icon":
case "option-feature":
currentOption = document.getElementById('option-feature');
break;
case "option-published-icon":
case "option-published":
currentOption = document.getElementById('option-published');
break;
}
let active = currentOption.getAttribute('data-active');
(active == 'false') ? currentOption.setAttribute('data-active', 'true') : currentOption.setAttribute('data-active', 'false')
}
handleEditorOptions(e) { handleEditorOptions(e) {
switch (e) { switch (e) {
case EditorEvent.EDITOR_SAVE: case EditorEvent.EDITOR_SAVE:
@ -102,11 +127,11 @@ class Entry {
let edit = false; let edit = false;
if (e == EditorEvent.EDITOR_UPDATE) if (e == EditorEvent.EDITOR_UPDATE)
edit = true; edit = true;
new EntryTasks().submitPost(edit, Entry.uploadFiles).then((response) => { new PostActions().submitPost(edit, PostEditor.uploadFiles).then((response) => {
let note = JSON.parse(response['response']['request'].response); let note = JSON.parse(response['response']['request'].response);
this.editor.notify(note.message, note.postID); this.editor.notify(note.message, note.postID);
if (note.message == DataEvent.POST_ADDED) if (note.message == DataEvent.POST_ADDED)
window.location = "/@/dashboard/entries/edit/" + note.postID; window.location = "/@/dashboard/posts/edit/" + note.postID;
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
}); });
@ -115,9 +140,9 @@ class Entry {
case EditorEvent.EDITOR_DELETE: case EditorEvent.EDITOR_DELETE:
if (confirm('Aye! You know you\'re deleting this post, right?')) { if (confirm('Aye! You know you\'re deleting this post, right?')) {
new EntryTasks().deletePost().then((response) => { new PostActions().deletePost().then((response) => {
let note = JSON.parse(response['response']['request'].response); let note = JSON.parse(response['response']['request'].response);
window.location = "/@/dashboard/entries/"; window.location = "/@/dashboard/posts/";
//console.log(note); //console.log(note);
}).catch((err) => { }).catch((err) => {
console.log(err) console.log(err)
@ -142,8 +167,8 @@ class Entry {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
//console.log("IMAGES " + e.target.files); //console.log("IMAGES " + e.target.files);
Entry.uploadFiles = e.target.files; PostEditor.uploadFiles = e.target.files;
for (var i = 0, f; f = Entry.uploadFiles[i]; i++) { for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) {
// Only process image files. // Only process image files.
if (!f.type.match('image.*')) { if (!f.type.match('image.*')) {
continue; continue;
@ -153,7 +178,10 @@ class Entry {
reader.onload = (function (theFile) { reader.onload = (function (theFile) {
return function (f) { return function (f) {
// Render thumbnail. // Render thumbnail.
var span = document.createElement('span'); var image = document.createElement('img');
image.src = f.target.result;
image.title = escape(theFile.name);
var span = document.createElement('div');
span.innerHTML = [ span.innerHTML = [
'<img src="', '<img src="',
f.target.result, f.target.result,
@ -163,7 +191,7 @@ class Entry {
].join(''); ].join('');
//document.getElementById('featured-image-drop').insertBefore(span, null); //document.getElementById('featured-image-drop').insertBefore(span, null);
document.getElementById('featured-image-drop').innerHTML = ''; document.getElementById('featured-image-drop').innerHTML = '';
document.getElementById('featured-image-drop').appendChild(span); document.getElementById('featured-image-drop').appendChild(image);
}; };
})(f); })(f);
// Read in the image file as a data URL. // Read in the image file as a data URL.
@ -175,9 +203,9 @@ class Entry {
handleDrop(e) { handleDrop(e) {
e.stopPropagation(); e.stopPropagation();
e.preventDefault(); e.preventDefault();
Entry.uploadFiles = e.dataTransfer.files; PostEditor.uploadFiles = e.dataTransfer.files;
//console.log(MemberArea.uploadFiles.length); //console.log(MemberArea.uploadFiles.length);
for (var i = 0, f; f = Entry.uploadFiles[i]; i++) { for (var i = 0, f; f = PostEditor.uploadFiles[i]; i++) {
// Only process image files. // Only process image files.
if (!f.type.match('image.*')) { if (!f.type.match('image.*')) {
continue; continue;
@ -228,8 +256,8 @@ class Entry {
}) })
} }
} }
Entry.uploadFiles = []; PostEditor.uploadFiles = [];
export { export {
Entry as PostEditor as
default default
} }

View file

@ -11,7 +11,7 @@ import ProjectFolio from '../tasks/ProjectFolio';
import TextEffects from '../tools/effects/TextEffects'; import TextEffects from '../tools/effects/TextEffects';
import Animate from '../tools/effects/Animate'; import Animate from '../tools/effects/Animate';
import * as Ease from '../tools/effects/Animate'; import * as Ease from '../tools/effects/Animate';
import DisplayAdminBlog from './DashEntry' import DisplayAdminBlog from './PostEditor'
import DisplayAdminFipamo from './DisplayAdminFipamo'; import DisplayAdminFipamo from './DisplayAdminFipamo';
export default class DisplayAdmin { export default class DisplayAdmin {

View file

@ -58,7 +58,6 @@ class TextEditor extends EventEmitter {
} }
}) })
} }
refresh() { refresh() {
var caret = position(this.textEditor).pos; var caret = position(this.textEditor).pos;
var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value; var spiffed = hljs.highlight('markdown', this.textEditor.innerText).value;
@ -73,13 +72,13 @@ class TextEditor extends EventEmitter {
case DataEvent.POST_UPDATED: case DataEvent.POST_UPDATED:
document.getElementById('submit-update').classList.add('icon-hide'); document.getElementById('submit-update').classList.add('icon-hide');
document.getElementById('submit-good').classList.remove('icon-hide'); document.getElementById('submit-good').classList.remove('icon-hide');
document.getElementById('option-update').classList.remove('submit-start'); document.getElementById('edit-update').classList.remove('submit-start');
document.getElementById('option-update').classList.add('submit-cool'); document.getElementById('edit-update').classList.add('submit-cool');
setTimeout(f => { setTimeout(f => {
document.getElementById('submit-update').classList.remove('icon-hide'); document.getElementById('submit-update').classList.remove('icon-hide');
document.getElementById('submit-good').classList.add('icon-hide'); document.getElementById('submit-good').classList.add('icon-hide');
document.getElementById('option-update').classList.add('submit-start'); document.getElementById('edit-update').classList.add('submit-start');
document.getElementById('option-update').classList.remove('submit-cool'); document.getElementById('edit-update').classList.remove('submit-cool');
}, 2000); }, 2000);
break; break;
@ -115,40 +114,40 @@ class TextEditor extends EventEmitter {
pulled = sel.getRangeAt(0).toString(); pulled = sel.getRangeAt(0).toString();
range.deleteContents(); range.deleteContents();
switch (e.target.id) { switch (e.target.id) {
case "option-bold": case "edit-bold":
range.insertNode(document.createTextNode("**" + pulled + "**")); range.insertNode(document.createTextNode("**" + pulled + "**"));
break; break;
case "option-italic": case "edit-italic":
range.insertNode(document.createTextNode("*" + pulled + "*")); range.insertNode(document.createTextNode("*" + pulled + "*"));
break; break;
case "option-strikethrough": case "edit-strikethrough":
range.insertNode(document.createTextNode("<del>" + pulled + "</del>")); range.insertNode(document.createTextNode("<del>" + pulled + "</del>"));
break; break;
case "option-header1": case "edit-header1":
range.insertNode(document.createTextNode("# " + pulled)); range.insertNode(document.createTextNode("# " + pulled));
break; break;
case "option-header2": case "edit-header2":
range.insertNode(document.createTextNode("## " + pulled)); range.insertNode(document.createTextNode("## " + pulled));
break; break;
case "option-header3": case "edit-header3":
range.insertNode(document.createTextNode("### " + pulled)); range.insertNode(document.createTextNode("### " + pulled));
break; break;
case "option-image": case "edit-image":
this.caretPos = position(this.textEditor).pos; this.caretPos = position(this.textEditor).pos;
this.emitEvent(EditorEvent.EDITOR_UPLOAD_POST_IMAGE); this.emitEvent(EditorEvent.EDITOR_UPLOAD_POST_IMAGE);
break; break;
case "submit-save": case "submit-save":
case "option-save": case "edit-save":
this.emitEvent(EditorEvent.EDITOR_SAVE); this.emitEvent(EditorEvent.EDITOR_SAVE);
break; break;
case "submit-update": case "submit-update":
case "option-update": case "edit-update":
this.emitEvent(EditorEvent.EDITOR_UPDATE); this.emitEvent(EditorEvent.EDITOR_UPDATE);
break break
case "option-link": case "edit-link":
range.insertNode(document.createTextNode("[" + pulled + "](PASTE URL HERE)")); range.insertNode(document.createTextNode("[" + pulled + "](PASTE URL HERE)"));
break; break;
case "option-delete": case "edit-delete":
this.emitEvent(EditorEvent.EDITOR_DELETE); this.emitEvent(EditorEvent.EDITOR_DELETE);
break break
default: default:

View file

@ -93,7 +93,7 @@
------------------------------- -------------------------------
**/ **/
@import 'main/_entries' @import 'main/_posts'
/** /**
------------------------------- -------------------------------

View file

@ -15,7 +15,7 @@
button button
background $secondary background $secondary
width 10% width 10%
height 35px height 39px
object-transitions(0.3s) object-transitions(0.3s)
margin 0 margin 0
border-radius 0 border-radius 0
@ -92,11 +92,3 @@
text-decoration line-through text-decoration line-through
font-style italic font-style italic
#edit-content-wrapper
width 98%
max-width 900px
margin 0 auto
border-radius 5px
code
border-radius 5px

View file

@ -1,9 +1,9 @@
#entries-index #post-index
width 100% width 100%
max-width 900px max-width 900px
margin 0 auto margin 0 auto
#entries-index-wrapper #post-index-wrapper
padding 0.75rem padding 0.75rem
a a
@ -16,8 +16,9 @@
border-radius 3px border-radius 3px
padding 3px padding 3px
color $white color $white
width 110px width 115px
margin-bottom: 10px text-align center
margin-bottom 10px
svg svg
display inline-block display inline-block
@ -33,10 +34,10 @@
&:hover &:hover
background $primary - 5% background $primary - 5%
#entries-list #posts-list
color $white color $white
a.entry-list-link a.post-list-link
display inline-block display inline-block
vertical-align top vertical-align top
padding 3px padding 3px
@ -50,29 +51,29 @@
font-size 0.7em font-size 0.7em
font-family 'Apercu-Mono' font-family 'Apercu-Mono'
#entries-edit-index #post-edit-index
width 100% width 100%
#entries-edit-index-wrapper #post-edit-index-wrapper
width 100% width 100%
#entry-header #post-header
// width 100% // width 100%
max-width 900px max-width 900px
margin 0 auto margin 0 auto
padding 0.75rem padding 0.75rem
#entry-title #post-title
#entry_title #post_title
background $primary - 4% background $primary - 4%
font-family 'Apercu' font-family 'Apercu'
width 100% width 97.6%
height 140px height 140px
font-size 1.5em font-size 1.5em
color $white color $white
padding 5px padding 5px
#entry-date #post-date
background $primary - 10% background $primary - 10%
border-radius 0 3px 3px 0 border-radius 0 3px 3px 0
width 105px width 105px
@ -90,8 +91,48 @@
color $secondary color $secondary
line-height 30px line-height 30px
#entry-meta #post-options
#entry_tags display inline-block
vertical-align top
width 49%
padding 0 0 0 3px
button:nth-child(1)
border-radius 3px 0 0 3px
button:nth-child(4)
border-radius 0 3px 3px 0
button
width 25%
height 39px
object-transitions(0.3s)
margin 0
border-radius 0
display inline-block
vertical-align top
text-align center
button[data-active='false']
background $secondary
svg
fill $primary
button[data-active='true']
background $tertiary
svg
fill $tertiary - 70%
//.option-inactive
//.option-active
#post-meta
#post_tags
background $primary - 4% background $primary - 4%
font-family 'Apercu' font-family 'Apercu'
width 97.6% width 97.6%
@ -102,7 +143,7 @@
#featured-click, #post-image #featured-click, #post-image
display none display none
#entry-feature #post-feature
width 100% width 100%
#featured-image-drop #featured-image-drop
@ -121,6 +162,8 @@
img img
width 100% width 100%
margin 0
padding 0
#featured-new-image-btn #featured-new-image-btn
position absolute position absolute
@ -133,21 +176,31 @@
svg svg
fill $highlight fill $highlight
#edit-content #edit-post
width 100% width 100%
max-width 900px max-width 900px
margin 0 auto margin 0 auto
#edit-content-wrapper #edit-post-wrapper
width 98%
max-width 900px
margin 0 auto
border-radius 5px
background $primary - 10%
pre pre
code code
// font-family 'Apercu-Mono' // font-family 'Apercu-Mono'
padding 5px
border-radius 5px
line-height 1.6em line-height 1.6em
font-size 1.25em font-size 1.25em
color $editorPrimary color $editorPrimary
word-wrap normal word-wrap normal
white-space pre-wrap white-space pre-wrap
line-break normal line-break normal
display inline-block
width 100%
// TINY DATE // TINY DATE
.dp-modal .dp-modal