Made a lot of changes:

Better SEO
Added eastereggs
Styled eastereggs
Imported easteregg database
Made some script.js improvements
Added opensearch
This commit is contained in:
Bram van der Veen 2015-06-23 11:36:31 +02:00
parent fa6af3756b
commit 205411350e
9 changed files with 164 additions and 37 deletions

68
eastereggs.json Normal file
View file

@ -0,0 +1,68 @@
[
{
"easter" : "eekhoorn",
"name" : "Femke Heeling",
"type" : "student"
},
{
"easter" : "chocoladebeer",
"name" : "Jerom Maat",
"text" : "Beer, malleman, \"420 blaze it\", geliefde en Albert Heijn medewerker",
"type" : "RIP"
},
{
"easter" : "nietzsche",
"name" : "hTig",
"real_name" : "Harm Tiggelaar",
"text" : "Docent, groot filosoof en voorbeeld in haarstijl",
"type" : "RIP"
},
{
"easter" : "kaas",
"name" : "Steven Smits",
"text" : "Mellow als kaas, gitarist en levensfilosoof",
"type" : "RIP"
},
{
"easter" : "stoeptegel",
"name" : "Femke Hoornstra",
"text" : "Klein, schattig en schrijfster",
"type" : "RIP"
},
{
"easter" : "die jongen met het coole haar",
"name" : "Jules Stenneker",
"type" : "student"
},
{
"easter" : "god",
"name" : "David Francois",
"type" : "student"
},
{
"easter" : "wobbes",
"name" : "Natascha Wobbes",
"type" : "RIP"
},
{
"easter" : "huis tuin en keuken neger",
"name" : "Fimme Neeleman",
"text" : "Goeie huisman, vriend, gamer, geliefde en malleman",
"type" : "RIP"
},
{
"easter" : "hahanna",
"name" : "Hanna van Rheenen",
"type" : "student"
},
{
"easter" : "lala",
"name" : 21297,
"type" : "easter"
},
{
"easter" : "aardappel",
"name" : "Sjors Mulder",
"type" : "student"
}
]

View file

@ -1,6 +1,7 @@
//lookup.js //lookup.js
var http = require('http'); var http = require('http');
var config = require('./configuration'); var config = require('./configuration');
var fs = require('fs');
var database = require('mongoskin').db('mongodb://' + config().database); var database = require('mongoskin').db('mongodb://' + config().database);
var school_id = config().school_id; var school_id = config().school_id;
@ -8,7 +9,11 @@ var school_id = config().school_id;
//Function for looking through the database and finding entries related to the searchterm. //Function for looking through the database and finding entries related to the searchterm.
function lookup(req, res, next, search) { function lookup(req, res, next, search) {
var index = database.collection('index'); var index = database.collection('index');
easter(search) ? req.easter = easter(search) : null;
easter(search) ? search = easter(search).name : null; //Check if there are any eastereggs matching the search query.
search = new RegExp(search, 'i'); //Make regular exeption for ignoring the case (Bram vs BRAM) should return the same. search = new RegExp(search, 'i'); //Make regular exeption for ignoring the case (Bram vs BRAM) should return the same.
index.find({$or : [{id : search}, {name : search}, {first_name : search}, {last_name : search}]}).toArray(function (err, database_entry) { index.find({$or : [{id : search}, {name : search}, {first_name : search}, {last_name : search}]}).toArray(function (err, database_entry) {
if (err) console.warn(err); if (err) console.warn(err);
@ -22,6 +27,7 @@ function lookup(req, res, next, search) {
} }
else { else {
res.send('Multiple hits were found in the database.'); res.send('Multiple hits were found in the database.');
console.log(database_entry);
} }
}); });
} }
@ -53,4 +59,21 @@ function make_url(req, database_entry) {
return url; return url;
} }
//Function for checking the given search query for eatereggs.
//TODO: add a way to supply a template file for eastereggs.
function easter(search) {
var list = JSON.parse(fs.readFileSync(__dirname + '/eastereggs.json'));
for (entry of list) {
if (entry.easter == search.toLowerCase()) return entry;
}
return null;
}
module.exports = lookup; module.exports = lookup;
//Testing function, if test is passed in the command line will execute a test.
if (process.argv[2] == "test") {
console.log(easter('aardappel'));
}

View file

@ -1,9 +1,14 @@
html html
head head(profile="http://a9.com/-/spec/opensearch/1.1/")
title Werkmanrooster title Werkmanrooster
meta(name='viewport', content='width=device-width, user-scalable=no')
meta(name="Description", content="De beste roostersite voor de leerlingen van Werkman Stadslyceum!")
link(rel="search" type="application/opensearchdescription+xml" href="/resources/opensearch.xml" title="Rooster zoeken")
link(rel="stylesheet", href="/css/skeleton.css", type="text/css") link(rel="stylesheet", href="/css/skeleton.css", type="text/css")
link(rel="stylesheet", href="/css/style.css", type="text/css") link(rel="stylesheet", href="/css/style.css", type="text/css")
meta(name='viewport', content='width=device-width, user-scalable=no')
script(type="text/javascript", src="http://code.jquery.com/jquery-1.11.3.min.js") script(type="text/javascript", src="http://code.jquery.com/jquery-1.11.3.min.js")
script(type="text/javascript", src="/js/script.js") script(type="text/javascript", src="/js/script.js")
script(type="text/javascript"). script(type="text/javascript").

