move getMDNLinks func to utils
This commit is contained in:
@ -32,27 +32,13 @@
|
|||||||
|
|
||||||
var R = require('ramda'),
|
var R = require('ramda'),
|
||||||
utils = require('../utils'),
|
utils = require('../utils'),
|
||||||
userMigration = require('../utils/middleware').userMigration,
|
userMigration = require('../utils/middleware').userMigration;
|
||||||
MDNlinks = require('../../seed/bonfireMDNlinks');
|
|
||||||
|
|
||||||
var challengeMapWithNames = utils.getChallengeMapWithNames();
|
var challengeMapWithNames = utils.getChallengeMapWithNames();
|
||||||
var challengeMapWithIds = utils.getChallengeMapWithIds();
|
var challengeMapWithIds = utils.getChallengeMapWithIds();
|
||||||
var challengeMapWithDashedNames = utils.getChallengeMapWithDashedNames();
|
var challengeMapWithDashedNames = utils.getChallengeMapWithDashedNames();
|
||||||
|
|
||||||
|
var getMDNLinks = utils.getMDNLinks;
|
||||||
function getMDNlinks(links) {
|
|
||||||
// takes in an array of links, which are strings
|
|
||||||
var populatedLinks = [];
|
|
||||||
|
|
||||||
// for each key value, push the corresponding link
|
|
||||||
// from the MDNlinks object into a new array
|
|
||||||
if (links) {
|
|
||||||
links.forEach(function (value) {
|
|
||||||
populatedLinks.push(MDNlinks[value]);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return populatedLinks;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = function(app) {
|
module.exports = function(app) {
|
||||||
var router = app.loopback.Router();
|
var router = app.loopback.Router();
|
||||||
@ -295,7 +281,7 @@ module.exports = function(app) {
|
|||||||
bonfires: challenge,
|
bonfires: challenge,
|
||||||
challengeId: challenge.id,
|
challengeId: challenge.id,
|
||||||
MDNkeys: challenge.MDNlinks,
|
MDNkeys: challenge.MDNlinks,
|
||||||
MDNlinks: getMDNlinks(challenge.MDNlinks),
|
MDNlinks: getMDNLinks(challenge.MDNlinks),
|
||||||
challengeType: challenge.challengeType
|
challengeType: challenge.challengeType
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ var path = require('path'),
|
|||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
|
|
||||||
|
|
||||||
|
MDNlinks = require('../../seed/bonfireMDNlinks'),
|
||||||
resources = require('./resources.json'),
|
resources = require('./resources.json'),
|
||||||
nonprofits = require('../../seed/nonprofits.json'),
|
nonprofits = require('../../seed/nonprofits.json'),
|
||||||
fieldGuides = require('../../seed/field-guides.json');
|
fieldGuides = require('../../seed/field-guides.json');
|
||||||
@ -16,7 +17,7 @@ var path = require('path'),
|
|||||||
*/
|
*/
|
||||||
var allFieldGuideIds, allFieldGuideNames, allNonprofitNames,
|
var allFieldGuideIds, allFieldGuideNames, allNonprofitNames,
|
||||||
challengeMap, challengeMapForDisplay, challengeMapWithIds,
|
challengeMap, challengeMapForDisplay, challengeMapWithIds,
|
||||||
challengeMapWithNames, allChallengeIds, allChallenges,
|
challengeMapWithNames, allChallengeIds,
|
||||||
challengeMapWithDashedNames;
|
challengeMapWithDashedNames;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -216,5 +217,18 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
},
|
||||||
|
|
||||||
|
getMDNLinks: function(links) {
|
||||||
|
if (!links) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
// takes in an array of links, which are strings
|
||||||
|
|
||||||
|
// for each key value, push the corresponding link
|
||||||
|
// from the MDNlinks object into a new array
|
||||||
|
return links.map(function(value) {
|
||||||
|
return MDNlinks[value];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user