add a modal that allows one to scroll through all wiki pages

This commit is contained in:
Michael Q Larson
2015-03-30 15:55:00 -07:00
parent 23a3e235a7
commit 106a10edca
6 changed files with 47 additions and 19 deletions

4
app.js
View File

@ -473,6 +473,8 @@ app.get('/api/trello', resourcesController.trelloCalls);
app.get('/bonfires/getBonfireList', bonfireController.showAllBonfires);
app.get('/wiki/getWikiList', wikiController.showAllWikis);
app.get('/playground', bonfireController.index);
app.get('/bonfires', bonfireController.returnNextBonfire);
@ -483,7 +485,7 @@ app.post('/bonfire-json-generator', bonfireController.generateChallenge);
app.get('/bonfire-challenge-generator', bonfireController.publicGenerator);
app.post('/bonfire-challenge-generator', bonfireController.testBonfire)
app.post('/bonfire-challenge-generator', bonfireController.testBonfire);
app.get(
'/bonfires/:bonfireName',

View File

@ -3,12 +3,14 @@ var async = require('async'),
Challenge = require('./../models/Challenge'),
Bonfire = require('./../models/Bonfire'),
Story = require('./../models/Story'),
Wiki = require('./../models/Wiki'),
Comment = require('./../models/Comment'),
resources = require('./resources.json'),
steps = resources.steps,
secrets = require('./../config/secrets'),
bonfires = require('../seed_data/bonfires.json'),
coursewares = require('../seed_data/coursewares.json'),
wikis = require('../seed_data/wikis.json'),
moment = require('moment'),
https = require('https'),
debug = require('debug')('freecc:cntr:resources'),
@ -251,23 +253,12 @@ module.exports = {
});
},
allBonfireNames: function() {
return bonfires.map(function(elem) {
allWikiNames: function() {
return wikis.map(function(elem) {
return {
name: elem.name,
difficulty: elem.difficulty,
_id: elem._id
name: elem.name
}
})
.sort(function(a, b) {
return a.difficulty - b.difficulty;
})
.map (function(elem) {
return {
name : elem.name,
_id: elem._id
}
});
},
getAllCourses: function() {

View File

@ -35,6 +35,7 @@ exports.returnIndividualWiki = function(req, res, next) {
};
exports.showAllWikis = function(req, res) {
var data = {};
data.wikiList = resources.allWikiNames();
res.send(data);
};

View File

@ -3,7 +3,8 @@
"_id": "bd7158d9c442eddfaeb5bdef",
"name": "Global Control Shortcuts for Mac",
"description": [
"<h2>These Global Control Shortcuts for Mac will save you hours by speeding up your typing</h2>",
"<div class=\"col-xs-12 col-sm-10 col-sm-offset-1\">",
"<h2 class='text-center'>These Global Control Shortcuts for Mac will save you hours by speeding up your typing</h2>",
"<div class=\"embed-responsive embed-responsive-16by9\"><iframe src=\"//player.vimeo.com/video/107073108\" class=\"embed-responsive-item\"></iframe></div>",
"<div class=\"text-left\">",
" <h3>These global shortcuts work everywhere on a Mac:",
@ -18,8 +19,7 @@
" <li>Control + E = End of Line</li>",
" <li>Control + K = Kill line</li>",
" </ul>",
" </h3>",
"</div><a href=\"/login\" class=\"btn btn-cta signup-btn btn-primary\">Start learning to code (it's free)<br/></a>"
"</div>"
]
},
{

24
views/partials/wikis.jade Normal file
View File

@ -0,0 +1,24 @@
h3
ol#bonfireList
script(src='/js/lib/ramda/ramda.min.js')
script.
var getLinkedName = function getLinkedName(name) {
// ensure name is a string
name = name + '';
return name.toLowerCase().replace(/\s/g, '-');
}
$.ajax({
url: '/wiki/getWikiList',
type: 'GET'
})
.success(
function(data) {
var docfrag = document.createDocumentFragment();
for (var i = 0; i < data.wikiList.length; i++) {
var li = document.createElement("li");
var linkedName = getLinkedName(data.wikiList[i].name);
$(li).html("<a href='/wiki/" + linkedName + "'>" + data.wikiList[i].name + "</a></li>");
docfrag.appendChild(li);
};
$('#bonfireList').append(docfrag);
});

View File

@ -8,9 +8,19 @@ block content
h1= title
.panel-body
div!= description
.spacer
.text-center
#showAllButton.btn.btn-info.btn-big Show all Wiki Articles
.spacer
.row
.col-xs-12.text-center
if !user
h3 Got 3 minutes? Learn to code with us!
a.btn.btn-cta.signup-btn.btn-primary(href="/login") Start learning to code (it's free)
.spacer
#all-challenges-dialog.modal(tabindex='-1')
.modal-dialog.animated.fadeInUp.fast-animation
.modal-content
.modal-header.all-list-header Wiki Articles
a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') ×
.modal-body
include ../partials/wikis