View file

@ -3,33 +3,39 @@
include header include header
include search include search
- var days = ['Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag', 'Zondag']; if !easter || easter.type != "RIP"
div#wrapper - var days = ['Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag', 'Zondag'];
div.schedule #wrapper
ul .schedule
each type in match.json.types ul
li each type in match.json.types
span=type.letter li
a(href='?tab=' + type.tab)=type.value span=type.letter
each day in match.json a(href='?tab=' + type.tab)=type.value
div.day each day in match.json
div.hour.title .day
span= days[match.json.indexOf(day)] .hour.title
each hour in day span= days[match.json.indexOf(day)]
if hour.teacher != 'vrij' each hour in day
div.hour(class=hour.changed == 'true' ? 'changed' : '') if hour.teacher != 'vrij'
each subhour in hour.teacher .hour(class=hour.changed == 'true' ? 'changed' : '')
span.teacher(class='sub_' + hour.teacher.length) each subhour in hour.teacher
a(href=hour.teacher[hour.teacher.indexOf(subhour)])= hour.teacher[hour.teacher.indexOf(subhour)] span.teacher(class='sub_' + hour.teacher.length)
span.chamber(class='sub_' + hour.teacher.length) a(href=hour.teacher[hour.teacher.indexOf(subhour)])= hour.teacher[hour.teacher.indexOf(subhour)]
a(href=hour.chamber[hour.teacher.indexOf(subhour)])= hour.chamber[hour.teacher.indexOf(subhour)] span.chamber(class='sub_' + hour.teacher.length)
span.course(class='sub_' + hour.teacher.length)= hour.course[hour.teacher.indexOf(subhour)] a(href=hour.chamber[hour.teacher.indexOf(subhour)])= hour.chamber[hour.teacher.indexOf(subhour)]
span.course(class='sub_' + hour.teacher.length)= hour.course[hour.teacher.indexOf(subhour)]
if match.json.indexOf(day) == 0 if match.json.indexOf(day) == 0
span.time= times[match.json[0].indexOf(hour)] span.time= times[match.json[0].indexOf(hour)]
else
div.hour.changed
span.free Vrij
else
.hour.changed
span.free Vrij
else
.schedule.rip
h1 R.I.P
p="Hier ligt " + (easter.real_name || easter.name)
p=easter.text
p Voor altijd in ons hart
include links include links

View file

@ -13,7 +13,7 @@ $(document).ready(function () {
function go() { function go() {
var searchterm = $('.search').val().trim(); var searchterm = $('.search').val().trim().replace(/\'s Rooster/gi, '');
if (!!searchterm) { if (!!searchterm) {
document.location.pathname = '/rooster/' + searchterm; document.location.pathname = '/rooster/' + searchterm;
} }

View file

@ -1,13 +1,12 @@
//mobile.less //mobile.less
/* Larger than mobile */
/* Larger than phablet */
@media (max-width: 550px) {}
/* Larger than tablet */
@media (max-width: 755px) { @media (max-width: 755px) {
#title { #title {
font-size: 40px !important; font-size: 40px !important;
span {
display: none !important;
}
} }
input, button { input, button {

View file

@ -58,6 +58,11 @@ div.schedule {
border: solid 1px #e1e1e1; border: solid 1px #e1e1e1;
font-family: Open Sans; font-family: Open Sans;
&.rip {
text-align: center;
border: none;
}
ul { ul {
margin: 0; margin: 0;
padding: 0; padding: 0;

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>rooster</ShortName>
<LongName>rooster zoeken</LongName>
<Description>De beste roostersite voor leerlingen van Werkman Stadslyceum</Description>
<InputEncoding>UTF-8</InputEncoding>
<OutputEncoding>UTF-8</OutputEncoding>
<AdultContent>false</AdultContent>
<Language>nl-NL</Language>
<Developer>Bram van der Veen</Developer>
<Contact>werkmanrooster@gmail.com</Contact>
<Description>De beste roostersite voor leerlingen van Werkman Stadslyceum</Description>
<Tags>werkman rooster werkmanrooster leerlingen groningen stadslyceum bram van der veen</Tags>
<Attribution>Werkmanrooster zoeken op, http://werkmanrooster.nl/</Attribution>
<SyndicationRight>open</SyndicationRight>
<!-- <Query role="example" searchTerms="Apple"/>
<Image height="16" width="16" type="image/vnd.microsoft.icon">http://werkmanrooster.nl/resources/fav.ico</Image>
<Image height="64" width="64" type="image/png">http://werkmanrooster.nl/resources/fav.png</Image>
<Url type="text/html" template="http://werkmanrooster.nl/rooster/{searchTerms}"/> -->
</OpenSearchDescription>

1
web.js
View file

@ -12,6 +12,7 @@ app.disable('view cache');
app.set('views', __dirname + '/resources/jade'); app.set('views', __dirname + '/resources/jade');
app.use('/css', less(__dirname + '/resources/less')); app.use('/css', less(__dirname + '/resources/less'));
app.use('/js', express.static(__dirname + '/resources/js')); app.use('/js', express.static(__dirname + '/resources/js'));
app.use('/other', express.static(__dirname + '/resources/other'));
app.get('/', function (req, res) { app.get('/', function (req, res) {
req.links = config().links; req.links = config().links;