Merge pull request #6182 from FreeCodeCamp/fix/remove-old-terminology
Remove old terminology
This commit is contained in:
@ -146,7 +146,7 @@ function getRenderData$(user, challenge$, origChallengeName, solution) {
|
|||||||
type: 'redirect',
|
type: 'redirect',
|
||||||
redirectUrl: '/map',
|
redirectUrl: '/map',
|
||||||
message: dedent`
|
message: dedent`
|
||||||
404: We couldn\'t find a challenge with the name ${origChallengeName}.
|
We couldn't find a challenge with the name ${origChallengeName}.
|
||||||
Please double check the name.
|
Please double check the name.
|
||||||
`
|
`
|
||||||
});
|
});
|
||||||
@ -478,8 +478,9 @@ module.exports = function(app) {
|
|||||||
|
|
||||||
function showChallenge(req, res, next) {
|
function showChallenge(req, res, next) {
|
||||||
const solution = req.query.solution;
|
const solution = req.query.solution;
|
||||||
|
const challengeName = req.params.challengeName.replace(challengesRegex, '');
|
||||||
|
|
||||||
getRenderData$(req.user, challenge$, req.params.challengeName, solution)
|
getRenderData$(req.user, challenge$, challengeName, solution)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
({ type, redirectUrl, message, data }) => {
|
({ type, redirectUrl, message, data }) => {
|
||||||
if (message) {
|
if (message) {
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
"./middlewares/constant-headers": {},
|
"./middlewares/constant-headers": {},
|
||||||
"./middlewares/csp": {},
|
"./middlewares/csp": {},
|
||||||
"./middlewares/express-rx": {},
|
"./middlewares/express-rx": {},
|
||||||
|
"./middlewares/jade-helpers": {},
|
||||||
"./middlewares/global-locals": {},
|
"./middlewares/global-locals": {},
|
||||||
"./middlewares/revision-helpers": {}
|
"./middlewares/revision-helpers": {}
|
||||||
},
|
},
|
||||||
|
11
server/middlewares/jade-helpers.js
Normal file
11
server/middlewares/jade-helpers.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
const challengesRegex = /^(bonfire|waypoint|zipline|basejump|checkpoint):\s/i;
|
||||||
|
|
||||||
|
export default function jadeHelpers() {
|
||||||
|
return function jadeHelpersMiddleware(req, res, next) {
|
||||||
|
res.locals.removeOldTerms = function removeOldTerms(str) {
|
||||||
|
return str.replace(challengesRegex, '');
|
||||||
|
};
|
||||||
|
|
||||||
|
next();
|
||||||
|
};
|
||||||
|
}
|
@ -132,12 +132,12 @@ block content
|
|||||||
for challenge in baseAndZip
|
for challenge in baseAndZip
|
||||||
tr
|
tr
|
||||||
td.col-xs-4.hidden-xs
|
td.col-xs-4.hidden-xs
|
||||||
a(href='/challenges/' + challenge.name, target='_blank')= challenge.name
|
a(href='/challenges/' + removeOldTerms(challenge.name), target='_blank')= removeOldTerms(challenge.name)
|
||||||
td.col-xs-2.hidden-xs= challenge.completedDate ? moment(challenge.completedDate, 'x').format("MMM DD, YYYY") : 'Not Available'
|
td.col-xs-2.hidden-xs= challenge.completedDate ? moment(challenge.completedDate, 'x').format("MMM DD, YYYY") : 'Not Available'
|
||||||
td.col-xs-6.hidden-xs
|
td.col-xs-6.hidden-xs
|
||||||
a(href=challenge.solution, target='_blank') View my project
|
a(href=challenge.solution, target='_blank') View my project
|
||||||
td.col-xs-12.visible-xs
|
td.col-xs-12.visible-xs
|
||||||
a(href=challenge.solution, target='_blank')=challenge.name
|
a(href=challenge.solution, target='_blank')= removeOldTerms(challenge.name)
|
||||||
if (bonfires.length > 0)
|
if (bonfires.length > 0)
|
||||||
.col-sm-12
|
.col-sm-12
|
||||||
table.table.table-striped
|
table.table.table-striped
|
||||||
@ -148,12 +148,12 @@ block content
|
|||||||
th.col-xs-3.hidden-xs Solution
|
th.col-xs-3.hidden-xs Solution
|
||||||
for bonfire in bonfires
|
for bonfire in bonfires
|
||||||
tr
|
tr
|
||||||
td.col-xs-6.hidden-xs= bonfire.name
|
td.col-xs-6.hidden-xs= removeOldTerms(bonfire.name)
|
||||||
td.col-xs-3.hidden-xs= bonfire.completedDate ? moment(bonfire.completedDate, 'x').format("MMM DD, YYYY") : 'Not Available'
|
td.col-xs-3.hidden-xs= bonfire.completedDate ? moment(bonfire.completedDate, 'x').format("MMM DD, YYYY") : 'Not Available'
|
||||||
td.col-xs-3.hidden-xs
|
td.col-xs-3.hidden-xs
|
||||||
a(href='/challenges/' + bonfire.name + '?solution=' + encodeURIComponent(encodeFcc(bonfire.solution)), target='_blank') View my solution
|
a(href='/challenges/' + removeOldTerms(bonfire.name) + '?solution=' + encodeURIComponent(encodeFcc(bonfire.solution)), target='_blank') View my solution
|
||||||
td.col-xs-12.visible-xs
|
td.col-xs-12.visible-xs
|
||||||
a(href='/challenges/' + bonfire.name + '?solution=' + encodeURIComponent(encodeFcc(bonfire.solution)), target='_blank')= bonfire.name
|
a(href='/challenges/' + removeOldTerms(bonfire.name) + '?solution=' + encodeURIComponent(encodeFcc(bonfire.solution)), target='_blank')= removeOldTerms(bonfire.name)
|
||||||
if (waypoints.length > 0)
|
if (waypoints.length > 0)
|
||||||
.col-sm-12
|
.col-sm-12
|
||||||
table.table.table-striped
|
table.table.table-striped
|
||||||
@ -164,18 +164,18 @@ block content
|
|||||||
th.col-xs-3.hidden-xs Solution
|
th.col-xs-3.hidden-xs Solution
|
||||||
for challenge in waypoints
|
for challenge in waypoints
|
||||||
tr
|
tr
|
||||||
td.col-xs-6.hidden-xs= challenge.name
|
td.col-xs-6.hidden-xs= removeOldTerms(challenge.name)
|
||||||
td.col-xs-3.hidden-xs= challenge.completedDate ?moment(challenge.completedDate, 'x').format("MMM DD, YYYY") : 'Not Available'
|
td.col-xs-3.hidden-xs= challenge.completedDate ?moment(challenge.completedDate, 'x').format("MMM DD, YYYY") : 'Not Available'
|
||||||
td.col-xs-3.hidden-xs
|
td.col-xs-3.hidden-xs
|
||||||
if (challenge.solution)
|
if (challenge.solution)
|
||||||
a(href='/challenges/' + challenge.name + '?solution=' + encodeURIComponent(encodeFcc(challenge.solution)), target='_blank') View my solution
|
a(href='/challenges/' + removeOldTerms(challenge.name) + '?solution=' + encodeURIComponent(encodeFcc(challenge.solution)), target='_blank') View my solution
|
||||||
else
|
else
|
||||||
a(href='/challenges/' + challenge.name) View this challenge
|
a(href='/challenges/' + removeOldTerms(challenge.name)) View this challenge
|
||||||
td.col-xs-12.visible-xs
|
td.col-xs-12.visible-xs
|
||||||
if (challenge.solution)
|
if (challenge.solution)
|
||||||
a(href='/challenges/' + challenge.name + '?solution=' + encodeURIComponent(encodeFcc(challenge.solution)), target='_blank')= challenge.name
|
a(href='/challenges/' + removeOldTerms(challenge.name) + '?solution=' + encodeURIComponent(encodeFcc(challenge.solution)), target='_blank')= removeOldTerms(challenge.name)
|
||||||
else
|
else
|
||||||
a(href='/challenges/' + challenge.name)= challenge.name
|
a(href='/challenges/' + removeOldTerms(challenge.name))= removeOldTerms(challenge.name)
|
||||||
|
|
||||||
if (user && user.username === username)
|
if (user && user.username === username)
|
||||||
h1.text-center Manage your account
|
h1.text-center Manage your account
|
||||||
|
Reference in New Issue
Block a user