Skip to content

Commit

Permalink
Web Site Minor Clean Up (#386)
Browse files Browse the repository at this point in the history
-  Removed Tournaments.pug Page and all corresponding pages due to its main use which displayed the FAF Challonge did not work and the Challonge API was causing long load times.

- Update Competitive tab to link to the Global ranks & added in 4v4 Full share

- Minor Page Clean ups

- Updated Main page and added GOG buy Link

- Updated Account Register due to still having Steam link mandatory.
  • Loading branch information
MrRowey authored May 29, 2022
1 parent c58367b commit b9f059b
Show file tree
Hide file tree
Showing 15 changed files with 72 additions and 120 deletions.
3 changes: 2 additions & 1 deletion express.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 0 additions & 5 deletions routes/challonge_config.js

This file was deleted.

1 change: 0 additions & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
18 changes: 6 additions & 12 deletions routes/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
}

Expand Down
23 changes: 23 additions & 0 deletions routes/views/4v4.js
Original file line number Diff line number Diff line change
@@ -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');
});

};
6 changes: 3 additions & 3 deletions routes/views/accounts/get/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(" ");
}

Expand All @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down
36 changes: 0 additions & 36 deletions routes/views/tournaments.js

This file was deleted.

21 changes: 19 additions & 2 deletions scripts/extractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
};
};
7 changes: 4 additions & 3 deletions scripts/getAllClans.js
Original file line number Diff line number Diff line change
@@ -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...');
Expand Down
2 changes: 1 addition & 1 deletion templates/layouts/default.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
6 changes: 5 additions & 1 deletion templates/mixins/form/account.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -69,6 +69,10 @@ mixin tosagree(checked)
.input-group
p I have read and agree with our <a href="https://faforever.com/privacy" rel="_new">Privacy Statement</a>
input(type='checkbox', name='privacyagree', required='required')
label Agree to our Code of Conduct
.input-group
p I have read and agree with out <a href=https://faforever.com/coc" rel="_new">Code of Conduct</a>
input(type='checkbox', name='cocagree', required='required')
mixin gogUsername
.form-group.has-feedback
Expand Down
10 changes: 6 additions & 4 deletions templates/views/account/register.pug
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ block content
li <strong>Your email address is the only way to regain access to your account</strong> if you lose your password. If you lose both your password and your email, you will lose access to your account.
li <strong>Full FAF Social rules:</strong> <a href="/rules">FAF Lobby and Forum rules</a>
hr
h3.account-steamLink-warning-title STEAM LINKING MANDATORY
p.account-steamLink-warning-subtext Owning the game on Steam is <strong>mandatory</strong> to play on FAF. After registration, you will need to login to the FAF website to <a href="https://www.faforever.com/account/link">link your account</a> to Steam.
p Note: According to <strong><a href="https://web.archive.org/web/20140903143132/http://forums.gaspowered.com/viewtopic.php?f=67&t=57459">GPG's statement</a></strong>, 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 <a href="https://www.faforever.com/account/link"> Link Account With Steam</a>
li <a href="https://www.faforever.com/account/linkGog"> Link Account With GOG</a>
p Note: According to <strong><a href="https://web.archive.org/web/20140903143132/http://forums.gaspowered.com/viewtopic.php?f=67&t=57459">GPG's statement</a></strong>, 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
.col-md-offset-3.col-md-6
+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
Expand Down
1 change: 1 addition & 0 deletions templates/views/account/requestPasswordReset.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
3 changes: 2 additions & 1 deletion templates/views/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
50 changes: 0 additions & 50 deletions templates/views/tournaments.pug

This file was deleted.

0 comments on commit b9f059b

Please sign in to comment.