Abstract map and showChallenge logic
Rename some legacy naming conventions Remove logic for waypoint,basejumps, etc...
This commit is contained in:
@ -189,15 +189,6 @@ function getRenderData$(user, challenge$, origChallengeName, solution) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCompletedChallengeIds(user = {}) {
|
|
||||||
// if user
|
|
||||||
// get the id's of all the users completed challenges
|
|
||||||
return !user.completedChallenges ?
|
|
||||||
[] :
|
|
||||||
_.uniq(user.completedChallenges)
|
|
||||||
.map(({ id, _id }) => id || _id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a stream of an array of all the challenge blocks
|
// create a stream of an array of all the challenge blocks
|
||||||
function getSuperBlocks$(challenge$, completedChallenges) {
|
function getSuperBlocks$(challenge$, completedChallenges) {
|
||||||
return challenge$
|
return challenge$
|
||||||
@ -415,19 +406,7 @@ 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 completedChallenges = getCompletedChallengeIds(req.user);
|
getRenderData$(req.user, challenge$, req.params.challengeName, solution)
|
||||||
|
|
||||||
Observable.combineLatest(
|
|
||||||
getRenderData$(req.user, challenge$, req.params.challengeName, solution),
|
|
||||||
getSuperBlocks$(challenge$, completedChallenges),
|
|
||||||
({ data, ...rest }, superBlocks) => ({
|
|
||||||
...rest,
|
|
||||||
data: {
|
|
||||||
...data,
|
|
||||||
superBlocks
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
.subscribe(
|
.subscribe(
|
||||||
({ type, redirectUrl, message, data }) => {
|
({ type, redirectUrl, message, data }) => {
|
||||||
if (message) {
|
if (message) {
|
||||||
@ -573,9 +552,14 @@ module.exports = function(app) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMap({ user }, res, next) {
|
function showMap({ user = {} }, res, next) {
|
||||||
|
// if user
|
||||||
|
// get the id's of all the users completed challenges
|
||||||
|
const completedChallenges = !user.completedChallenges ?
|
||||||
|
[] :
|
||||||
|
_.uniq(user.completedChallenges).map(({ id, _id }) => id || _id);
|
||||||
|
|
||||||
getSuperBlocks$(challenge$, getCompletedChallengeIds(user))
|
getSuperBlocks$(challenge$, completedChallenges)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
superBlocks => {
|
superBlocks => {
|
||||||
res.render('map/show', {
|
res.render('map/show', {
|
||||||
|
@ -1,58 +0,0 @@
|
|||||||
extends ../layout-wide
|
|
||||||
block content
|
|
||||||
.col-xs-12.col-sm-4.col-sm-offset-8
|
|
||||||
for superBlock, index in superBlocks
|
|
||||||
for challengeBlock in superBlock.blocks
|
|
||||||
h4.bold #{challengeBlock.name} (#{challengeBlock.time})
|
|
||||||
for challenge in challengeBlock.challenges
|
|
||||||
if challenge.completed
|
|
||||||
p.text-primary.ion-checkmark-circled.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
|
||||||
a(href="/challenges/#{challenge.dashedName}")
|
|
||||||
= challenge.title
|
|
||||||
span.sr-only= " Complete"
|
|
||||||
else
|
|
||||||
if challenge.type === "bonfire"
|
|
||||||
p.ion-asterisk.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
|
||||||
a(name="#{challenge.dashedName}" href="/challenges/#{challenge.dashedName}" class=challenge.isComingSoon ? 'disabled' : '')
|
|
||||||
span= challenge.title
|
|
||||||
span.sr-only= " Incomplete"
|
|
||||||
if challenge.markNew
|
|
||||||
span.text-success.small    
|
|
||||||
strong
|
|
||||||
em New
|
|
||||||
if challengeBlock.isComingSoon
|
|
||||||
span.text-success.small    
|
|
||||||
strong
|
|
||||||
em Coming Soon
|
|
||||||
else
|
|
||||||
p.ion-ios-circle-outline.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
|
||||||
a(name="#{challenge.dashedName}" href="/challenges/#{challenge.dashedName}" class=challenge.isComingSoon ? 'disabled' : '')
|
|
||||||
span= challenge.title
|
|
||||||
span.sr-only= " Incomplete"
|
|
||||||
if challenge.markNew
|
|
||||||
span.text-success.small    
|
|
||||||
strong
|
|
||||||
em New
|
|
||||||
if challengeBlock.isComingSoon
|
|
||||||
span.text-success.small    
|
|
||||||
strong
|
|
||||||
em Coming Soon
|
|
||||||
if (index < superBlocks.length)
|
|
||||||
hr
|
|
||||||
|
|
||||||
script.
|
|
||||||
var username = !{JSON.stringify(user && user.username || '')};
|
|
||||||
var lastCompleted = !{JSON.stringify(lastCompleted || false)}
|
|
||||||
$(document).ready(function () {
|
|
||||||
if (!localStorage || !localStorage.hideRedditNotice) {
|
|
||||||
$("#map-notice").removeClass("hidden");
|
|
||||||
}
|
|
||||||
$("#hide-map-notice-button").on("click", function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
$("#map-notice").addClass('animated fadeOut');
|
|
||||||
setTimeout(function() {
|
|
||||||
$("#map-notice").hide();
|
|
||||||
}, 1000);
|
|
||||||
localStorage.hideRedditNotice = "true";
|
|
||||||
});
|
|
||||||
});
|
|
@ -1,137 +1,42 @@
|
|||||||
extends ../layout-wide
|
extends ../layout-wide
|
||||||
block content
|
block content
|
||||||
.row
|
.col-xs-12.col-sm-4.col-sm-offset-8
|
||||||
.col-xs-12.col-md-6.col-md-offset-3
|
for superBlock, index in superBlocks
|
||||||
ul
|
for challengeBlock in superBlock.blocks
|
||||||
for superBlock in superBlocks
|
h4.bold #{challengeBlock.name} (#{challengeBlock.time})
|
||||||
h2= superBlock.name
|
for challenge in challengeBlock.challenges
|
||||||
for challengeBlock in superBlock.blocks
|
if challenge.completed
|
||||||
.row
|
p.text-primary.ion-checkmark-circled.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
||||||
if (user)
|
a(href="/challenges/#{challenge.dashedName}")
|
||||||
.col-xs-11.col-sm-8.col-md-9
|
= challenge.title
|
||||||
li.map-p.negative-10
|
span.sr-only= " Complete"
|
||||||
|
|
else
|
||||||
a(href='#' + challengeBlock.dashedName)= challengeBlock.name
|
if challenge.type === "bonfire"
|
||||||
if challengeBlock.markNew
|
p.ion-asterisk.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
||||||
span.text-info.small    
|
a(name="#{challenge.dashedName}" href="/challenges/#{challenge.dashedName}" class=challenge.isComingSoon ? 'disabled' : '')
|
||||||
strong
|
span= challenge.title
|
||||||
em NEW
|
span.sr-only= " Incomplete"
|
||||||
if challengeBlock.isComingSoon
|
if challenge.markNew
|
||||||
span.text-info.small    
|
span.text-success.small    
|
||||||
strong
|
strong
|
||||||
em Coming Soon
|
em New
|
||||||
else
|
if challengeBlock.isComingSoon
|
||||||
.hidden-xs.col-sm-3.col-md-2
|
span.text-success.small    
|
||||||
.col-xs-10.col-sm-8.col-md-9
|
strong
|
||||||
span.map-p.negative-10
|
em Coming Soon
|
||||||
a(href='#' + challengeBlock.dashedName)= challengeBlock.name
|
else
|
||||||
if challengeBlock.markNew
|
p.ion-ios-circle-outline.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
||||||
span.text-info.small    
|
a(name="#{challenge.dashedName}" href="/challenges/#{challenge.dashedName}" class=challenge.isComingSoon ? 'disabled' : '')
|
||||||
strong
|
span= challenge.title
|
||||||
em NEW
|
span.sr-only= " Incomplete"
|
||||||
if challengeBlock.isComingSoon
|
if challenge.markNew
|
||||||
span.text-info.small    
|
span.text-success.small    
|
||||||
strong
|
strong
|
||||||
em Coming Soon
|
em New
|
||||||
h2 Full Stack Development Certification
|
if challengeBlock.isComingSoon
|
||||||
.row
|
span.text-success.small    
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
strong
|
||||||
li.map-p.negative-10
|
em Coming Soon
|
||||||
|
|
|
||||||
span.ion-locked.padded-ionic-icon
|
|
||||||
| Greenfield Nonprofit Project 1
|
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
|
||||||
li.map-p.negative-10
|
|
||||||
|
|
|
||||||
span.ion-locked.padded-ionic-icon
|
|
||||||
| Greenfield Nonprofit Project 2
|
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
|
||||||
li.map-p.negative-10
|
|
||||||
|
|
|
||||||
span.ion-locked.padded-ionic-icon
|
|
||||||
| Legacy Nonprofit Project 1
|
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
|
||||||
li.map-p.negative-10
|
|
||||||
|
|
|
||||||
span.ion-locked.padded-ionic-icon
|
|
||||||
| Legacy Nonprofit Project 2
|
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
|
||||||
li.map-p.negative-10
|
|
||||||
|
|
|
||||||
span.ion-locked.padded-ionic-icon
|
|
||||||
| Claim your Full Stack Development Certification
|
|
||||||
|
|
||||||
h2 Coding Interview Preparation
|
|
||||||
.row
|
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
|
||||||
li.map-p.negative-10
|
|
||||||
|
|
|
||||||
span.ion-locked.padded-ionic-icon
|
|
||||||
| Whiteboard Coding Interview Training
|
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
|
||||||
li.map-p.negative-10
|
|
||||||
|
|
|
||||||
span.ion-locked.padded-ionic-icon
|
|
||||||
| Critical Thinking Interview Training
|
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
|
||||||
li.map-p.negative-10
|
|
||||||
|
|
|
||||||
span.ion-locked.padded-ionic-icon
|
|
||||||
| Mock Interview 1
|
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
|
||||||
li.map-p.negative-10
|
|
||||||
|
|
|
||||||
span.ion-locked.padded-ionic-icon
|
|
||||||
| Mock Interview 2
|
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
|
||||||
li.map-p.negative-10
|
|
||||||
|
|
|
||||||
span.ion-locked.padded-ionic-icon
|
|
||||||
| Mock Interview 3
|
|
||||||
hr
|
|
||||||
.row
|
|
||||||
.col-xs-12.col-md-6.col-md-offset-3
|
|
||||||
for superBlock, index in superBlocks
|
|
||||||
for challengeBlock in superBlock.blocks
|
|
||||||
.row
|
|
||||||
a(href='#' name=challengeBlock.dashedName)
|
|
||||||
.spacer.negative-55
|
|
||||||
.row
|
|
||||||
h4.bold #{challengeBlock.name} (#{challengeBlock.time})
|
|
||||||
for challenge in challengeBlock.challenges
|
|
||||||
|
|
||||||
.col-xs-12.col-sm-9.col-md-10
|
|
||||||
if challenge.completed
|
|
||||||
p.text-primary.ion-checkmark-circled.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
|
||||||
a(href="/challenges/#{challenge.dashedName}")
|
|
||||||
= challenge.title
|
|
||||||
span.sr-only= " Complete"
|
|
||||||
else if (challenge.type === "bonfire")
|
|
||||||
p.ion-asterisk.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
|
||||||
a(name="#{challenge.dashedName}" href="/challenges/#{challenge.dashedName}" class=challenge.isComingSoon ? 'disabled' : '')
|
|
||||||
span= challenge.title
|
|
||||||
span.sr-only= " Incomplete"
|
|
||||||
if challenge.markNew
|
|
||||||
span.text-success.small    
|
|
||||||
strong
|
|
||||||
em New
|
|
||||||
if challengeBlock.isComingSoon
|
|
||||||
span.text-success.small    
|
|
||||||
strong
|
|
||||||
em Coming Soon
|
|
||||||
else
|
|
||||||
p.ion-ios-circle-outline.padded-ionic-icon.negative-15(name="#{challenge.dashedName}")
|
|
||||||
a(name="#{challenge.dashedName}" href="/challenges/#{challenge.dashedName}" class=challenge.isComingSoon ? 'disabled' : '')
|
|
||||||
span= challenge.title
|
|
||||||
span.sr-only= " Incomplete"
|
|
||||||
if challenge.markNew
|
|
||||||
span.text-success.small    
|
|
||||||
strong
|
|
||||||
em New
|
|
||||||
if challengeBlock.isComingSoon
|
|
||||||
span.text-success.small    
|
|
||||||
strong
|
|
||||||
em Coming Soon
|
|
||||||
if (index < superBlocks.length)
|
if (index < superBlocks.length)
|
||||||
hr
|
hr
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user