Added a MOTD system with a simple .json file

This commit is contained in:
Bram van der Veen 2016-06-18 16:39:46 +02:00
parent 4fc5f4505a
commit 52cedd0ab4
4 changed files with 33 additions and 34 deletions

5
motd.json Normal file
View file

@ -0,0 +1,5 @@
{
"header": "Op zoek naar nieuwe beheerder!",
"body": "Hallo iedereen, ik ben dit jaar geslaagd!<br>Dit betekent echter wel dat het tijd is voor mij om Werkmanrooster door te geven aan de volgende beheerder die nog op Werkman zit. <br><br>Wil jij Werkmanrooster overnemen, stuur dan een mailtje naar werkmanrooster@gmail.com",
"enabled": false
}

View file

@ -1,16 +1,28 @@
//style.less //style.less
@import url('https://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,700,400|Oswald'); @import url('https://fonts.googleapis.com/css?family=Open+Sans:400italic,700italic,700,400|Oswald');
.notice { .motd {
background-color: #BB4848; background-color: #BB4848;
border: solid 1px #A22F2F; border: solid 1px #A22F2F;
box-shadow: 0px 0px 5px #A53838; box-shadow: 0px 0px 10px #CECECE;
width: 600px; width: 600px;
padding: 15px; padding: 15px;
text-align: center; border-radius: 2px;
margin: 30px auto;
border-radius: 3px;
color: #FFF; color: #FFF;
font-size: 13px;
width: 300px;
padding: 0;
margin: 0 auto;
p {
padding: 10px 10px;
margin: 0px;
}
> .bold {
text-align: center;
font-weight: bold;
}
} }
.night { .night {
@ -64,25 +76,6 @@ div.duringschool {
text-align: center; text-align: center;
} }
.motd {
border: solid 1px red;
display: block;
font-size: 13px;
width: 300px;
border: solid 1px #000;
border-radius: 5px;
padding: 0;
position: absolute;
top: 15px;
left: 15px;
p {
padding: 10px 10px;
margin: 0px;
}
}
.notfound { .notfound {
margin: 20px auto; margin: 20px auto;
} }

View file

@ -23,14 +23,16 @@
else else
ul ul
li
a(href="/login") Login
li |
li li
a(href="http://hoewerkt.werkmanrooster.nl", target="_blank") Hoe werkt Werkmanrooster? a(href="http://hoewerkt.werkmanrooster.nl", target="_blank") Hoe werkt Werkmanrooster?
ul.right ul.right
li li
a(href="http://hexli.me", target="_blank") The Dev a(href="http://hexli.me", target="_blank") Dev
li | li |
li li
a(href="http://github.com/96aa48/rooster.io", target="_blank") Github a(href="http://github.com/96aa48/rooster.io", target="_blank") Github
if app.locals.motd.enabled
.motd
p.bold #{app.locals.motd.header}
p!= app.locals.motd.body

11
web.js
View file

@ -35,6 +35,7 @@ app.set('views', __dirname + '/resources/pug');
app.locals.linkbar = config().linkbar; app.locals.linkbar = config().linkbar;
app.locals.times = config().times; app.locals.times = config().times;
app.locals.time = time; app.locals.time = time;
app.locals.motd = require('./motd.json');
//Set up all static directories for getting resources. //Set up all static directories for getting resources.
app.use('/css', less(__dirname + '/resources/less')); app.use('/css', less(__dirname + '/resources/less'));
@ -43,9 +44,7 @@ app.use('/other', express.static(__dirname + '/resources/other'));
app.use('/images', express.static(__dirname + '/resources/images')); app.use('/images', express.static(__dirname + '/resources/images'));
//Initialising homepage. //Initialising homepage.
app.get('/', auth.is, function (req, res) { app.get('/', (req, res) => res.render('homepage', req));
res.render('homepage', req);
});
//Initialize redirector when information is posted to the root of the website. //Initialize redirector when information is posted to the root of the website.
app.post('/', redirecter); app.post('/', redirecter);
@ -53,12 +52,12 @@ app.post('/', redirecter);
//Initialising behavior for searching. //Initialising behavior for searching.
app.param('search', lookup.get); app.param('search', lookup.get);
app.get('/rooster/:search', [auth.is, schedule.get, (req, res) => res.render('schedule', req)]); app.get('/rooster/:search', [schedule.get, (req, res) => res.render('schedule', req)]);
//Initialising behavior for searching through lists. //Initialising behavior for searching through lists.
app.param('list', lookup.list); app.param('list', lookup.list);
app.get('/klassenlijst/:list',[auth.is, (req, res) => res.render('list', req)]); app.get('/klassenlijst/:list', (req, res) => res.render('list', req));
//Initialising login page frontend. //Initialising login page frontend.
app.get('/login', (req, res) => res.render('login', req)); app.get('/login', (req, res) => res.render('login', req));
@ -68,7 +67,7 @@ app.post('/login', auth.login);
app.get('/logout', auth.logout); app.get('/logout', auth.logout);
//Intialising API handler. //Intialising API handler.
app.get('/api/:api', function (req, res, next) { next(); }); app.get('/api/:api', (req, res, next) => next());
app.param('api', api); app.param('api', api);
//Initialize the server on configured web port. //Initialize the server on configured web port.