Links from database are being passed to the view. TODO create links

This commit is contained in:
A. Drake
2015-03-23 23:20:19 -04:00
parent 5bfd8a8d54
commit 0bf68fea5f
5 changed files with 48 additions and 4 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,8 @@ exports.returnIndividualBonfire = function(req, res, next) {
phrase: resources.randomPhrase(),
compliment: resources.randomCompliment(),
bonfires: bonfire,
bonfireHash: bonfire._id
bonfireHash: bonfire._id,
MDNlinks: getMDNlinks(bonfire.MDNlinks)
});
});
@@ -147,6 +149,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;
};
/**
*
*/