Heb het hele PWS opnieuw geprogrameerd.
This commit is contained in:
parent
9ce6d8d023
commit
fac5703ee9
10
app.js
10
app.js
|
@ -1,7 +1,7 @@
|
|||
//web.js
|
||||
var express = require('express');
|
||||
var less = require('express-less');
|
||||
var markdown = require('express-markdown');
|
||||
var hoewerkt = require('./hoewerkt');
|
||||
var fs = require('fs');
|
||||
var app = express();
|
||||
|
||||
|
@ -9,7 +9,6 @@ var app = express();
|
|||
app.set('view engine', 'jade');
|
||||
app.disable('view cache');
|
||||
app.set('views', __dirname + '/resources/jade');
|
||||
app.locals.articles = fs.readdirSync(__dirname + '/markdown');
|
||||
|
||||
//Set up all static directories for getting resources.
|
||||
app.use('/css', less(__dirname + '/resources/less', {debug : true}));
|
||||
|
@ -17,11 +16,10 @@ app.use('/css', less(__dirname + '/resources/less', {debug : true}));
|
|||
app.use('/images', express.static(__dirname + '/resources/images'));
|
||||
app.use('/other', express.static(__dirname + '/resources/other'));
|
||||
//Setup markdown middleware.
|
||||
app.use(markdown({directory: __dirname + '/markdown', view: 'article'}));
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.redirect('/home.md');
|
||||
});
|
||||
app.get('/', hoewerkt);
|
||||
app.get('/:article', hoewerkt);
|
||||
|
||||
|
||||
function start(port) {
|
||||
app.listen(port);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
##Hoe werkt Werkmanrooster?
|
||||
#### Hoe werkt Werkmanrooster?
|
||||
---
|
||||
Welkom op de index van mijn profielwerkstuk. Vanuit hier kun je alle verschillende hoofdstukken en deelvragen bekijken en nalezen. Ik zou echt wel voorstellen om de artikelen te lezen op chronologische volgorde, want op die manier zou het het makkelijkste te lezen zijn.
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//compile.js
|
||||
var fs = require('fs');
|
||||
var marked = require('marked');
|
||||
var buffer = '<a href="http://hoewerkt.werkmanrooster.nl">Een betere leeservaring is op http://hoewerkt.werkmanrooster.nl, het is ook bedoelt om het hier te lezen.</a>';
|
||||
var buffer = '<a href="http://hoewerkt.werkmanrooster.nl">Een betere leeservaring is op http://hoewerkt.werkmanrooster.nl, het is ook bedoelt om het hier te lezen. Ook staat dit papier NIET op de bedoelde volgorde.</a>';
|
||||
|
||||
var articles = fs.readdirSync(__dirname + '/markdown');
|
||||
|
||||
|
|
39
hoewerkt.js
Normal file
39
hoewerkt.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
//hoewerkt.js
|
||||
var fs = require('fs');
|
||||
var marked = require('marked');
|
||||
var articles = [
|
||||
'Inleiding',
|
||||
'Moeilijkheidsgraad',
|
||||
'Inhetkort:In het kort'
|
||||
]
|
||||
|
||||
module.exports = function (req, res, next) {
|
||||
console.log('Got a hit');
|
||||
if (req.url == '/') {
|
||||
res.render('article', render('index'));
|
||||
}
|
||||
else {
|
||||
var sub = req.url.split('/')[1];
|
||||
var othersub = req.url.split('/')[2] || 'makkelijk';
|
||||
|
||||
for (article of articles) {
|
||||
if (sub == article.split(':')[0]) {
|
||||
res.render('article', render(sub, othersub))
|
||||
return;
|
||||
}
|
||||
}
|
||||
res.render('404');
|
||||
}
|
||||
}
|
||||
|
||||
function render(file, difficulty) {
|
||||
if (file == 'index') var content = fs.readFileSync(__dirname + '/articles/index.md').toString();
|
||||
else {
|
||||
console.log('files', file);
|
||||
var files = fs.readdirSync(__dirname + '/articles/' + file.toLowerCase()).join('\n');
|
||||
var selected = files.match(new RegExp(difficulty + '.*'))[0];
|
||||
var content = fs.readFileSync(__dirname + '/articles/' + file + '/' + selected).toString();
|
||||
}
|
||||
|
||||
return {'markdown': marked(content), 'articles': articles}
|
||||
}
|
|
@ -12,6 +12,7 @@
|
|||
"express": "^4.13.0",
|
||||
"express-less": "0.0.7",
|
||||
"express-markdown": "0.0.6",
|
||||
"jade": "^1.11.0"
|
||||
"jade": "^1.11.0",
|
||||
"marked": "^0.3.5"
|
||||
}
|
||||
}
|
||||
|
|
1
resources/jade/404.jade
Normal file
1
resources/jade/404.jade
Normal file
|
@ -0,0 +1 @@
|
|||
h1 Het artikel waar je naar zoekt is niet gevonden.
|
|
@ -12,13 +12,14 @@ html
|
|||
div
|
||||
h5 Profielwerkstuk
|
||||
p Hoe werkt Werkmanrooster?
|
||||
a(href="http://96aa48.github.io")
|
||||
img(src="/images/face.png")
|
||||
sup Door :
|
||||
//- a(href="http://96aa48.github.io")
|
||||
//- img(src="/images/face.png")
|
||||
sup Bram van der Veen
|
||||
ul
|
||||
for article in locals.articles
|
||||
for article in articles
|
||||
li
|
||||
a(href="/" + article)=article.substr(0,1).toUpperCase() + article.replace(/.md/, '').slice(1)
|
||||
a(href="/" + article.match(':') ? article.split(':')[0] : article)=article.match(':') ? article.split(':')[1] : article
|
||||
.content.seven
|
||||
div!=markdown
|
||||
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
html
|
||||
head
|
||||
title Hoe werkt Werkmanrooster ?
|
||||
link(rel="stylesheet", href="/css/style.css", type="text/css")
|
||||
link(rel="stylesheet", href="/css/skeleton.css", type="text/css")
|
||||
|
||||
body
|
||||
.container=markdown
|
Loading…
Reference in a new issue