Links from database are being passed to the view. TODO create links
This commit is contained in:
@ -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;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -15,7 +15,8 @@ var bonfireSchema = new mongoose.Schema({
|
||||
difficulty: String,
|
||||
description: Array,
|
||||
tests: Array,
|
||||
challengeSeed: String
|
||||
challengeSeed: String,
|
||||
MDNlinks: [String]
|
||||
});
|
||||
|
||||
module.exports = mongoose.model('Bonfire', bonfireSchema);
|
||||
|
22
seed_data/bonfireMDNlinks.js
Normal file
22
seed_data/bonfireMDNlinks.js
Normal file
@ -0,0 +1,22 @@
|
||||
// MDN Links
|
||||
|
||||
/* These links are for Bonfires. Each key/value pair is used to render a Bonfire with approrpiate links.
|
||||
Making an effort to keep methods in alphabetical order will help others behind you.
|
||||
|
||||
*/
|
||||
var links =
|
||||
{
|
||||
// ========= GLOBAL OBJECTS
|
||||
"Array-global" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array",
|
||||
"Object-global" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object",
|
||||
"String-global" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String",
|
||||
|
||||
// ======== STRING METHODS
|
||||
"string-split" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split",
|
||||
|
||||
// ======== ARRAY METHODS
|
||||
"array-join" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join",
|
||||
"array-reverse": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse"
|
||||
};
|
||||
|
||||
module.exports = links;
|
@ -31,7 +31,8 @@
|
||||
"You may need to turn the string into an array before you can reverse it.",
|
||||
"Your result must be a string."
|
||||
],
|
||||
"challengeSeed": "function reverseString(str) {\n return str;\r\n}\n\nreverseString('hello');"
|
||||
"challengeSeed": "function reverseString(str) {\n return str;\r\n}\n\nreverseString('hello');",
|
||||
"links" : ["String-global", "string-methods.split"]
|
||||
},
|
||||
{
|
||||
"_id": "a302f7aae1aa3152a5b413bc",
|
||||
|
@ -92,6 +92,7 @@ block content
|
||||
var started = Math.floor(Date.now() / 1000);
|
||||
var _ = R;
|
||||
var dashed = !{JSON.stringify(dashedName)};
|
||||
var MDNlinks = !{JSON.stringify(MDNlinks)};
|
||||
.col-xs-12.col-sm-12.col-md-8
|
||||
#mainEditorPanel
|
||||
form.code
|
||||
|
Reference in New Issue
Block a user