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',
|
||||
redirectUrl: '/map',
|
||||
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.
|
||||
`
|
||||
});
|
||||
@ -478,8 +478,9 @@ module.exports = function(app) {
|
||||
|
||||
function showChallenge(req, res, next) {
|
||||
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(
|
||||
({ type, redirectUrl, message, data }) => {
|
||||
if (message) {
|
||||
|
@ -45,6 +45,7 @@
|
||||
"./middlewares/constant-headers": {},
|
||||
"./middlewares/csp": {},
|
||||
"./middlewares/express-rx": {},
|
||||
"./middlewares/jade-helpers": {},
|
||||
"./middlewares/global-locals": {},
|
||||
"./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
|
||||
tr
|
||||
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-6.hidden-xs
|
||||
a(href=challenge.solution, target='_blank') View my project
|
||||
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)
|
||||
.col-sm-12
|
||||
table.table.table-striped
|
||||
@ -148,12 +148,12 @@ block content
|
||||
th.col-xs-3.hidden-xs Solution
|
||||
for bonfire in bonfires
|
||||
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
|
||||
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
|
||||
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)
|
||||
.col-sm-12
|
||||
table.table.table-striped
|
||||
@ -164,18 +164,18 @@ block content
|
||||
th.col-xs-3.hidden-xs Solution
|
||||
for challenge in waypoints
|
||||
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
|
||||
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
|
||||
a(href='/challenges/' + challenge.name) View this challenge
|
||||
a(href='/challenges/' + removeOldTerms(challenge.name)) View this challenge
|
||||
td.col-xs-12.visible-xs
|
||||
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
|
||||
a(href='/challenges/' + challenge.name)= challenge.name
|
||||
a(href='/challenges/' + removeOldTerms(challenge.name))= removeOldTerms(challenge.name)
|
||||
|
||||
if (user && user.username === username)
|
||||
h1.text-center Manage your account
|
||||
|
Reference in New Issue
Block a user