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

pull/20/head
Ro 5 years ago
parent 7dae73bed9
commit 161f441b84

1
.gitignore vendored

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

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

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

@ -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,17 +91,31 @@ router.get('/list/:filter?/:page?', function (req, res) {
//--------------------------
router.get('/add/new', function (req, res) {
if (req.session.user) {
res.render('page-edit', {
id: settings.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
//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: 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 {
res.redirect('/@/dashboard');

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

Loading…
Cancel
Save