Merge pull request #262 from aldraco/bonfirelinks

Bonfire MDN links - Issue #255
This commit is contained in:
Quincy Larson
2015-03-28 20:34:34 -07:00
5 changed files with 130 additions and 18 deletions

View File

@ -2,7 +2,8 @@ var _ = require('lodash'),
debug = require('debug')('freecc:cntr:bonfires'),
Bonfire = require('./../models/Bonfire'),
User = require('./../models/User'),
resources = require('./resources');
resources = require('./resources'),
MDNlinks = require('./../seed_data/bonfireMDNlinks');
/**
* Bonfire controller
@ -110,7 +111,9 @@ exports.returnIndividualBonfire = function(req, res, next) {
phrase: resources.randomPhrase(),
compliment: resources.randomCompliment(),
bonfires: bonfire,
bonfireHash: bonfire._id
bonfireHash: bonfire._id,
MDNkeys: bonfire.MDNlinks,
MDNlinks: getMDNlinks(bonfire.MDNlinks)
});
});
@ -147,6 +150,23 @@ function randomString() {
return randomstring;
};
/**
* Helper function to populate the MDN links array.
*/
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
links.forEach(function(value, index) {
populatedLinks.push(MDNlinks[value]);
});
return populatedLinks;
};
/**
*
*/