diff --git a/app.js b/app.js index 5fc28803..da71f688 100644 --- a/app.js +++ b/app.js @@ -138,6 +138,38 @@ handlebars = handlebars.create({ return'/' + config.settings.app_context; }return''; }, + simpleCSS: function(config){ + var cssString = ''; + if(typeof config.settings.style.cssHeaderBackgroundColor !== 'undefined' && config.settings.style.cssHeaderBackgroundColor !== ''){ + cssString = cssString + '.navbar-default, .headerText h1 {background-color:' + config.settings.style.cssHeaderBackgroundColor + ';}'; + } + if(typeof config.settings.style.cssHeaderTextColor !== 'undefined' && config.settings.style.cssHeaderTextColor !== ''){ + cssString = cssString + '.navbar-default .navbar-brand, .headerText h1 {color:' + config.settings.style.cssHeaderTextColor + ';}'; + cssString = cssString + '.navbar-default .navbar-brand:hover, .navbar-default .navbar-brand:focus, .brand-text, .contactLink {color:' + config.settings.style.cssHeaderTextColor + ' !important;}'; + } + if(typeof config.settings.style.cssFooterBackgroundColor !== 'undefined' && config.settings.style.cssFooterBackgroundColor !== ''){ + cssString = cssString + '.footer{background-color:' + config.settings.style.cssFooterBackgroundColor + ';}'; + } + if(typeof config.settings.style.cssFooterTextColor !== 'undefined' && config.settings.style.cssFooterTextColor !== ''){ + cssString = cssString + '.footer p{color:' + config.settings.style.cssFooterTextColor + ';}'; + } + if(typeof config.settings.style.cssButtonBackgroundColor !== 'undefined' && config.settings.style.cssButtonBackgroundColor !== ''){ + cssString = cssString + '#btn_search, .btn-default{background-color:' + config.settings.style.cssButtonBackgroundColor + ';border-color:' + config.settings.style.cssButtonBackgroundColor + ';}'; + } + if(typeof config.settings.style.cssButtonTextColor !== 'undefined' && config.settings.style.cssButtonTextColor !== ''){ + cssString = cssString + '#btn_search, .btn-default{color:' + config.settings.style.cssButtonTextColor + ';}'; + } + if(typeof config.settings.style.cssLinkColor !== 'undefined' && config.settings.style.cssLinkColor !== ''){ + cssString = cssString + 'a, footer a, a:hover, a:focus, .contactLink a{color:' + config.settings.style.cssLinkColor + ' !important;}'; + } + if(typeof config.settings.style.cssTextColor !== 'undefined' && config.settings.style.cssTextColor !== ''){ + cssString = cssString + 'body, .panel-primary>.panel-heading, .list-group-heading{color:' + config.settings.style.cssTextColor + ';}'; + } + if(typeof config.settings.style.cssFontFamily !== 'undefined' && config.settings.style.cssFontFamily !== ''){ + cssString = cssString + 'body, h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6{font-family:' + config.settings.style.cssFontFamily + ';}'; + } + return cssString; + }, ifCond: function(v1, operator, v2, options){ switch(operator){ case'==': diff --git a/config/config.json b/config/config.json index a238290c..7473dd9c 100644 --- a/config/config.json +++ b/config/config.json @@ -39,6 +39,18 @@ "article_versioning": false, "api_auth_token": "", "api_allowed": false, - "locale": "en" + "locale": "en", + "env": "", + "style": { + "cssHeaderBackgroundColor": "", + "cssHeaderTextColor": "", + "cssFooterBackgroundColor": "", + "cssFooterTextColor": "", + "cssButtonBackgroundColor": "", + "cssButtonTextColor": "", + "cssLinkColor": "", + "cssTextColor": "", + "cssFontFamily": "" + } } } \ No newline at end of file diff --git a/locales/en.js b/locales/en.js index 06d71665..38a69ebd 100644 --- a/locales/en.js +++ b/locales/en.js @@ -173,5 +173,6 @@ "Edit reason": "Edit reason", "Previous versions": "Previous versions", "Topic": "Topic", - "Suggestion successfully processed": "Suggestion successfully processed" + "Suggestion successfully processed": "Suggestion successfully processed", + "Style": "Style" } \ No newline at end of file diff --git a/routes/index.js b/routes/index.js index 812c5752..ea761f1e 100644 --- a/routes/index.js +++ b/routes/index.js @@ -211,6 +211,7 @@ router.get('/' + config.settings.route_name + '/:id', common.restrict, function return; } } + // add to old view count var old_viewcount = result.kb_viewcount; if(old_viewcount == null){ @@ -303,12 +304,17 @@ router.post('/update_settings', common.restrict, function (req, res){ // loop settings, update config for(var key in settings){ if(Object.prototype.hasOwnProperty.call(settings, key)){ - // if true/false, convert to boolean - TODO: Figure a better way of doing this? var settingValue = settings[key]; - if(booleanArray.indexOf(settingValue) > -1){ - settingValue = (settingValue === 'true'); + // check for style keys + if(key.split('.')[0] === 'style'){ + config.settings.style[key.split('.')[1]] = settingValue; + }else{ + // if true/false, convert to boolean - TODO: Figure a better way of doing this? + if(booleanArray.indexOf(settingValue) > -1){ + settingValue = (settingValue === 'true'); + } + config.settings[key] = settingValue; } - config.settings[key] = settingValue; } } @@ -581,7 +587,8 @@ router.post('/save_kb', common.restrict, function (req, res){ req.session.kb_featured = kb_featured; req.session.kb_seo_title = req.body.frm_kb_seo_title; req.session.kb_seo_description = req.body.frm_kb_seo_description; - req.session.b_edit_reason = req.body.frm_kb_edit_reason; + req.session.kb_edit_reason = req.body.frm_kb_edit_reason; + req.session.kb_visible_state = req.body.frm_kb_visible_state; // redirect to insert res.redirect(req.app_context + '/edit/' + req.body.frm_kb_id); @@ -615,7 +622,8 @@ router.post('/save_kb', common.restrict, function (req, res){ kb_permalink: req.body.frm_kb_permalink, kb_featured: kb_featured, kb_seo_title: req.body.frm_kb_seo_title, - kb_seo_description: req.body.frm_kb_seo_description + kb_seo_description: req.body.frm_kb_seo_description, + kb_visible_state: req.body.frm_kb_visible_state } }, {}, function (err, numReplaced){ if(err){ @@ -1539,7 +1547,7 @@ router.get('/sitemap.xml', function (req, res, next){ var db = req.app.db; // get the articles - common.dbQuery(db.kb, {kb_published: 'true'}, null, null, function (err, articles){ + common.dbQuery(db.kb, {kb_published: 'true', kb_visible_state: {$ne: 'private'}}, null, null, function (err, articles){ var urlArray = []; // push in the base url diff --git a/views/layouts/layout.hbs b/views/layouts/layout.hbs index 2f20051a..f1e0a7d9 100644 --- a/views/layouts/layout.hbs +++ b/views/layouts/layout.hbs @@ -56,17 +56,17 @@ {{#ifCond title '===' 'Settings'}} - + {{/ifCond}} {{#ifCond config.settings.mermaid '===' true}} - + {{/ifCond}} {{#ifCond config.settings.mathjax '===' true}} - - + + {{/ifCond}} @@ -84,6 +84,7 @@ {{#ifCond user_page '===' true}} + {{#if config.settings.google_analytics}} {{{config.settings.google_analytics}}} {{/if}} diff --git a/views/settings.hbs b/views/settings.hbs index 681b4697..b77723b0 100644 --- a/views/settings.hbs +++ b/views/settings.hbs @@ -9,6 +9,7 @@