Implemented configuration everywhere possible and added times to schedule.jade
This commit is contained in:
parent
3eaf81b40f
commit
64857e8d48
|
@ -1,7 +1,9 @@
|
|||
//lookup.js
|
||||
var http = require('http');
|
||||
var database = require('mongoskin').db('mongodb://wallpiece/roosterio');
|
||||
var schoolid = 934;
|
||||
var config = require('./configuration');
|
||||
|
||||
var database = require('mongoskin').db('mongodb://' + config().database);
|
||||
var school_id = config().school_id;
|
||||
|
||||
//Function for looking through the database and finding entries related to the searchterm.
|
||||
function lookup(req, res, next, search) {
|
||||
|
@ -25,7 +27,7 @@ function lookup(req, res, next, search) {
|
|||
|
||||
//Function for making a link out of the given database_entry.
|
||||
function make_url(database_entry) {
|
||||
var url = 'http://roosters5.gepro-osi.nl/roosters/rooster.php?school=' + schoolid + '&type=' + database_entry.type.charAt(0).toUpperCase() + database_entry.type.slice(1) + 'rooster';
|
||||
var url = 'http://roosters5.gepro-osi.nl/roosters/rooster.php?school=' + school_id + '&type=' + database_entry.type.charAt(0).toUpperCase() + database_entry.type.slice(1) + 'rooster';
|
||||
|
||||
switch (database_entry.type) {
|
||||
case 'leerling' :
|
||||
|
|
|
@ -16,6 +16,10 @@ div.schedule
|
|||
span.teacher= hour.teacher
|
||||
span.chamber= hour.chamber
|
||||
span.course= hour.course
|
||||
|
||||
if match.json.indexOf(day) == 0
|
||||
span.time= match.times[match.json[0].indexOf(hour)]
|
||||
|
||||
else
|
||||
div.hour.changed
|
||||
span.free Vrij
|
||||
|
|
|
@ -62,12 +62,13 @@ div.schedule {
|
|||
float: left;
|
||||
|
||||
div.hour {
|
||||
width: 150px;
|
||||
height: 20px;
|
||||
border-bottom: solid 1px #DDD;
|
||||
padding: 12px 15px;
|
||||
border-bottom: 1px solid #e1e1e1;
|
||||
width: 150px;
|
||||
border-left: 1px solid #FFF;
|
||||
position: relative;
|
||||
|
||||
span {
|
||||
display: inline-block;
|
||||
|
@ -101,6 +102,15 @@ div.schedule {
|
|||
}
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 10px;
|
||||
color: #665;
|
||||
width: 100%;
|
||||
position: absolute;
|
||||
top: 2px;
|
||||
left: 5px;
|
||||
}
|
||||
|
||||
.free {
|
||||
.changed;
|
||||
text-align: center;
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
//schedule.js
|
||||
var http = require('http');
|
||||
var cheerio = require('cheerio');
|
||||
var config = require('./configuration');
|
||||
|
||||
//Wrapper function that is being called by express.
|
||||
function schedule(req, res, next) {
|
||||
get(req.match.url, function (json) {
|
||||
req.match.json = json;
|
||||
req.match.times = config().hour_times;
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
@ -29,7 +31,7 @@ function get(url, callback) {
|
|||
function to_json(page) {
|
||||
var result = cheerio('td:nth-child(3) table', page);
|
||||
var amount_of_days = cheerio(result).find('tr.AccentDark').find('td').length - 1;
|
||||
var amount_of_hours = 7;
|
||||
var amount_of_hours = config().amount_of_hours;
|
||||
|
||||
var schedule_data = [];
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ var http = require('http');
|
|||
var cheerio = require('cheerio');
|
||||
var iconv = require('iconv-lite');
|
||||
var mongodb = require('mongodb').MongoClient;
|
||||
var config = require('./configuration');
|
||||
|
||||
var scheduletypes = [
|
||||
'Klasrooster',
|
||||
|
@ -110,9 +111,9 @@ function rip(data) {
|
|||
}
|
||||
|
||||
//Function being called to access functionality from this module.
|
||||
function crawl(sid) {
|
||||
school_id = sid;
|
||||
mongodb.connect('mongodb://wallpiece/roosterio', function (error, db) {
|
||||
function crawl() {
|
||||
school_id = config().school_id;
|
||||
mongodb.connect('mongodb://' + config().database, function (error, db) {
|
||||
if (error) console.warn(error);
|
||||
database = db;
|
||||
|
||||
|
|
7
web.js
7
web.js
|
@ -1,10 +1,11 @@
|
|||
//web.js
|
||||
var config = require('./configuration');
|
||||
var express = require('express');
|
||||
var less = require('express-less');
|
||||
var app = express();
|
||||
|
||||
var lookup = require('./lookup.js');
|
||||
var schedule = require('./schedule.js');
|
||||
var lookup = require('./lookup');
|
||||
var schedule = require('./schedule');
|
||||
|
||||
app.set('view engine', 'jade');
|
||||
app.disable('view cache');
|
||||
|
@ -37,4 +38,4 @@ app.param('search', function (req, res) {
|
|||
console.log(req);
|
||||
});
|
||||
|
||||
app.listen(1024);
|
||||
app.listen(config().web_port);
|
||||
|
|
Loading…
Reference in a new issue