aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph Benden2014-12-15 16:49:38 (GMT)
committerJoseph Benden2014-12-15 16:49:38 (GMT)
commit630d60ec106ed9aef720591c95d254f4c4e39e71 (patch)
tree73dd196eed0997d123a44132a0e4684cd1e3843d
parentb1232a426c36a7b6bf29f872966a451d1fb1c16e (diff)
downloadHLS-Streamer-JS-630d60ec106ed9aef720591c95d254f4c4e39e71.zip
HLS-Streamer-JS-630d60ec106ed9aef720591c95d254f4c4e39e71.tar.gz
HLS-Streamer-JS-630d60ec106ed9aef720591c95d254f4c4e39e71.tar.bz2
HLS-Streamer-JS-630d60ec106ed9aef720591c95d254f4c4e39e71.tar.xz
Changes necessary to support Express 4 framework.
-rw-r--r--apps/sidewalk/views/index.jade34
-rw-r--r--apps/sidewalk/views/layout.jade (renamed from views/layout.jade)9
-rw-r--r--apps/sidewalk/views/show.jade32
-rw-r--r--apps/socket-io.coffee6
-rw-r--r--package.json23
-rw-r--r--server.js77
6 files changed, 102 insertions, 79 deletions
diff --git a/apps/sidewalk/views/index.jade b/apps/sidewalk/views/index.jade
index 63164c0..93c0815 100644
--- a/apps/sidewalk/views/index.jade
+++ b/apps/sidewalk/views/index.jade
@@ -1,16 +1,18 @@
1div#home.current 1extends layout
2 div.toolbar 2
3 if q 3block content
4 a.back(href="#") Back 4 div#home.current
5 h1 HLS Streamer 5 div.toolbar
6 a.button(href="#about") About HLS Streamer 6 if q
7 div.scroll 7 a.back(href="#") Back
8 ul.rounded 8 h1 HLS Streamer
9 each video in videos 9 div.scroll
10 li.arrow 10 ul.rounded
11 - var link = video.id 11 each video in videos
12 a(href="?q=" + link target="_webapp").webapp.loading 12 li.arrow
13 = video.name 13 - var link = video.id
14 if !video.directory 14 a(href="?q=" + link target="_webapp").webapp.loading
15 small.counter 15 = video.name
16 = video.size 16 if !video.directory
17 small.counter
18 = video.size
diff --git a/views/layout.jade b/apps/sidewalk/views/layout.jade
index 1ac05c2..8963d3f 100644
--- a/views/layout.jade
+++ b/apps/sidewalk/views/layout.jade
@@ -1,5 +1,5 @@
1doctype html 1doctype html
2html 2html(lang="en")
3 head 3 head
4 title= "HLS Streamer JS - " + title 4 title= "HLS Streamer JS - " + title
5 link(rel='apple-touch-icon', href='/images/apple-touch-icon.png') 5 link(rel='apple-touch-icon', href='/images/apple-touch-icon.png')
@@ -11,12 +11,7 @@ html
11 11
12 div#jqt.supports3d.touchscroll.portrait 12 div#jqt.supports3d.touchscroll.portrait
13 13
14 div#about 14 block content
15 center
16 h1= title
17 a.grayButton.goback(href="#") Close
18
19 != body
20 15
21 script(src='/socket.io/socket.io.js') 16 script(src='/socket.io/socket.io.js')
22 != js('application') 17 != js('application')
diff --git a/apps/sidewalk/views/show.jade b/apps/sidewalk/views/show.jade
index be58c40..4f8b6c2 100644
--- a/apps/sidewalk/views/show.jade
+++ b/apps/sidewalk/views/show.jade
@@ -1,15 +1,17 @@
1div#home.current 1extends layout
2 div.toolbar 2
3 if q 3block content
4 a.back(href="#") Back 4 div#home.current
5 h1 HLS Streamer 5 div.toolbar
6 a.button(href="#about") About HLS Streamer 6 if q
7 div.scroll 7 a.back(href="#") Back
8 center 8 h1 HLS Streamer
9 = video.name 9 div.scroll
10 video(src=video.sha + ".m3u8" width="100%" height="100%" autoplay="autoplay" controls="controls" data-sha="#{video.sha}" data-file="#{video.file}" data-wshost="ws://localhost:3000/") 10 center
11 script(type="text/javascript"). 11 = video.name
12 wshost = "ws://localhost:3000/"; 12 video(src=video.sha + ".m3u8" width="100%" height="100%" autoplay="autoplay" controls="controls" data-sha="#{video.sha}" data-file="#{video.file}" data-wshost="ws://localhost:3000/")
13 sha256 = "#{video.sha}"; 13 script(type="text/javascript").
14 file = "#{video.path}/#{video.name}"; 14 wshost = "ws://localhost:3000/";
15 pos = "0"; \ No newline at end of file 15 sha256 = "#{video.sha}";
16 file = "#{video.path}/#{video.name}";
17 pos = "0";
diff --git a/apps/socket-io.coffee b/apps/socket-io.coffee
index 930f515..4f95489 100644
--- a/apps/socket-io.coffee
+++ b/apps/socket-io.coffee
@@ -2,8 +2,8 @@ Transcoder = require '../models/transcoder'
2 2
3module.exports = (app) -> 3module.exports = (app) ->
4 socketIO = require('socket.io').listen(app) 4 socketIO = require('socket.io').listen(app)
5 unless app.settings.socketIO 5 #unless app.settings.socketIO
6 app.set 'socketIO', socketIO 6 # app.set 'socketIO', socketIO
7 socketIO.sockets.on 'connection', (socket) -> 7 socketIO.sockets.on 'connection', (socket) ->
8 console.log "CONNECTED" 8 console.log "CONNECTED"
9 socket.on 'message', (socket) -> 9 socket.on 'message', (socket) ->
@@ -15,4 +15,4 @@ module.exports = (app) ->
15 console.log "Pausing at position '" + match[1] + "' of '" + match[2] + "'" 15 console.log "Pausing at position '" + match[1] + "' of '" + match[2] + "'"
16 else if socket.substr(0,4) == "kill" 16 else if socket.substr(0,4) == "kill"
17 console.log("kill: " + socket.substr(5)) 17 console.log("kill: " + socket.substr(5))
18 Transcoder.stop(socket.substr(5)) \ No newline at end of file 18 Transcoder.stop(socket.substr(5))
diff --git a/package.json b/package.json
index 4b5bc9d..11ace99 100644
--- a/package.json
+++ b/package.json
@@ -3,20 +3,23 @@
3 "version": "0.0.1", 3 "version": "0.0.1",
4 "private": true, 4 "private": true,
5 "dependencies": { 5 "dependencies": {
6 "express": "2.5.1", 6 "express": "4.10.6",
7 "jade": ">= 0.0.1", 7 "jade": ">= 0.0.1",
8 "redis": "~0.7.1", 8 "redis": "~0.12.1",
9 "hiredis": "~0.1.14", 9 "hiredis": "~0.1.14",
10 "coffee-script": "~1.2.0", 10 "coffee-script": "~1.8.0",
11 "connect-redis": "~1.2.0", 11 "connect-redis": "~2.1.0",
12 "express-namespace": "0.0.4", 12 "express-namespace": "0.1.1",
13 "connect-assets": "~2.1.8", 13 "connect-assets": "~4.3.3",
14 "socket.io": "~0.9.2", 14 "socket.io": "~1.2.1",
15 "underscore": "~1.3.1", 15 "underscore": "~1.7.0",
16 "stylus": "~0.24.0", 16 "stylus": "~0.49.3",
17 "filepath": "~0.8.1", 17 "filepath": "~0.8.1",
18 "pmset": "~0.0.1", 18 "pmset": "~0.0.1",
19 "mdns": "~2.2.0" 19 "mdns": "~2.2.0",
20 "express-busboy": "~2.1.0",
21 "cookie-parser": ">= 0.0.1",
22 "express-session": ">= 0.0.1"
20 }, 23 },
21 "devDependencies": { 24 "devDependencies": {
22 "node-dev": "~0.2.2", 25 "node-dev": "~0.2.2",
diff --git a/server.js b/server.js
index 84d9855..80d9517 100644
--- a/server.js
+++ b/server.js
@@ -1,21 +1,24 @@
1require('coffee-script'); 1var CoffeeScript = require('coffee-script');
2 2
3/** 3/**
4 * Module dependencies. 4 * Module dependencies.
5 */ 5 */
6 6
7var express = require('express'), 7var express = require('express'),
8 stylus = require('stylus'), 8 stylus = require('stylus');
9 RedisStore = require('connect-redis')(express); 9var busboy = require('express-busboy');
10var cookieParser = require('cookie-parser');
11var session = require('express-session');
10 12
11require('express-namespace') 13require('express-namespace')
12 14
13var app = module.exports = express.createServer(); 15var app = module.exports = express();
14 16CoffeeScript.register();
15require('./apps/socket-io')(app) 17var server = require('http').Server(app);
18require('./apps/socket-io')(server)
16 19
17// Configuration 20// Configuration
18app.configure(function () { 21//app.configure(function () {
19 app.use(stylus.middleware({ 22 app.use(stylus.middleware({
20 src: __dirname + "/views", 23 src: __dirname + "/views",
21 // It will add /stylesheets to this path. 24 // It will add /stylesheets to this path.
@@ -23,33 +26,48 @@ app.configure(function () {
23 })); 26 }));
24 app.set('views', __dirname + '/views'); 27 app.set('views', __dirname + '/views');
25 app.set('view engine', 'jade'); 28 app.set('view engine', 'jade');
29 app.engine('jade', require('jade').__express);
30 app.set('view options', { layout: false });
26 app.set('port', 3001); 31 app.set('port', 3001);
27 app.use(express.bodyParser()); 32 // app.use(busboy({immediate:true}));
28 app.use(express.methodOverride()); 33 busboy.extend(app);
29 app.use(express.cookieParser()); 34 //app.use(express.methodOverride());
30 app.use(express.session({ 35 app.use(cookieParser());
31 secret: "KioxIqpvdyfMXOHjVkUQmGLwEAtB0SZ9cTuNgaWFJYsbzerCDn", 36 app.use(session({
32 store: new RedisStore 37 secret: "KioxIqpvdyfMXOHjVkUQmGLwEAtB0SZ9cTuNgaWFJYsbzerCDn"
33 })); 38 }));
34 app.use(require('connect-assets')()); 39 app.use(require('connect-assets')());
35 app.use(app.router); 40 // app.use(app.router);
36 app.use(express.static(__dirname + '/public')); 41 app.use(express.static(__dirname + '/public'));
37}); 42//});
43
44 /*
45 app.use(function(req, res, next) {
46 req.busboy.on('field', function(fieldname, val) {
47 req.body[fieldname] = val;
48 });
49 req.busboy.on('finish', function() {
50 next();
51 });
52 });
53 */
38 54
39app.configure('development', function () { 55//app.configure('development', function () {
40 app.use(express.errorHandler({ 56 //app.use(express.errorHandler({
41 dumpExceptions: true, 57 // dumpExceptions: true,
42 showStack: true 58 // showStack: true
43 })); 59 // }));
44}); 60//});
45 61
46app.configure('test', function () { 62//app.configure('test', function () {
47 app.set('port', 3001); 63 app.set('port', 3001);
48}); 64//});
49 65
50app.configure('production', function () { 66 // if ('production' == app.get('env')) {
51 app.use(express.errorHandler()); 67//app.configure('production', function () {
52}); 68 //app.use(express.errorHandler());
69//});
70 // }
53 71
54String.prototype.commafy = function () { 72String.prototype.commafy = function () {
55 return this.replace(/(^|[^\w.])(\d{4,})/g, function($0, $1, $2) { 73 return this.replace(/(^|[^\w.])(\d{4,})/g, function($0, $1, $2) {
@@ -62,14 +80,17 @@ Number.prototype.commafy = function () {
62} 80}
63 81
64// Global helpers 82// Global helpers
65require('./apps/helpers')(app); 83// require('./apps/helpers')(app);
66 84
67// Routes 85// Routes
68require('./apps/sidewalk/routes')(app); 86require('./apps/sidewalk/routes')(app);
69//require('./apps/authentication/routes')(app); 87//require('./apps/authentication/routes')(app);
70//require('./apps/admin/routes')(app); 88//require('./apps/admin/routes')(app);
71 89
72app.listen(app.settings.port); 90server.listen(app.get('port'), function(){
91 console.log('express listening on port ' + app.get('port'));
92});
93//app.listen(app.settings.port);
73 94
74// advertise a http server on port # 95// advertise a http server on port #
75var mdns = require('mdns'); 96var mdns = require('mdns');