Skip to content

Commit

Permalink
removed incomplete flash-message feature.
Browse files Browse the repository at this point in the history
it was not used, and if used, it broke the site
  • Loading branch information
fcaps authored and Brutus5000 committed Nov 21, 2023
1 parent fc06573 commit 9ea1098
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 88 deletions.
1 change: 0 additions & 1 deletion express.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
16 changes: 0 additions & 16 deletions public/js/app/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
});
}
}


9 changes: 0 additions & 9 deletions public/styles/layout/_navigation.sass
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions routes/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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();
}
};
27 changes: 2 additions & 25 deletions scripts/extractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down Expand Up @@ -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) => {
Expand Down
15 changes: 0 additions & 15 deletions templates/layouts/default.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9ea1098

Please sign in to comment.