made separate file for tags, fixed config caching error when creating new post
This commit is contained in:
parent
7dae73bed9
commit
161f441b84
5 changed files with 33 additions and 17 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -11,6 +11,7 @@ config.development.json
|
||||||
site/settings.json
|
site/settings.json
|
||||||
site/folks.json
|
site/folks.json
|
||||||
site/pages.json
|
site/pages.json
|
||||||
|
site/tags.json
|
||||||
brain/models/_backup/
|
brain/models/_backup/
|
||||||
/_maintenance/
|
/_maintenance/
|
||||||
*.DS_Store
|
*.DS_Store
|
||||||
|
|
|
@ -3,6 +3,7 @@ import StringUtils from '../../src/com/utils/StringUtils';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import sanitize from 'sanitize-html';
|
import sanitize from 'sanitize-html';
|
||||||
const config = require('../../site/settings.json');
|
const config = require('../../site/settings.json');
|
||||||
|
const tags_list = require('../../site/tags.json');
|
||||||
const pug = require('pug');
|
const pug = require('pug');
|
||||||
const md = require('markdown-it')('commonmark');
|
const md = require('markdown-it')('commonmark');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
@ -73,7 +74,7 @@ export default class Render {
|
||||||
}
|
}
|
||||||
publishTags(pages) {
|
publishTags(pages) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let tags = config.tags;
|
let tags = tags_list.tags;
|
||||||
let renderList = [];
|
let renderList = [];
|
||||||
for (let index = 0; index < tags.length; index++) {
|
for (let index = 0; index < tags.length; index++) {
|
||||||
let tag = tags[index];
|
let tag = tags[index];
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import * as DataEvent from '../../src/com/events/DataEvent';
|
import * as DataEvent from '../../src/com/events/DataEvent';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
const config = require('../../site/settings.json');
|
const config = require('../../site/tags.json');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
|
||||||
export default class Settings {
|
export default class Settings {
|
||||||
|
@ -15,7 +15,7 @@ export default class Settings {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!_.isEqual(config.tags, tags)) {
|
if (!_.isEqual(config.tags, tags)) {
|
||||||
config.tags = tags;
|
config.tags = tags;
|
||||||
fs.writeJson('site/settings.json', config)
|
fs.writeJson('site/tags.json', config)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
let response = {
|
let response = {
|
||||||
type: DataEvent.SETTINGS_UPDATED,
|
type: DataEvent.SETTINGS_UPDATED,
|
||||||
|
|
|
@ -4,7 +4,7 @@ const router = express.Router();
|
||||||
const moment = require('moment');
|
const moment = require('moment');
|
||||||
const book = new Book();
|
const book = new Book();
|
||||||
const uuidv4 = require('uuid/v4');
|
const uuidv4 = require('uuid/v4');
|
||||||
const settings = require('../../../site/settings.json');
|
const fs = require('fs-extra');
|
||||||
//--------------------------
|
//--------------------------
|
||||||
// POSTS
|
// POSTS
|
||||||
//--------------------------
|
//--------------------------
|
||||||
|
@ -91,17 +91,31 @@ router.get('/list/:filter?/:page?', function (req, res) {
|
||||||
//--------------------------
|
//--------------------------
|
||||||
router.get('/add/new', function (req, res) {
|
router.get('/add/new', function (req, res) {
|
||||||
if (req.session.user) {
|
if (req.session.user) {
|
||||||
res.render('page-edit', {
|
//need to grab a few copy of settings for the lastest index
|
||||||
id: settings.library_stats.current_index,
|
fs.readFile('site/settings.json', 'utf8', (err, json) => {
|
||||||
uuid: uuidv4(),
|
if (err) {
|
||||||
title: 'Add New Page',
|
// TODO: add error page
|
||||||
user_status: true,
|
//console.log('Error reading file from disk:', err);
|
||||||
welcome: 'Add New Page',
|
return;
|
||||||
date: moment(Date.now()).format('YYYY MMM DD'),
|
}
|
||||||
page: [],
|
try {
|
||||||
rawDate: moment(Date.now()).format(),
|
let config = JSON.parse(json);
|
||||||
status: ['false', 'false', 'false'],
|
res.render('page-edit', {
|
||||||
edit: false
|
id: config.library_stats.current_index,
|
||||||
|
uuid: uuidv4(),
|
||||||
|
title: 'Add New Page',
|
||||||
|
user_status: true,
|
||||||
|
welcome: 'Add New Page',
|
||||||
|
date: moment(Date.now()).format('YYYY MMM DD'),
|
||||||
|
page: [],
|
||||||
|
rawDate: moment(Date.now()).format(),
|
||||||
|
status: ['false', 'false', 'false'],
|
||||||
|
edit: false
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
//add error page
|
||||||
|
console.log('ERROR', err);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
res.redirect('/@/dashboard');
|
res.redirect('/@/dashboard');
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
background $primary - 4%
|
background $primary - 4%
|
||||||
font-family $baseType
|
font-family $baseType
|
||||||
width 97.6%
|
width 97.6%
|
||||||
height 140px
|
height 80px
|
||||||
font-size 1.5em
|
font-size 1.5em
|
||||||
color $white
|
color $white
|
||||||
padding 5px
|
padding 5px
|
||||||
|
@ -147,7 +147,7 @@
|
||||||
background $primary - 4%
|
background $primary - 4%
|
||||||
font-family $baseType
|
font-family $baseType
|
||||||
width 97.6%
|
width 97.6%
|
||||||
height 140px
|
height 80px
|
||||||
color $secondary
|
color $secondary
|
||||||
padding 5px
|
padding 5px
|
||||||
margin 0 0 5px 0
|
margin 0 0 5px 0
|
||||||
|
|
Loading…
Reference in a new issue