-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit. first prototype. various known bugs.
- Loading branch information
Showing
14 changed files
with
36,408 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ logs | |
results | ||
|
||
node_modules | ||
npm-debug.log | ||
npm-debug.log | ||
dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
body { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Oops, something went wrong.