diff --git a/express.js b/express.js index be1ca2f9..2949f2b9 100644 --- a/express.js +++ b/express.js @@ -144,9 +144,10 @@ app.route('/news').get(function(req, res) { res.redirect('/newshub'); }); -app.get('/competitive/tournaments', require(routes + 'tournaments')); +//app.get('/competitive/tournaments', require(routes + 'tournaments')); app.get('/competitive/leaderboards/1v1', require(routes + '1v1')); app.get('/competitive/leaderboards/2v2', require(routes + '2v2')); +app.get('/competitive/leaderboards/4v4', require(routes + '4v4')); app.get('/competitive/leaderboards/global', require(routes + 'global')); app.get('/competitive/leaderboards/leagues', (function(){ let updateLeagues = require('./scripts/updateLeagues'); diff --git a/routes/challonge_config.js b/routes/challonge_config.js deleted file mode 100644 index 252fa701..00000000 --- a/routes/challonge_config.js +++ /dev/null @@ -1,5 +0,0 @@ -module.exports = { - getAuth: function () { - return "https://" + process.env.CHALLONGE_USERNAME + ":" + process.env.CHALLONGE_APIKEY + "@api.challonge.com/v1"; - } -}; \ No newline at end of file diff --git a/routes/index.js b/routes/index.js index ed9bbfdb..381d9df3 100644 --- a/routes/index.js +++ b/routes/index.js @@ -37,7 +37,6 @@ exports = module.exports = function(app) { app.get('/news/page/:page', routes.views.blog); app.get('/:year/:month/:slug', routes.views.post); app.get('/contribution', routes.views.contribution); - app.get('/competitive/tournaments', routes.views.tournaments); app.get('/competitive/leaderboards', routes.views.leaderboards); app.all('/contact', routes.views.contact); diff --git a/routes/middleware.js b/routes/middleware.js index 43571b1d..12d54624 100755 --- a/routes/middleware.js +++ b/routes/middleware.js @@ -10,18 +10,12 @@ exports.initLocals = function(req, res, next) { var locals = res.locals; - locals.navLinks = [ - { label: 'News', key: 'blog', href: '/news' }, - { label: 'Competitive', key: 'competitive', href: '/competitive/tournaments' } - ]; - - locals.cNavLinks = [ - { label: 'Tournaments', key: 'tournaments', href: '/competitive/tournaments' }, - { label: '1v1 Leaderboards', key: '1v1', href: '/competitive/leaderboards/1v1' }, - { label: 'Global Leaderboards', key: 'global', href: '/competitive/leaderboards/global' }, - { label: 'Leagues', key: 'leagues', href: '/competitive/leaderboards/leagues' }, + locals.cNavLinks = [ + { label: 'Global Leaderboards', key: 'global', href: '/competitive/leaderboards/global' }, + { label: '1v1 Leaderboards', key: '1v1', href: '/competitive/leaderboards/1v1' }, { label: '2v2 Leaderboards', key: '2v2', href: '/competitive/leaderboards/2v2' }, - ]; + { label: '4v4 Full Share Leaderboards', key: '4v4', href: '/competitive/leaderboards/4v4' }, + ]; next(); @@ -60,7 +54,7 @@ exports.clientChecks = function(req, res, next) { } var userAgent = req.headers['user-agent']; - if (userAgent == 'FAF Client' || userAgent == 'downlords-faf-client') { + if (userAgent === 'FAF Client' || userAgent === 'downlords-faf-client') { locals.removeNavigation = true; } diff --git a/routes/views/4v4.js b/routes/views/4v4.js new file mode 100644 index 00000000..a8df0235 --- /dev/null +++ b/routes/views/4v4.js @@ -0,0 +1,23 @@ +exports = module.exports = function(req, res) { + + var locals = res.locals; + var fs = require('fs'); + + // locals.section is used to set the currently selected + // item in the header navigation. + locals.section = 'competitive'; + locals.cSection = '4v4'; + locals.ratingTypeTitle = '4v4'; + locals.ratingType = 'tmm_4v4_full_share'; + locals.apiURL = process.env.API_URL; + + fs.readFile('members/4v4.json', 'utf8', function (err, data) { + if(err) return; + locals.members = JSON.parse(data); + locals.lastPage = Math.ceil(locals.members.length / 100); + + // Render the view + res.render('leaderboards'); + }); + +}; diff --git a/routes/views/accounts/get/report.js b/routes/views/accounts/get/report.js index 89c7a389..f8954f44 100755 --- a/routes/views/accounts/get/report.js +++ b/routes/views/accounts/get/report.js @@ -13,7 +13,7 @@ exports = module.exports = function (req, res) { locals.game_id = req.query.game_id; // Game_id can be supplied as GET locals.offenders_names = []; // Offender name aswell - if (req.query.offenders != undefined) { + if (req.query.offenders !== undefined) { locals.offenders_names = req.query.offenders.split(" "); } @@ -22,7 +22,7 @@ exports = module.exports = function (req, res) { var flash = null; - if (req.originalUrl == '/report_submitted') { + if (req.originalUrl === '/report_submitted') { flash = {}; flash.class = 'alert-success'; @@ -63,7 +63,7 @@ exports = module.exports = function (req, res) { if (report.relationships.lastModerator.data) { for (l in reports.included) { const user = reports.included[l]; - if (user.type == "player" && user.id == report.relationships.lastModerator.data.id) { + if (user.type === "player" && user.id === report.relationships.lastModerator.data.id) { moderator = user.attributes.login; break; } diff --git a/routes/views/tournaments.js b/routes/views/tournaments.js deleted file mode 100644 index 0a8dae2c..00000000 --- a/routes/views/tournaments.js +++ /dev/null @@ -1,36 +0,0 @@ -var request = require('request'); -var challonge_config = require('../challonge_config'); - -exports = module.exports = function(req, res) { - - var locals = res.locals; - - // locals.section is used to set the currently selected - // item in the header navigation. - locals.section = 'competitive'; - locals.cSection = 'tournaments'; - locals.data = { - }; - locals.error = false; - locals.data.upcomingTournaments = []; - locals.data.runningTournaments = []; - - request(challonge_config.getAuth() + '/tournaments.json', function (error, response, body) { - if (!error && response.statusCode == 200) { - var tournaments = JSON.parse(body); - for (tournament of tournaments) { - if (tournament.tournament.state === 'pending') { - var startDate = new Date(tournament.tournament.start_at); - tournament.tournament.start_at = startDate.toUTCString().replace("GMT", "UTC"); - locals.data.upcomingTournaments.push(tournament.tournament); - } else if (tournament.tournament.state === 'underway' || tournament.tournament.state === 'in_progress') { - locals.data.runningTournaments.push(tournament.tournament); - } - } - } else { - locals.error = true; - } - // Render the view - res.render('tournaments'); - }); -}; diff --git a/scripts/extractor.js b/scripts/extractor.js index ba7f7fdf..687a30e8 100644 --- a/scripts/extractor.js +++ b/scripts/extractor.js @@ -2,7 +2,8 @@ require("dotenv").config(); let jsonapi = require("json-api-models"); let request = require("request"); -let fs = require('fs'); +let fs = require("fs"); +let moment = require("moment"); function saveLeaderboardRatingsToFile(ratings, filename) { @@ -91,9 +92,25 @@ module.exports.run = function run() { saveLeaderboardRatingsToFile(ratings, "members/2v2.json"); }); + + models.reset(); + + request(process.env.API_URL + "/data/leaderboardRating?include=player&sort=-rating&filter=leaderboard.id==4;updateTime=ge=" + + pastMonth.format("YYYY-MM-DDTHH:mm:ss") + "Z", function (error, response, body) { + if (error || response.statusCode > 210) { + console.log(moment().format("DD-MM-YYYY - HH:mm:ss") + ' - There was an issue while fetching leaderboards 4v4:'); + console.error(error); + if (response) console.trace(response.statusCode); + return; + } + + const ratings = models.sync(JSON.parse(body)); + + saveLeaderboardRatingsToFile(ratings, "members/4v4.json"); + }); } catch (e) { console.log(moment().format("DD-MM-YYYY - HH:mm:ss") + ' - An error occured while extracting leaderboards:'); console.log(e); } -}; \ No newline at end of file +}; diff --git a/scripts/getAllClans.js b/scripts/getAllClans.js index 6339ff75..2bacee84 100644 --- a/scripts/getAllClans.js +++ b/scripts/getAllClans.js @@ -1,7 +1,8 @@ -require('dotenv').config(); +require("dotenv").config(); -let request = require('request'); -let fs = require('fs'); +let request = require("request"); +let fs = require("fs"); +let moment = require("moment"); module.exports.run = async function run(leagueData) { console.log(moment().format("DD-MM-YYYY - HH:mm:ss") + ' - Updating clan list...'); diff --git a/templates/layouts/default.pug b/templates/layouts/default.pug index ff2ddb3f..ad05adec 100755 --- a/templates/layouts/default.pug +++ b/templates/layouts/default.pug @@ -72,7 +72,7 @@ html(lang='en') li(class=(section === 'news' ? 'active' : null)): a(href='/newshub') i.fas.fa-rss span News - li(class=(section === 'competitive' ? 'active' : null)): a(href='/competitive/tournaments') + li(class=(section === 'competitive' ? 'active' : null)): a(href='/competitive/leaderboards/global') i.fas.fa-trophy span Competitive li(class=(section === 'clan' ? 'active' : null)): a(href='/clans') diff --git a/templates/mixins/form/account.pug b/templates/mixins/form/account.pug index 2c8c69b5..3f3657f6 100644 --- a/templates/mixins/form/account.pug +++ b/templates/mixins/form/account.pug @@ -39,7 +39,7 @@ mixin confirm-password(passwordName,labelPassword) .form-group.has-feedback label Confirm #{labelPassword} Password: .input-group - input(type='password', name=passwordName + '_confirm', required='required',data-match='#inputPassword', data-match-error="Passwords don't match. Please fix!", data-minlength='6').form-control + input(type='password', name=passwordName + '_confirm', required='required', data-match='#inputPassword', data-match-error="Passwords don't match. Please fix!", data-minlength='6').form-control span(aria-hidden='true').glyphicon.form-control-feedback .help-block.with-errors @@ -69,6 +69,10 @@ mixin tosagree(checked) .input-group p I have read and agree with our Privacy Statement input(type='checkbox', name='privacyagree', required='required') + label Agree to our Code of Conduct + .input-group + p I have read and agree with out Code of Conduct + input(type='checkbox', name='cocagree', required='required') mixin gogUsername .form-group.has-feedback diff --git a/templates/views/account/register.pug b/templates/views/account/register.pug index c4f02de0..b0f065c5 100644 --- a/templates/views/account/register.pug +++ b/templates/views/account/register.pug @@ -14,9 +14,11 @@ block content li Your email address is the only way to regain access to your account if you lose your password. If you lose both your password and your email, you will lose access to your account. li Full FAF Social rules: FAF Lobby and Forum rules hr - h3.account-steamLink-warning-title STEAM LINKING MANDATORY - p.account-steamLink-warning-subtext Owning the game on Steam is mandatory to play on FAF. After registration, you will need to login to the FAF website to link your account to Steam. - p Note: According to GPG's statement, ALL existing CD keys for either Supreme Commander and Forged Alliance can be redeemed on Steam for a copy of the Supreme Commander Gold Edition bundle. + h3.account-steamLink-warning-title Account Link is Mandatory + p.account-steamLink-warning-subtext After registration, you will need to login to the FAF website to link your account with steam or gog! + li Link Account With Steam + li Link Account With GOG + p Note: According to GPG's statement, ALL existing CD keys for either Supreme "Commander and Forged Alliance can be redeemed on Steam for a copy of the Supreme Commander Gold Edition bundle. On GOG you need the Gold Edition to play on FAF. hr .row @@ -24,7 +26,7 @@ block content +flash-messages(flash) .row .col-md-offset-3.col-md-6 - form(method='post',action="/account/register",data-toggle="validator") + form(method='post', action="/account/register", data-toggle="validator") +username +email +tosagree diff --git a/templates/views/account/requestPasswordReset.pug b/templates/views/account/requestPasswordReset.pug index e0cece86..e243f6a9 100644 --- a/templates/views/account/requestPasswordReset.pug +++ b/templates/views/account/requestPasswordReset.pug @@ -30,6 +30,7 @@ block content .col-md-12 h2.account-subtitle.text-center Via steam p Click on the image below to get to the Steam login page: + p Note: if you are linked with GOG you can't use Steam password reset a(href=steamReset) img(src='/images/steam_link.png') diff --git a/templates/views/index.pug b/templates/views/index.pug index b12e8e34..8ae9de8a 100644 --- a/templates/views/index.pug +++ b/templates/views/index.pug @@ -80,9 +80,10 @@ block content p Unleash the most powerful weapon in the galaxy, the Supreme Commander, in one of four diverse factions: The United Earth Federation, The Cybran Nation, The Aeon Illuminate or The Order (Seraphim). .row.text-center.buy-now hr - h3 To play Forged Alliance Forever, you must first install Supreme Commander: Forged Alliance. You can purchase it for less than 10€, below: + h3 To play Forged Alliance Forever, you must first install Supreme Commander: Forged Alliance. You can purchase it for less than 15€, below: .col-md-12.text-center a(href="https://store.steampowered.com/app/9420" class="btn btn-default btn-lg btn-outro btn-danger") Buy from Steam + a(href="https://www.gog.com/en/game/supreme_commander_gold_edition" class="btn btn-default btn-lg btn-outro btn-danger") Buy from GOG block js diff --git a/templates/views/tournaments.pug b/templates/views/tournaments.pug deleted file mode 100644 index 2fc6cdaa..00000000 --- a/templates/views/tournaments.pug +++ /dev/null @@ -1,50 +0,0 @@ -extends competitive_nav - -block cContent - if error - h3 Error: No response from Challonge - else - - if data.runningTournaments.length === 0 - else - each tournament, i in data.runningTournaments - h1.text-center= tournament.name - br - iframe.tournament-live(src='https://challonge.com/#{tournament.url}/module?theme=3899' width='100%' height='900' frameborder='0' scrolling='auto' allowtransparency='true') - button(data-toggle="collapse" data-target="##{tournament.url}") Description - if tournament.description === "" - div(id="#{tournament.url}" class="collapse") Tournament has no description - else - div(id="#{tournament.url}" class="collapse") !{tournament.description} - br - hr - br - - h2 Upcoming Tournaments - br - - if error - h3 Error: No response from Challonge - else - - if data.upcomingTournaments.length === 0 && data.runningTournaments.length === 0 - p.text-center No upcoming tournaments have been registered - else - table.table.table-striped.table-hover - thead - tr - th Name - th Start at - th Link - tbody - each tournament, i in data.runningTournaments - tr.info - td= tournament.name - td In Progress - td: a(href=tournament.full_challonge_url target="_blank")= tournament.full_challonge_url - - each tournament, i in data.upcomingTournaments - tr - td= tournament.name - td= (tournament.start_at === 'Thu, 01 Jan 1970 00:00:00 UTC' ? 'Undetermined' : tournament.start_at) - td: a(href=tournament.full_challonge_url target="_blank")= tournament.full_challonge_url