From 106a10edcaca310c2730881d542dc8625807257c Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Mon, 30 Mar 2015 15:55:00 -0700 Subject: [PATCH] add a modal that allows one to scroll through all wiki pages --- app.js | 4 +++- controllers/resources.js | 19 +++++-------------- controllers/wiki.js | 1 + seed_data/wikis.json | 6 +++--- views/partials/wikis.jade | 24 ++++++++++++++++++++++++ views/wiki/show.jade | 12 +++++++++++- 6 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 views/partials/wikis.jade diff --git a/app.js b/app.js index 2831eb851c..1cd47c6a8e 100644 --- a/app.js +++ b/app.js @@ -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', diff --git a/controllers/resources.js b/controllers/resources.js index 8fa984e6ff..b173c4c54d 100644 --- a/controllers/resources.js +++ b/controllers/resources.js @@ -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() { diff --git a/controllers/wiki.js b/controllers/wiki.js index 6172e0f225..f7bf1a22c4 100644 --- a/controllers/wiki.js +++ b/controllers/wiki.js @@ -35,6 +35,7 @@ exports.returnIndividualWiki = function(req, res, next) { }; exports.showAllWikis = function(req, res) { + var data = {}; data.wikiList = resources.allWikiNames(); res.send(data); }; diff --git a/seed_data/wikis.json b/seed_data/wikis.json index f356bfdfff..853b3391bd 100644 --- a/seed_data/wikis.json +++ b/seed_data/wikis.json @@ -3,7 +3,8 @@ "_id": "bd7158d9c442eddfaeb5bdef", "name": "Global Control Shortcuts for Mac", "description": [ - "

These Global Control Shortcuts for Mac will save you hours by speeding up your typing

", + "
", + "

These Global Control Shortcuts for Mac will save you hours by speeding up your typing

", "
", "
", "

These global shortcuts work everywhere on a Mac:", @@ -18,8 +19,7 @@ "
  • Control + E = End of Line
  • ", "
  • Control + K = Kill line
  • ", " ", - "

    ", - "
    Start learning to code (it's free)
    " + "
    " ] }, { diff --git a/views/partials/wikis.jade b/views/partials/wikis.jade new file mode 100644 index 0000000000..be4fd2b3cd --- /dev/null +++ b/views/partials/wikis.jade @@ -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("" + data.wikiList[i].name + ""); + docfrag.appendChild(li); + }; + $('#bonfireList').append(docfrag); + }); diff --git a/views/wiki/show.jade b/views/wiki/show.jade index 9143e6a592..c8bc601c78 100644 --- a/views/wiki/show.jade +++ b/views/wiki/show.jade @@ -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