added pages config json(may not need), synced editor to markdown metadata, resolved new asset dependency paths

This commit is contained in:
Ro 2019-11-23 10:30:34 -08:00
parent 5824f36e47
commit d536871fd4
13 changed files with 74 additions and 60 deletions

5
.gitignore vendored
View file

@ -8,8 +8,9 @@ content/
config.development.json config.development.json
*.swp *.swp
/config.json /config.json
config/config.json site/settings.json
config/folks.json site/folks.json
site/pages.json
brain/models/_backup/ brain/models/_backup/
/_maintenance/ /_maintenance/
*.DS_Store *.DS_Store

View file

@ -23,7 +23,7 @@ router.get('/', function(req, res) {
* Login Member and return token * Login Member and return token
*/ */
router.post('/login', function(req, res) { router.post('/login', function(req, res) {
fs.readJson('config/folks.json').then(folks => { fs.readJson('site/folks.json').then(folks => {
let found = _.find(folks, { handle: req.body.handle }); let found = _.find(folks, { handle: req.body.handle });
if (found) { if (found) {
if (!isValidPassword(found, req.body.password)) { if (!isValidPassword(found, req.body.password)) {

View file

@ -1,5 +1,5 @@
import DateUtils from '../../../src/com/utils/DateUtils'; import DateUtils from '../../../src/com/utils/DateUtils';
import Pages from '../../data/Pages'; 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';

View file

@ -43,7 +43,7 @@ app.use(flash());
//sections //sections
//var front = require('./routes/front/index')(session); //var front = require('./routes/front/index')(session);
var dash = require('./routes/dash/index'); var dash = require('./routes/dash/index');
var postDashboard = require('./routes/dash/posts'); var page = require('./routes/dash/pages');
//var settingsDashboard = require('./routes/dash/settings'); //var settingsDashboard = require('./routes/dash/settings');
//var navDashboard = require('./routes/dash/nav'); //var navDashboard = require('./routes/dash/nav');
//api //api
@ -60,7 +60,7 @@ app.use('/api/v1/auth', auth);
// PAGES // PAGES
//app.use('/', front); //app.use('/', front);
app.use('/@/dashboard', dash); app.use('/@/dashboard', dash);
app.use('/@/dashboard/posts', postDashboard); app.use('/@/dashboard/page', page);
//app.use('/@/dashboard/settings', settingsDashboard); //app.use('/@/dashboard/settings', settingsDashboard);
//app.use('/@/dashboard/navigation', navDashboard); //app.use('/@/dashboard/navigation', navDashboard);
//app.use('/mailer', mailer); //app.use('/mailer', mailer);

View file

@ -1,6 +1,7 @@
import fh from 'filehound'; import fh from 'filehound';
import fs from 'fs-extra'; import fs from 'fs-extra';
import metadataParser from 'markdown-yaml-metadata-parser'; import metadataParser from 'markdown-yaml-metadata-parser';
import _ from 'lodash';
export default class Pages { export default class Pages {
//-------------------------- //--------------------------
@ -12,7 +13,7 @@ export default class Pages {
//-------------------------- //--------------------------
start() {} start() {}
grab(id) { getPage(id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fh.create() fh.create()
.paths('content/pages') .paths('content/pages')
@ -25,13 +26,20 @@ export default class Pages {
pages.push(metadataParser(file)); pages.push(metadataParser(file));
}); });
} }
if (id === null || id === null || id === undefined) { if (id === null || id === null || id === undefined) {
setTimeout(() => { setTimeout(() => {
//TODO: Duct tape solution until something better created //TODO: Duct tape solution until something better created
resolve(pages); resolve(pages);
}, 100); }, 100);
} else { } else {
// find specific pages setTimeout(() => {
//TODO: Duct tape solution until something better created
let page = _.find(pages, list => {
return list.metadata.uuid === id;
});
resolve(page);
}, 100);
} }
}) })
.catch(err => { .catch(err => {

View file

@ -1,14 +1,15 @@
import Pages from '../../data/Pages'; import Book from '../../data/Book';
const express = require('express'); const express = require('express');
const router = express.Router(); const router = express.Router();
const settings = require('../../../config/site-settings.json'); const settings = require('../../../site/settings.json');
//-------------------------- //--------------------------
// Index // Index
//-------------------------- //--------------------------
router.get('/', function(req, res) { router.get('/', function(req, res) {
let pages = new Pages(); let book = new Book();
pages.grab().then(result => { book.getPage().then(result => {
result.sort((a, b) => parseFloat(b.metadata.id) - parseFloat(a.metadata.id));
let pageData = []; let pageData = [];
if (req.session.user) { if (req.session.user) {
pageData = { title: settings.title, status: true, pages: result }; pageData = { title: settings.title, status: true, pages: result };

View file

@ -1,10 +1,12 @@
import DateUtils from '../../../src/com/utils/DateUtils'; import DateUtils from '../../../src/com/utils/DateUtils';
import Book from '../../data/Book';
var express = require('express'); var express = require('express');
var router = express.Router(); var router = express.Router();
var hljs = require('highlight.js/lib/highlight'); var hljs = require('highlight.js/lib/highlight');
var hljs_md = require('highlight.js/lib/languages/markdown'); var hljs_md = require('highlight.js/lib/languages/markdown');
hljs.registerLanguage('markdown', hljs_md); hljs.registerLanguage('markdown', hljs_md);
const dateUtils = new DateUtils(); const dateUtils = new DateUtils();
const book = new Book();
//-------------------------- //--------------------------
// POSTS // POSTS
//-------------------------- //--------------------------
@ -54,7 +56,39 @@ router.get('/add/new', function(req, res) {
// BLOG POST EDIT DISPLAY // BLOG POST EDIT DISPLAY
//-------------------------- //--------------------------
router.get('/edit/:id', function(req, res) { router.get('/edit/:id', function(req, res) {
var id = req.params.id;
if (req.session.user) { if (req.session.user) {
book.getPage(id)
.then(page => {
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', {
id: page.metadata.id,
title: 'Edit Page',
user_status: true,
welcome: 'Edit Page',
mode: 'admin',
page: page.metadata,
date: sexydate,
colored: pretty,
feature: page.metadata.feature,
status: [
String(true),
String(page.metadata.featured),
String(page.metadata.published)
],
edit: true
});
})
.catch(err => {
res.json({ type: err });
});
} else { } else {
res.redirect('/@/dashboard'); res.redirect('/@/dashboard');
} }

View file

@ -10,10 +10,10 @@ block main-content
-var post_status = ['false', 'false', 'false',] -var post_status = ['false', 'false', 'false',]
if(edit) if(edit)
-post_title = post.title -post_title = page.title
-post_plaintext = post.plaintext -post_plaintext = page.plaintext
-post_feature = feature -post_feature = page.feature
-post_tags = post.tags -post_tags = page.tags
-post_date = date -post_date = date
-post_status = status -post_status = status
@ -32,7 +32,7 @@ block main-content
#featured-new-image-btn #featured-new-image-btn
button#new-feature-upload button#new-feature-upload
svg#new-feature-upload(viewBox="0 0 20 20" class="icons") svg#new-feature-upload(viewBox="0 0 20 20" class="icons")
use(xlink:href='/dash/assets/images/sprite.svg#entypo-image-inverted') use(xlink:href='/assets/images/global/sprite.svg#entypo-image-inverted')
#featured-image-drop #featured-image-drop
img(src=post_feature) img(src=post_feature)
#post-header.columns #post-header.columns
@ -41,21 +41,21 @@ block main-content
=post_title =post_title
#calendar-icon #calendar-icon
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-calendar') use(xlink:href='/assets/images/global/sprite.svg#entypo-calendar')
input(id="post-date" type="text" value=post_date) input(id="post-date" type="text" value=post_date)
#post-options #post-options
button#option-page.option-inactive.post-option-btn(data-active= status[0]) button#option-page.option-inactive.post-option-btn(data-active= status[0])
svg#option-page-icon(viewBox="0 0 20 20" class="icons") svg#option-page-icon(viewBox="0 0 20 20" class="icons")
use#option-page-icon(xlink:href='/dash/assets/images/sprite.svg#entypo-pin') use#option-page-icon(xlink:href='/assets/images/global/sprite.svg#entypo-pin')
button#option-feature.option-inactive.post-option-btn(data-active= status[1]) button#option-feature.option-inactive.post-option-btn(data-active= status[1])
svg#option-feature-icon(viewBox="0 0 20 20" class="icons") svg#option-feature-icon(viewBox="0 0 20 20" class="icons")
use#option-feature-icon(xlink:href='/dash/assets/images/sprite.svg#entypo-star') use#option-feature-icon(xlink:href='/assets/images/global/sprite.svg#entypo-star')
button#option-published.option-inactive.post-option-btn(data-active= status[2]) button#option-published.option-inactive.post-option-btn(data-active= status[2])
svg#option-published-icon(viewBox="0 0 20 20" class="icons") svg#option-published-icon(viewBox="0 0 20 20" class="icons")
use#option-published-icon(xlink:href='/dash/assets/images/sprite.svg#entypo-globe') use#option-published-icon(xlink:href='/assets/images/global/sprite.svg#entypo-globe')
button#option-preview.option-inactive(data-active="false") button#option-preview.option-inactive(data-active="false")
svg#option-preview-icon(viewBox="0 0 20 20" class="icons") svg#option-preview-icon(viewBox="0 0 20 20" class="icons")
use#option-preview-icon(xlink:href='/dash/assets/images/sprite.svg#entypo-eye') use#option-preview-icon(xlink:href='/assets/images/global/sprite.svg#entypo-eye')
#post-meta.column #post-meta.column
textarea(id='post_tags' type='text', name='post_tags' class='form-control', placeholder='tags [comma seperated]', autofocus) textarea(id='post_tags' type='text', name='post_tags' class='form-control', placeholder='tags [comma seperated]', autofocus)
=post_tags =post_tags

View file

@ -7,7 +7,7 @@
| S | S
button#edit-link.content-editor-btn-icon.editor-button(title="insert link") button#edit-link.content-editor-btn-icon.editor-button(title="insert link")
svg#edit-link(viewBox="0 0 20 20" class="icons") svg#edit-link(viewBox="0 0 20 20" class="icons")
use#edit-link(xlink:href='/dash/assets/images/sprite.svg#entypo-link') use#edit-link(xlink:href='/assets/images/global/sprite.svg#entypo-link')
button#edit-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#edit-header2.content-editor-btn-text.editor-button(title="header 2") button#edit-header2.content-editor-btn-text.editor-button(title="header 2")
@ -16,19 +16,19 @@
| H3 | H3
button#edit-image.content-editor-btn-icon.editor-button(title='insert image') button#edit-image.content-editor-btn-icon.editor-button(title='insert image')
svg#edit-image(viewBox="0 0 20 20" class="icons") svg#edit-image(viewBox="0 0 20 20" class="icons")
use#edit-image(xlink:href='/dash/assets/images/sprite.svg#entypo-image') use#edit-image(xlink:href='/assets/images/global/sprite.svg#entypo-image')
if(edit) if(edit)
button#edit-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=page.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='/assets/images/global/sprite.svg#entypo-save' data-action='blog-update' data-id=page.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='/assets/images/global/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='/assets/images/global/sprite.svg#entypo-thumbs-down')
button#edit-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#edit-delete(viewBox="0 0 20 20" class="icons") svg#edit-delete(viewBox="0 0 20 20" class="icons")
use#edit-delete(xlink:href='/dash/assets/images/sprite.svg#entypo-cross') use#edit-delete(xlink:href='/assets/images/global/sprite.svg#entypo-cross')
else else
button#edit-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")

View file

@ -13,7 +13,7 @@
label this is empty label this is empty
else else
- for ( index; index < pages.length; index++) - for ( index; index < pages.length; index++)
a.post-link(href="/@/dashboard/posts/edit/"+pages[index].metadata.uuid id=pages[index].metadata.uuid style="background:url("+pages[index].metadata.feature+") no-repeat center center / cover") a.post-link(href="/@/dashboard/page/edit/"+pages[index].metadata.uuid id=pages[index].metadata.uuid style="background:url("+pages[index].metadata.feature+") no-repeat center center / cover")
div div
label= pages[index].metadata.title label= pages[index].metadata.title
span= pages[index].metadata.created span= pages[index].metadata.created

View file

@ -1,30 +0,0 @@
{
"url": "DOMAIN_URL",
"theme": "default",
"development": {
"database": "DATABASE",
"user": "DATABASE_USER",
"password": "DATABASE_PASS",
"dialect": "postgres",
"host": "localhost",
"operatorsAliases": false,
"pool": {
"max": 9,
"min": 0,
"idle": 10000
}
},
"production": {
"database": "DATABASE",
"user": "DATABASE_USER",
"password": "DATABASE_PASS",
"operatorsAliases": false,
"host": "localhost",
"dialect": "postgres",
"pool": {
"max": 9,
"min": 0,
"idle": 10000
}
}
}