mirror of
https://github.com/fergalmoran/dss.git
synced 2025-12-22 09:38:18 +00:00
Started new socket.io interface
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
define ['backbone', 'marionette', 'vent', 'app.lib/router', 'app.lib/panningRegion', 'app.lib/audioController', 'views/header',
|
||||
define ['backbone', 'marionette', 'vent',
|
||||
'app.lib/router', 'app.lib/panningRegion', 'app.lib/realtimeController', 'app.lib/audioController', 'views/header',
|
||||
'views/sidebar/sidebarView',
|
||||
'models/mix/mixCollection'],
|
||||
(Backbone, Marionette, vent, DssRouter, PanningRegion, AudioController, HeaderView, SidebarView, MixCollection) ->
|
||||
(Backbone, Marionette, vent, DssRouter, PanningRegion, RealtimeController, AudioController, HeaderView, SidebarView, MixCollection) ->
|
||||
Marionette.Region.prototype.open = (view) ->
|
||||
@.$el.hide();
|
||||
@.$el.html(view.el);
|
||||
@@ -9,7 +10,9 @@ define ['backbone', 'marionette', 'vent', 'app.lib/router', 'app.lib/panningRegi
|
||||
true
|
||||
|
||||
App = new Marionette.Application();
|
||||
App.audioController = new AudioController()
|
||||
App.audioController = new AudioController();
|
||||
App.realtimeController = new RealtimeController();
|
||||
App.realtimeController.startSocketIO();
|
||||
|
||||
App.vent.on "routing:started", ->
|
||||
console.log "App(vent): routing:started"
|
||||
@@ -36,9 +39,7 @@ define ['backbone', 'marionette', 'vent', 'app.lib/router', 'app.lib/panningRegi
|
||||
App.vent.trigger("routing:started");
|
||||
|
||||
App.addInitializer ->
|
||||
console.log("App: gobbling links");
|
||||
$(document).on("click", "a[href]:not([data-bypass])", (evt) ->
|
||||
console.log("App: scarfed link")
|
||||
href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
|
||||
root = location.protocol + "//" + location.host + (App.root || '/');
|
||||
if (href.prop.slice(0, root.length) == root)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
|
||||
define(['backbone', 'marionette', 'vent', 'app.lib/router', 'app.lib/panningRegion', 'app.lib/audioController', 'views/header', 'views/sidebar/sidebarView', 'models/mix/mixCollection'], function(Backbone, Marionette, vent, DssRouter, PanningRegion, AudioController, HeaderView, SidebarView, MixCollection) {
|
||||
define(['backbone', 'marionette', 'vent', 'app.lib/router', 'app.lib/panningRegion', 'app.lib/realtimeController', 'app.lib/audioController', 'views/header', 'views/sidebar/sidebarView', 'models/mix/mixCollection'], function(Backbone, Marionette, vent, DssRouter, PanningRegion, RealtimeController, AudioController, HeaderView, SidebarView, MixCollection) {
|
||||
var App, sidebarView;
|
||||
Marionette.Region.prototype.open = function(view) {
|
||||
this.$el.hide();
|
||||
@@ -11,6 +11,8 @@
|
||||
};
|
||||
App = new Marionette.Application();
|
||||
App.audioController = new AudioController();
|
||||
App.realtimeController = new RealtimeController();
|
||||
App.realtimeController.startSocketIO();
|
||||
App.vent.on("routing:started", function() {
|
||||
var enablePushState, pushState;
|
||||
console.log("App(vent): routing:started");
|
||||
@@ -36,10 +38,8 @@
|
||||
return App.vent.trigger("routing:started");
|
||||
});
|
||||
App.addInitializer(function() {
|
||||
console.log("App: gobbling links");
|
||||
$(document).on("click", "a[href]:not([data-bypass])", function(evt) {
|
||||
var href, root;
|
||||
console.log("App: scarfed link");
|
||||
href = {
|
||||
prop: $(this).prop("href"),
|
||||
attr: $(this).attr("href")
|
||||
|
||||
@@ -20,7 +20,8 @@ requirejs.config({
|
||||
models: 'app/models',
|
||||
'app.lib': 'app/lib',
|
||||
moment: 'libs/moment',
|
||||
toastr: 'libs/toastr'
|
||||
toastr: 'libs/toastr',
|
||||
'socket.io': com.podnoms.settings.SOCKET_IO_JS_URL
|
||||
},
|
||||
shim: {
|
||||
jquery: {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
define ['app', 'marionette',
|
||||
'views/chat/chatView',
|
||||
'models/mix/mixItem', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView',
|
||||
'models/user/userItem', 'views/user/userListView', 'views/user/userEditView'],
|
||||
(App, Marionette, MixItem, MixListView, MixDetailView, MixEditView, UserItem, UserListView, UserEditView)->
|
||||
(App, Marionette, ChatView, MixItem, MixListView, MixDetailView, MixEditView, UserItem, UserListView, UserEditView)->
|
||||
class DssController extends Marionette.Controller
|
||||
home: ->
|
||||
console.log "Controller: home"
|
||||
@@ -51,6 +52,11 @@ define ['app', 'marionette',
|
||||
)
|
||||
true
|
||||
|
||||
showChat: ->
|
||||
console.log("Controller: showChat")
|
||||
app = require('app')
|
||||
app.contentRegion.show(new ChatView())
|
||||
|
||||
showUserList: (type) ->
|
||||
console.log("Controller: showUserList")
|
||||
app = require('app')
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// Generated by CoffeeScript 1.6.2
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
define(['app', 'marionette', 'models/mix/mixItem', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView', 'models/user/userItem', 'views/user/userListView', 'views/user/userEditView'], function(App, Marionette, MixItem, MixListView, MixDetailView, MixEditView, UserItem, UserListView, UserEditView) {
|
||||
var DssController, _ref;
|
||||
|
||||
define(['app', 'marionette', 'views/chat/chatView', 'models/mix/mixItem', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView', 'models/user/userItem', 'views/user/userListView', 'views/user/userEditView'], function(App, Marionette, ChatView, MixItem, MixListView, MixDetailView, MixEditView, UserItem, UserListView, UserEditView) {
|
||||
var DssController;
|
||||
DssController = (function(_super) {
|
||||
|
||||
__extends(DssController, _super);
|
||||
|
||||
function DssController() {
|
||||
_ref = DssController.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
return DssController.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
DssController.prototype.home = function() {
|
||||
@@ -22,7 +21,6 @@
|
||||
|
||||
DssController.prototype._showMixList = function(options) {
|
||||
var app;
|
||||
|
||||
console.log("Controller: _showMixList");
|
||||
app = require('app');
|
||||
app.contentRegion.show(new MixListView(options));
|
||||
@@ -38,7 +36,6 @@
|
||||
|
||||
DssController.prototype.showMix = function(slug) {
|
||||
var app, mix;
|
||||
|
||||
console.log("Controller: showMix");
|
||||
app = require('app');
|
||||
mix = new MixItem({
|
||||
@@ -57,7 +54,6 @@
|
||||
|
||||
DssController.prototype.uploadMix = function() {
|
||||
var app, mix;
|
||||
|
||||
console.log("Controller: mixUpload");
|
||||
app = require('app');
|
||||
mix = new MixItem({
|
||||
@@ -74,7 +70,6 @@
|
||||
|
||||
DssController.prototype.editMix = function(slug) {
|
||||
var app, mix;
|
||||
|
||||
console.log("Controller: mixEdit");
|
||||
app = require('app');
|
||||
mix = new MixItem({
|
||||
@@ -90,9 +85,15 @@
|
||||
return true;
|
||||
};
|
||||
|
||||
DssController.prototype.showChat = function() {
|
||||
var app;
|
||||
console.log("Controller: showChat");
|
||||
app = require('app');
|
||||
return app.contentRegion.show(new ChatView());
|
||||
};
|
||||
|
||||
DssController.prototype.showUserList = function(type) {
|
||||
var app;
|
||||
|
||||
console.log("Controller: showUserList");
|
||||
app = require('app');
|
||||
return app.contentRegion.show(new UserListView());
|
||||
@@ -144,7 +145,6 @@
|
||||
|
||||
DssController.prototype.editUser = function() {
|
||||
var app, user;
|
||||
|
||||
console.log("Controller: editUser");
|
||||
app = require('app');
|
||||
user = new UserItem({
|
||||
|
||||
15
static/js/app/lib/realtimeController.coffee
Normal file
15
static/js/app/lib/realtimeController.coffee
Normal file
@@ -0,0 +1,15 @@
|
||||
define ['socket.io'],
|
||||
(SocketIO) ->
|
||||
class RealtimeController
|
||||
startSocketIO: ->
|
||||
console.log("RealtimeController: Socket IO starting")
|
||||
@socket = SocketIO.connect(com.podnoms.settings.REALTIME_HOST)
|
||||
@socket.on "connect": =>
|
||||
console.log("RealtimeController: Connected")
|
||||
|
||||
sendMessage: (message) ->
|
||||
console.log("RealtimeController: sendMessage")
|
||||
@socket.
|
||||
|
||||
RealtimeController
|
||||
|
||||
32
static/js/app/lib/realtimeController.js
Normal file
32
static/js/app/lib/realtimeController.js
Normal file
@@ -0,0 +1,32 @@
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
|
||||
define(['socket.io'], function(SocketIO) {
|
||||
var RealtimeController;
|
||||
RealtimeController = (function() {
|
||||
|
||||
function RealtimeController() {}
|
||||
|
||||
RealtimeController.prototype.startSocketIO = function() {
|
||||
var _this = this;
|
||||
console.log("RealtimeController: Socket IO starting");
|
||||
this.socket = SocketIO.connect(com.podnoms.settings.REALTIME_HOST);
|
||||
return this.socket.on("news", function(data) {
|
||||
console.log("RealtimeController: Connected");
|
||||
return _this.socket.emit("dss:connected", {
|
||||
my: "data"
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
RealtimeController.prototype.sendMessage = function(message) {
|
||||
return console.log("RealtimeController: sendMessage");
|
||||
};
|
||||
|
||||
return RealtimeController;
|
||||
|
||||
})();
|
||||
return RealtimeController;
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -12,6 +12,8 @@ define ['marionette', 'app.lib/controller'],
|
||||
"mix/:slug": "showMix"
|
||||
"mix/edit/:slug": "editMix",
|
||||
|
||||
"chat": "showChat",
|
||||
|
||||
"users": "showUserList"
|
||||
"user/:slug/favourites": "showUserFavourites"
|
||||
"user/:slug/likes": "showUserLikes"
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// Generated by CoffeeScript 1.6.2
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
define(['marionette', 'app.lib/controller'], function(Marionette, Controller) {
|
||||
var DssRouter, _ref;
|
||||
|
||||
var DssRouter;
|
||||
return DssRouter = (function(_super) {
|
||||
|
||||
__extends(DssRouter, _super);
|
||||
|
||||
function DssRouter() {
|
||||
_ref = DssRouter.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
return DssRouter.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
DssRouter.prototype.controller = new Controller;
|
||||
@@ -24,6 +23,7 @@
|
||||
"mixes/:type": "showMixList",
|
||||
"mix/:slug": "showMix",
|
||||
"mix/edit/:slug": "editMix",
|
||||
"chat": "showChat",
|
||||
"users": "showUserList",
|
||||
"user/:slug/favourites": "showUserFavourites",
|
||||
"user/:slug/likes": "showUserLikes",
|
||||
|
||||
@@ -14,7 +14,6 @@ define ['marionette', 'models/activity/activityCollection', 'views/activity/acti
|
||||
@collection.fetch(
|
||||
success: =>
|
||||
console.log "ActivityListView: Collection fetched"
|
||||
console.log @collection
|
||||
return
|
||||
)
|
||||
return
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
// Generated by CoffeeScript 1.6.2
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
define(['marionette', 'models/activity/activityCollection', 'views/activity/activityItemView', 'text!/tpl/ActivityListView'], function(Marionette, ActivityCollection, ActivityItemView, Template) {
|
||||
var ActivityListView, _ref;
|
||||
|
||||
var ActivityListView;
|
||||
ActivityListView = (function(_super) {
|
||||
|
||||
__extends(ActivityListView, _super);
|
||||
|
||||
function ActivityListView() {
|
||||
_ref = ActivityListView.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
return ActivityListView.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
ActivityListView.prototype.template = _.template(Template);
|
||||
@@ -26,13 +25,11 @@
|
||||
|
||||
ActivityListView.prototype.initialize = function() {
|
||||
var _this = this;
|
||||
|
||||
console.log("ActivityListView: initialize");
|
||||
this.collection = new ActivityCollection;
|
||||
this.collection.fetch({
|
||||
success: function() {
|
||||
console.log("ActivityListView: Collection fetched");
|
||||
console.log(_this.collection);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
18
static/js/app/views/chat/chatView.coffee
Executable file
18
static/js/app/views/chat/chatView.coffee
Executable file
@@ -0,0 +1,18 @@
|
||||
define ['marionette', 'app.lib/realtimeController', 'text!/tpl/ChatView'],
|
||||
(Marionette, RealtimeController, Template) ->
|
||||
class ChatView extends Marionette.ItemView
|
||||
controller = new RealtimeController()
|
||||
template: _.template(Template)
|
||||
ui:
|
||||
chatMessage: '#chat-message'
|
||||
|
||||
events:
|
||||
"click #chat-send": "sendChatMessage"
|
||||
|
||||
sendChatMessage: ->
|
||||
console.log("ChatView: sendChatMessage")
|
||||
message = @ui.chatMessage.val()
|
||||
if message
|
||||
controller.sendMessage(message)
|
||||
|
||||
ChatView
|
||||
44
static/js/app/views/chat/chatView.js
Normal file
44
static/js/app/views/chat/chatView.js
Normal file
@@ -0,0 +1,44 @@
|
||||
// Generated by CoffeeScript 1.3.3
|
||||
(function() {
|
||||
var __hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
define(['marionette', 'app.lib/realtimeController', 'text!/tpl/ChatView'], function(Marionette, RealtimeController, Template) {
|
||||
var ChatView;
|
||||
ChatView = (function(_super) {
|
||||
var controller;
|
||||
|
||||
__extends(ChatView, _super);
|
||||
|
||||
function ChatView() {
|
||||
return ChatView.__super__.constructor.apply(this, arguments);
|
||||
}
|
||||
|
||||
controller = new RealtimeController();
|
||||
|
||||
ChatView.prototype.template = _.template(Template);
|
||||
|
||||
ChatView.prototype.ui = {
|
||||
chatMessage: '#chat-message'
|
||||
};
|
||||
|
||||
ChatView.prototype.events = {
|
||||
"click #chat-send": "sendChatMessage"
|
||||
};
|
||||
|
||||
ChatView.prototype.sendChatMessage = function() {
|
||||
var message;
|
||||
console.log("ChatView: sendChatMessage");
|
||||
message = this.ui.chatMessage.val();
|
||||
if (message) {
|
||||
return controller.sendMessage(message);
|
||||
}
|
||||
};
|
||||
|
||||
return ChatView;
|
||||
|
||||
})(Marionette.ItemView);
|
||||
return ChatView;
|
||||
});
|
||||
|
||||
}).call(this);
|
||||
@@ -2,9 +2,8 @@ if (!com) var com = {};
|
||||
if (!com.podnoms) com.podnoms = {};
|
||||
|
||||
com.podnoms.settings = {
|
||||
CHAT_HOST: '{{ CHAT_HOST }}',
|
||||
REALTIME_HOST: '{{ CHAT_HOST }}',
|
||||
REALTIME_PORT: '{{ CHAT_HOST }}',
|
||||
REALTIME_HOST: "{{ REALTIME_HOST }}",
|
||||
SOCKET_IO_JS_URL: "{{ SOCKET_IO_JS_URL }}",
|
||||
urlRoot: '{{ API_URL }}',
|
||||
liveStreamRoot: 'http://{{ LIVE_STREAM_URL }}:{{ LIVE_STREAM_PORT }}/{{ LIVE_STREAM_MOUNT }}',
|
||||
streamInfoUrl: 'http://{{ LIVE_STREAM_INFO_URL }}',
|
||||
|
||||
16
templates/views/ChatView.html
Normal file
16
templates/views/ChatView.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<fieldset>
|
||||
<legend>Dss Chat Server</legend>
|
||||
<div class="control-group">
|
||||
<label for="chat-message" class="control-label">Message</label>
|
||||
<div class="controls">
|
||||
<textarea class="input-block-level" id="chat-message" rows="3" name="textarea"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Button -->
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button id="chat-send" name="chat-send" class="btn btn-success">Send message</button>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
Reference in New Issue
Block a user