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/folks.json
site/pages.json
site/tags.json
brain/models/_backup/
/_maintenance/
*.DS_Store

View file

@ -3,6 +3,7 @@ import StringUtils from '../../src/com/utils/StringUtils';
import fs from 'fs-extra';
import sanitize from 'sanitize-html';
const config = require('../../site/settings.json');
const tags_list = require('../../site/tags.json');
const pug = require('pug');
const md = require('markdown-it')('commonmark');
const _ = require('lodash');
@ -73,7 +74,7 @@ export default class Render {
}
publishTags(pages) {
return new Promise((resolve, reject) => {
let tags = config.tags;
let tags = tags_list.tags;
let renderList = [];
for (let index = 0; index < tags.length; index++) {
let tag = tags[index];

View file

@ -1,6 +1,6 @@
import * as DataEvent from '../../src/com/events/DataEvent';
import fs from 'fs-extra';
const config = require('../../site/settings.json');
const config = require('../../site/tags.json');
const _ = require('lodash');
export default class Settings {
@ -15,7 +15,7 @@ export default class Settings {
return new Promise((resolve, reject) => {
if (!_.isEqual(config.tags, tags)) {
config.tags = tags;
fs.writeJson('site/settings.json', config)
fs.writeJson('site/tags.json', config)
.then(() => {
let response = {
type: DataEvent.SETTINGS_UPDATED,

View file

@ -4,7 +4,7 @@ const router = express.Router();
const moment = require('moment');
const book = new Book();
const uuidv4 = require('uuid/v4');
const settings = require('../../../site/settings.json');
const fs = require('fs-extra');
//--------------------------
// POSTS
//--------------------------
@ -91,8 +91,17 @@ router.get('/list/:filter?/:page?', function (req, res) {
//--------------------------
router.get('/add/new', function (req, res) {
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', {
id: settings.library_stats.current_index,
id: config.library_stats.current_index,
uuid: uuidv4(),
title: 'Add New Page',
user_status: true,
@ -103,6 +112,11 @@ router.get('/add/new', function (req, res) {
status: ['false', 'false', 'false'],
edit: false
});
} catch (err) {
//add error page
console.log('ERROR', err);
}
});
} else {
res.redirect('/@/dashboard');
}

View file

@ -85,7 +85,7 @@
background $primary - 4%
font-family $baseType
width 97.6%
height 140px
height 80px
font-size 1.5em
color $white
padding 5px
@ -147,7 +147,7 @@
background $primary - 4%
font-family $baseType
width 97.6%
height 140px
height 80px
color $secondary
padding 5px
margin 0 0 5px 0