forked from projects/fipamo
added pages config json(may not need), synced editor to markdown metadata, resolved new asset dependency paths
This commit is contained in:
parent
5824f36e47
commit
d536871fd4
13 changed files with 74 additions and 60 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -8,8 +8,9 @@ content/
|
|||
config.development.json
|
||||
*.swp
|
||||
/config.json
|
||||
config/config.json
|
||||
config/folks.json
|
||||
site/settings.json
|
||||
site/folks.json
|
||||
site/pages.json
|
||||
brain/models/_backup/
|
||||
/_maintenance/
|
||||
*.DS_Store
|
||||
|
|
|
@ -23,7 +23,7 @@ router.get('/', function(req, res) {
|
|||
* Login Member and return token
|
||||
*/
|
||||
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 });
|
||||
if (found) {
|
||||
if (!isValidPassword(found, req.body.password)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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 * as DataEvent from '../../../src/com/events/DataEvent';
|
||||
import sanitize from 'sanitize-html';
|
||||
|
|
|
@ -43,7 +43,7 @@ app.use(flash());
|
|||
//sections
|
||||
//var front = require('./routes/front/index')(session);
|
||||
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 navDashboard = require('./routes/dash/nav');
|
||||
//api
|
||||
|
@ -60,7 +60,7 @@ app.use('/api/v1/auth', auth);
|
|||
// PAGES
|
||||
//app.use('/', front);
|
||||
app.use('/@/dashboard', dash);
|
||||
app.use('/@/dashboard/posts', postDashboard);
|
||||
app.use('/@/dashboard/page', page);
|
||||
//app.use('/@/dashboard/settings', settingsDashboard);
|
||||
//app.use('/@/dashboard/navigation', navDashboard);
|
||||
//app.use('/mailer', mailer);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import fh from 'filehound';
|
||||
import fs from 'fs-extra';
|
||||
import metadataParser from 'markdown-yaml-metadata-parser';
|
||||
import _ from 'lodash';
|
||||
|
||||
export default class Pages {
|
||||
//--------------------------
|
||||
|
@ -12,7 +13,7 @@ export default class Pages {
|
|||
//--------------------------
|
||||
start() {}
|
||||
|
||||
grab(id) {
|
||||
getPage(id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fh.create()
|
||||
.paths('content/pages')
|
||||
|
@ -25,13 +26,20 @@ export default class Pages {
|
|||
pages.push(metadataParser(file));
|
||||
});
|
||||
}
|
||||
|
||||
if (id === null || id === null || id === undefined) {
|
||||
setTimeout(() => {
|
||||
//TODO: Duct tape solution until something better created
|
||||
resolve(pages);
|
||||
}, 100);
|
||||
} 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 => {
|
|
@ -1,14 +1,15 @@
|
|||
import Pages from '../../data/Pages';
|
||||
import Book from '../../data/Book';
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const settings = require('../../../config/site-settings.json');
|
||||
const settings = require('../../../site/settings.json');
|
||||
|
||||
//--------------------------
|
||||
// Index
|
||||
//--------------------------
|
||||
router.get('/', function(req, res) {
|
||||
let pages = new Pages();
|
||||
pages.grab().then(result => {
|
||||
let book = new Book();
|
||||
book.getPage().then(result => {
|
||||
result.sort((a, b) => parseFloat(b.metadata.id) - parseFloat(a.metadata.id));
|
||||
let pageData = [];
|
||||
if (req.session.user) {
|
||||
pageData = { title: settings.title, status: true, pages: result };
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import DateUtils from '../../../src/com/utils/DateUtils';
|
||||
import Book from '../../data/Book';
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var hljs = require('highlight.js/lib/highlight');
|
||||
var hljs_md = require('highlight.js/lib/languages/markdown');
|
||||
hljs.registerLanguage('markdown', hljs_md);
|
||||
const dateUtils = new DateUtils();
|
||||
const book = new Book();
|
||||
//--------------------------
|
||||
// POSTS
|
||||
//--------------------------
|
||||
|
@ -54,7 +56,39 @@ router.get('/add/new', function(req, res) {
|
|||
// BLOG POST EDIT DISPLAY
|
||||
//--------------------------
|
||||
router.get('/edit/:id', function(req, res) {
|
||||
var id = req.params.id;
|
||||
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 {
|
||||
res.redirect('/@/dashboard');
|
||||
}
|
|
@ -10,10 +10,10 @@ block main-content
|
|||
-var post_status = ['false', 'false', 'false',]
|
||||
|
||||
if(edit)
|
||||
-post_title = post.title
|
||||
-post_plaintext = post.plaintext
|
||||
-post_feature = feature
|
||||
-post_tags = post.tags
|
||||
-post_title = page.title
|
||||
-post_plaintext = page.plaintext
|
||||
-post_feature = page.feature
|
||||
-post_tags = page.tags
|
||||
-post_date = date
|
||||
-post_status = status
|
||||
|
||||
|
@ -32,7 +32,7 @@ block main-content
|
|||
#featured-new-image-btn
|
||||
button#new-feature-upload
|
||||
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
|
||||
img(src=post_feature)
|
||||
#post-header.columns
|
||||
|
@ -41,21 +41,21 @@ block main-content
|
|||
=post_title
|
||||
#calendar-icon
|
||||
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)
|
||||
#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')
|
||||
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])
|
||||
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])
|
||||
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")
|
||||
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
|
||||
textarea(id='post_tags' type='text', name='post_tags' class='form-control', placeholder='tags [comma seperated]', autofocus)
|
||||
=post_tags
|
|
@ -7,7 +7,7 @@
|
|||
| S
|
||||
button#edit-link.content-editor-btn-icon.editor-button(title="insert link")
|
||||
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")
|
||||
| H1
|
||||
button#edit-header2.content-editor-btn-text.editor-button(title="header 2")
|
||||
|
@ -16,19 +16,19 @@
|
|||
| H3
|
||||
button#edit-image.content-editor-btn-icon.editor-button(title='insert image')
|
||||
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)
|
||||
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")
|
||||
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")
|
||||
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")
|
||||
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')
|
||||
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
|
||||
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")
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
label this is empty
|
||||
else
|
||||
- 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
|
||||
label= pages[index].metadata.title
|
||||
span= pages[index].metadata.created
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue