diff --git a/build/components.html b/build/components.html
index 634812d..86f96c4 100644
--- a/build/components.html
+++ b/build/components.html
@@ -1,4 +1,4 @@
-
-
+
-
-
+
diff --git a/client/index.js b/client/index.js
new file mode 100644
index 0000000..8d9e001
--- /dev/null
+++ b/client/index.js
@@ -0,0 +1,20 @@
+$(document).ready(function(){
+
+ @@include('components.js')
+
+ $.getJSON('/data/'+location.pathname.split('/').slice(3).join('/'), function(res){
+
+ var ractive = new Ractive.components[location.pathname.split('/')[2]]({
+ el:'#load',
+ data:res
+ });
+
+ });
+
+
+ //Code below here
+
+
+
+
+ });
diff --git a/client/parent.html b/client/parent.html
deleted file mode 100644
index d484511..0000000
--- a/client/parent.html
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
- RCard
-
-
-
-
-
-
-
-
-
-
-
-
-
- @@include('components.html')
-
-
-
-
-
diff --git a/client/parent.js b/client/parent.js
deleted file mode 100644
index 5261092..0000000
--- a/client/parent.js
+++ /dev/null
@@ -1,20 +0,0 @@
-$(document).ready(function(){
-
- @@include('components.js')
-
- $.getJSON('/sample', function(res){
-
- var ractive = new Ractive.components.home({
- el:'#load',
- data:res
- });
-
- });
-
-
- //Code below here
-
-
-
-
- });
diff --git a/client/teacher.css b/client/teacher.css
deleted file mode 100644
index e69de29..0000000
diff --git a/server/app.js b/server/app.js
index a14e571..5216af9 100644
--- a/server/app.js
+++ b/server/app.js
@@ -3,8 +3,12 @@ var express = require('express');
var app = express();
app.use(express.static('../build'))
-app.get('/', function(req, res){
- res.send(fs.readFileSync('../build/index.html'));
+var mongojs = require('mongojs');
+
+var db = mongojs('test', ['class', 'student']);
+
+app.get('/view/:viewType/:dataType/:id', function(req, res){
+ res.send(fs.readFileSync('../build/index.html', 'utf8'));
});
app.get('/sample', function(req, res){
@@ -14,5 +18,24 @@ app.get('/sample', function(req, res){
});
});
+app.get('/data/:type/:id', function(req, res){
+ if(req.params.type === 'class') {
+ db.class.findOne({_id: mongojs.ObjectId(req.params.id)}, function(err, classDoc){
+ if(err)
+ throw new Error('Error finding class');
+ db.student.find({class:req.params.id}, function(err, students){
+ res.send({
+ class:classDoc,
+ students:students
+ });
+ });
+ });
+ } else if(req.params.type === 'student') {
+ db.student.find({_id:mongojs.ObjectId(req.params.id)}, function(err, student){
+ res.send(student);
+ });
+ }
+});
+
app.listen(1337);