From 302147df573c428998e93e34ad244fc0c0569628 Mon Sep 17 00:00:00 2001 From: Ro Date: Mon, 6 Jul 2020 16:12:32 -0700 Subject: [PATCH] plugged in feeaturd posts into template --- brain/api/v1/settings.js | 4 ++-- brain/data/Render.js | 10 ++++++++++ brain/data/Settings.js | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/brain/api/v1/settings.js b/brain/api/v1/settings.js index 789f08a..ee31887 100644 --- a/brain/api/v1/settings.js +++ b/brain/api/v1/settings.js @@ -48,10 +48,10 @@ router.post('/sync', (req, res) => { message: 'Settings Saved' }); }) - .catch(() => { + .catch(err => { res.json({ type: DataEvent.REQUEST_LAME, - message: "You're not logged in, champ" + message: "Uh oh. Settings didn't take, sport" }); }); }) diff --git a/brain/data/Render.js b/brain/data/Render.js index 00278da..82093e3 100644 --- a/brain/data/Render.js +++ b/brain/data/Render.js @@ -36,6 +36,13 @@ export default class Render { let rendered = 0; let display_count = 0; let recent = []; + let featured = _.filter(pages, page => { + return ( + page.metadata.deleted === false && + page.metadata.published === true && + page.metadata.featured === true + ); + }); for (let index = 0; index < pages.length; index++) { pages.sort((a, b) => parseFloat(b.metadata.id) - parseFloat(a.metadata.id)); @@ -52,6 +59,7 @@ export default class Render { display_count = ++display_count; } let writeFile, template; + let path = 'public/' + moment(page.metadata.created).format('YYYY') + @@ -91,6 +99,7 @@ export default class Render { }); } buffed = new StringUtils().decodeHTML(buffed); + let html = md.render(buffed, { html: true, xhtmlOut: true }); let file = pug.renderFile(template, { title: page.metadata.title, @@ -99,6 +108,7 @@ export default class Render { tags: tags, menu: config.menu, recent_posts: recent, + featured_posts: featured, meta: { who: author, when: moment(page.metadata.created).fromNow(), diff --git a/brain/data/Settings.js b/brain/data/Settings.js index baf6022..a38e608 100644 --- a/brain/data/Settings.js +++ b/brain/data/Settings.js @@ -19,6 +19,9 @@ export default class Settings { self.loadConfigData() .then(result => { let payload = req.body; + //so payload matches loaded config + payload.global.display_limit = result.settings.global.display_limit; + payload.global.last_backup = result.settings.global.last_backup; let user = req.session.user; let found = _.find(result.folks, { id: user.id }); let needToUpdate = false; @@ -44,7 +47,6 @@ export default class Settings { }; reject(response); } - if (!_.isEqual(result.settings.global, payload.global)) { let bg = payload.global.background; payload.global.background = bg.substr(21, bg.length);