diff --git a/express.js b/express.js index b5a92800..8f969c35 100644 --- a/express.js +++ b/express.js @@ -45,7 +45,6 @@ app.use(passport.initialize()); app.use(passport.session()); app.use(flash()); app.use(middleware.username); -app.use(middleware.flashMessage); //Initialize values for default configs app.set('views', 'templates/views'); diff --git a/public/js/app/navigation.js b/public/js/app/navigation.js index c9cb3ad6..ebd8c60e 100644 --- a/public/js/app/navigation.js +++ b/public/js/app/navigation.js @@ -148,19 +148,3 @@ document.addEventListener("DOMContentLoaded", () => { setInterval(highlightPulse, 2000); }); - -if (typeof htmlElement !== 'undefined') { - let pages = htmlElement.split(','); - if (pages[0] === '/all') { - document.getElementById('flashMessageContainer').style.display = 'block'; - } else { - pages.forEach(route => { - - if (window.location.href.includes(route) && window.innerWidth > 900) { - document.getElementById('flashMessageContainer').style.display = 'block'; - } - }); - } -} - - diff --git a/public/styles/layout/_navigation.sass b/public/styles/layout/_navigation.sass index bb0803a1..8fff2985 100644 --- a/public/styles/layout/_navigation.sass +++ b/public/styles/layout/_navigation.sass @@ -585,15 +585,6 @@ ul background-color: variables.$background-tertiary color: variables.$color-active - -#flashMessageContainer - display: none - p - padding: 0.2em - font-size: 18px - - - @media (min-width: 1201px) .mobileTransition display: none diff --git a/routes/middleware.js b/routes/middleware.js index d6fec6d3..1721a403 100755 --- a/routes/middleware.js +++ b/routes/middleware.js @@ -5,7 +5,6 @@ the navigation in the header, you may wish to change this array or replace it with your own templates / logic. */ -const fs = require('fs'); exports.initLocals = function(req, res, next) { let locals = res.locals; locals.navLinks = []; @@ -35,24 +34,3 @@ exports.username = function(req, res, next) { next(); }; - -exports.flashMessage = function(req, res, next) { - - try { - let rawData = fs.readFileSync('./public/js/app/members/flashMessage.json') ; - let data = JSON.parse(rawData); - let {valid, content, color, pages} = data[0]; - - let locals = res.locals; - //String 'true' because the wordpress value comes in a string - if (valid === 'true') { - locals.flashMessage = content; - locals.flashColor = color; - locals.flashRoutes = pages.slice(1,-1); - } - next(); - } catch (e) { - console.log(e); - next(); - } -}; diff --git a/scripts/extractor.js b/scripts/extractor.js index df8c9261..e8c543cb 100644 --- a/scripts/extractor.js +++ b/scripts/extractor.js @@ -35,29 +35,6 @@ async function getTournamentNews() { } } - -async function flashMessage() { - - try { - let response = await axios.get(`${process.env.WP_URL}/wp-json/wp/v2/posts/?per_page=100&_embed&_fields,_links.wp:featuredmedia,_embedded,title,content.rendered,categories&categories=640`); - - //Now we get a js array rather than a js object. Otherwise we can't sort it out. - let dataObjectToArray = Object.values(response.data); - let data = dataObjectToArray.map(item => ({ - //title: item.title.rendered, - content: item.newshub_badge, - color: item.newshub_backgroundcolor, - valid: item.newshub_sortIndex, - pages: item.newshub_externalLinkUrl, - - })); - return await data; - } catch (e) { - console.error(currentDate, '- [error] extractor::flashMessage failed with =>', e.toString()); - return null; - } -} - async function news() { try { let response = await axios.get(`${process.env.WP_URL}/wp-json/wp/v2/posts/?per_page=100&_embed&_fields=_links.author,_links.wp:featuredmedia,_embedded,title,content.rendered,date,categories&categories=587`); @@ -180,11 +157,11 @@ module.exports.run = function run() { // Do not change the order of these/make sure they match the order of fileNames below const extractorFunctions = [ - getTournamentNews(), flashMessage(), news(), contentCreators(), newshub(), fafTeams(), getAllClans(), + getTournamentNews(), news(), contentCreators(), newshub(), fafTeams(), getAllClans(), ]; //Make sure to not change the order of these since they match the order of extractorFunctions const fileNames = [ - 'tournament-news','flashMessage', 'news', 'content-creators', 'newshub', 'faf-teams', 'getAllClans', + 'tournament-news', 'news', 'content-creators', 'newshub', 'faf-teams', 'getAllClans', ]; fileNames.forEach((fileName, index) => { diff --git a/templates/layouts/default.pug b/templates/layouts/default.pug index 41b64fd7..38f52664 100755 --- a/templates/layouts/default.pug +++ b/templates/layouts/default.pug @@ -31,9 +31,6 @@ html(lang='en') //- HTML BODY body - if flashMessage - #flashMessageContainer - p(style=`background-color:${flashColor}`) #{flashMessage} .mainTopNavContainer // this is the "thin" navbar that has forums, discord, youtube icons, etc. .topNavContainer @@ -284,20 +281,8 @@ html(lang='en') a(href='https://discord.gg/mXahVSKGVb') DISCORD li a(href='https://forum.faforever.com/') FORUMS - - - - - - - //- Add scripts that are globally required by your site here. - // This script here adss what our flash message requirements are. - if flashRoutes - script(type='text/javascript'). - var htmlElement = !{JSON.stringify(flashRoutes)} script(src="../../js/app/navigation.js") - //- Include template-specific javascript files by extending the js block block js