Skip to content

Commit

Permalink
initial commit. first prototype. various known bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
csizmazia committed Oct 22, 2012
1 parent 2e6d6f5 commit 8c1aaef
Show file tree
Hide file tree
Showing 14 changed files with 36,408 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ logs
results

node_modules
npm-debug.log
npm-debug.log
dev
12 changes: 12 additions & 0 deletions server/README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### install node.js:
dowload package/installer from http://nodejs.org/download
install package or run installer

### install socket.io:
> npm install socket.io

### install slidehub
> cd slidehub/server
> npm install
> npm ls

123 changes: 123 additions & 0 deletions server/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
var express = require("express");
var util = require("util");
var mysql = require("mysql");
var mu = require('mu2');
var io = require('socket.io');
var app = express();
var server = require("http").createServer(app);
var io = io.listen(server);

// config
app.set("title","SlideHub");
app.set("env","dev"); // dev|prod

if (app.get("env") == "dev") {
app.set("db host", "localhost");
app.set("db user", "slidehub");
app.set("db pass", "slidehub");
app.set("db db", "slidehub");
}
if (app.get("env") == "prod") {

}

var db = mysql.createConnection({
host : app.get("db host"),
user : app.get("db user"),
password : app.get("db pass"),
database : app.get("db db")
});

app.configure(function() {
//app.all("*", requireAuthentication);
//app.all("*", loadUser);
app.use(express.static(__dirname + "/public/img"));
app.use(express.static(__dirname + "/public/css"));
app.use(express.static(__dirname + "/public/js"));
app.use(express.static(__dirname + "/public/presentations"));
app.use(express.favicon(__dirname + "/public/img/favicon.ico"));
app.use(express.logger());
});

mu.root = __dirname + '/templates';



// functions
function dbClose() {
db.end();
}

function requireAuthentication() {

}

function loadUser() {

}

// logic
app.get("/", function(req, res){
db.query("SELECT * FROM presentation",[], function(error, results) {
if (error) {
console.log(error);
throw error;
}

console.log(results);

var view = {
title: app.get("title"),
presentations: results
};

if (app.get("env") == "dev") {
mu.clearCache();
}
var stream = mu.compileAndRender('presentations.html', view);
util.pump(stream, res);
});
});

app.get("/testpres", function(req, res){
res.send("testpresentation1");
});

app.get("/presentation/*", function(req, res){
var presentationId = req.url.split("/").pop();

db.query("SELECT * FROM presentation WHERE filename = ?",[presentationId], function(error, results) {
if (error) {
console.log(error);
throw error;
}

console.log(results);

var view = {
title: app.get("title"),
is_available: results.length == 1,
presentation: results[0]
};

if (app.get("env") == "dev") {
mu.clearCache();
}
var stream = mu.compileAndRender('presentation.html', view);
util.pump(stream, res);
});
});

io.sockets.on('connection', function (socket) {
socket.on('note', function (data) {
console.log(data);
// TODO: store note
socket.broadcast.emit("note", data);
});
});

//app.listen(8000);
//console.log("Listening on port 8000");

server.listen(8000);
console.log("Socket Listening on port 8000");
12 changes: 12 additions & 0 deletions server/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "slidehub",
"description": "slidehub server",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "3.0.0rc5",
"mysql": "2.0.0-alpha3",
"mu2": "0.5.17",
"socket.io": ""
}
}
3 changes: 3 additions & 0 deletions server/public/css/mobile.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body {

}
40 changes: 40 additions & 0 deletions server/public/css/screen.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
body {

}

#page {

}

#header {
top: 0;
left: 0;
width: 100%;
height: 50px;
}
#header #logo {
float: left;
}
#header #topnav {
float: right;
}

#pdf-canvas {
display: block;
width: 45%;
float: left;
}

#content {
display: block;
width: 45%;
background: lightgrey;
float: left;
}

.note {
width: 300px;
padding: 10px;
background: lightgreen;
margin-bottom: 10px;
}
Binary file added server/public/img/favicon.ico
Binary file not shown.
Loading

0 comments on commit 8c1aaef

Please sign in to comment.