made separate file for tags, fixed config caching error when creating new post

This commit is contained in:
Ro 2020-05-21 21:18:32 -07:00
parent 7dae73bed9
commit 161f441b84
5 changed files with 33 additions and 17 deletions

1
.gitignore vendored
View file

@ -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

View file

@ -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];

View file

@ -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,

View file

@ -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,8 +91,17 @@ 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) {
//need to grab a few copy of settings for the lastest index
fs.readFile('site/settings.json', 'utf8', (err, json) => {
if (err) {
// TODO: add error page
//console.log('Error reading file from disk:', err);
return;
}
try {
let config = JSON.parse(json);
res.render('page-edit', { res.render('page-edit', {
id: settings.library_stats.current_index, id: config.library_stats.current_index,
uuid: uuidv4(), uuid: uuidv4(),
title: 'Add New Page', title: 'Add New Page',
user_status: true, user_status: true,
@ -103,6 +112,11 @@ router.get('/add/new', function (req, res) {
status: ['false', 'false', 'false'], status: ['false', 'false', 'false'],
edit: false edit: false
}); });
} catch (err) {
//add error page
console.log('ERROR', err);
}
});
} else { } else {
res.redirect('/@/dashboard'); res.redirect('/@/dashboard');
} }

View file

@ -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