diff --git a/index.html b/index.html new file mode 100644 index 0000000..cd85f0c --- /dev/null +++ b/index.html @@ -0,0 +1,31 @@ +if (!com) var com = {}; +if (!com.podnoms) com.podnoms = {}; + +com.podnoms.settings = { + CHAT_HOST: 'www.deepsouthsounds.com:8081', + REALTIME_HOST: 'www.deepsouthsounds.com:8081', + REALTIME_PORT: 'www.deepsouthsounds.com:8081', + urlRoot: '/api/v1/', + liveStreamRoot: 'http://radio.deepsouthsounds.com:8000/mp3', + streamInfoUrl: 'http://radio.deepsouthsounds.com:8000/mp3', + volume: '50', + smDebugMode: false, + isDebug: false, + drawTimelineOnMix: false, + staticUrl: 'http://static.podnoms.com/', + urlArgs: false ? "" : "bust="+ (new Date()).getTime(), + currentUser: -1, + /** simple helper to take an api JSON object and initialise a player item */ + setupPlayerWrapper: function (id, stream_url, el) { + com.podnoms.player.setupPlayer({ + id: id, + boundingEl: $('#mix-container-' + id, el), + waveFormEl: $('#waveform-' + id, el), + playHeadEl: $('#playhead-player-' + id, el), + loadingEl: $('#progress-player-' + id, el), + seekHeadEl: $('#player-seekhead', el), + playButtonEl: $('#play-pause-button-small-' + id, el), + url: stream_url || "" + }); + } +}; diff --git a/manage.py b/manage.py old mode 100644 new mode 100755 diff --git a/static/js/app/lib/utils.coffee b/static/js/app/lib/utils.coffee index a3af839..6442878 100644 --- a/static/js/app/lib/utils.coffee +++ b/static/js/app/lib/utils.coffee @@ -1,7 +1,4 @@ -define ['jquery', 'bootstrap'] -($, bootstrap) -> - class Utils - +define ['jquery', 'bootstrap'], ($, bootstrap) -> modal: (url) -> if url.indexOf("#") is 0 $(url).modal "open" @@ -20,5 +17,3 @@ define ['jquery', 'bootstrap'] com.podnoms.utils.modal "tpl/PlayCountLoginAlert" if (data.play_count isnt 0) and (data.play_count % 1) is 0 true - Utils - diff --git a/static/js/app/lib/utils.js b/static/js/app/lib/utils.js new file mode 100644 index 0000000..bd75cdd --- /dev/null +++ b/static/js/app/lib/utils.js @@ -0,0 +1,33 @@ +// Generated by CoffeeScript 1.3.3 +(function() { + + define(['jquery', 'bootstrap'], function($, bootstrap) { + return { + modal: function(url) { + if (url.indexOf("#") === 0) { + $(url).modal("open"); + } else { + $.get(url, function(data) { + return $("
" + data + "
").modal().on("hidden", function() { + return $(this).remove(); + }); + }).success(function() { + return $("input:text:visible:first").focus(); + }); + } + return true; + }, + checkPlayCount: function() { + if (document.cookie.indexOf("sessionId")) { + $.getJSON("/ajax/session_play_count", function(data) { + if ((data.play_count !== 0) && (data.play_count % 1) === 0) { + return com.podnoms.utils.modal("tpl/PlayCountLoginAlert"); + } + }); + } + return true; + } + }; + }); + +}).call(this); diff --git a/static/js/app/views/header.js b/static/js/app/views/header.js new file mode 100644 index 0000000..08314cb --- /dev/null +++ b/static/js/app/views/header.js @@ -0,0 +1,103 @@ +// Generated by CoffeeScript 1.3.3 + +/* +@license + +---------------------------------------------- + +Copyright (c) 2012, Fergal Moran. All rights reserved. +Code provided under the BSD License: +*/ + + +(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(["underscore", "backbone", "vent", "utils", "text!/tpl/HeaderView"], function(_, Backbone, vent, utils, Template) { + var HeaderView; + HeaderView = (function(_super) { + + __extends(HeaderView, _super); + + function HeaderView() { + return HeaderView.__super__.constructor.apply(this, arguments); + } + + HeaderView.prototype.template = _.template(Template); + + HeaderView.prototype.events = { + "click #header-play-pause-button": "togglePlayState", + "click #header-login-button": "login", + "click #header-live-button": "playLive" + }; + + HeaderView.prototype.initialize = function() { + this.render(); + this.listenTo(vent, "mix:play", this.trackPlaying); + return this.listenTo(vent, "mix:pause", this.trackPaused); + }; + + HeaderView.prototype.login = function() { + return utils.modal("tpl/LoginView"); + }; + + HeaderView.prototype.logout = function() { + return utils.showAlert("Success", "You are now logged out"); + }; + + HeaderView.prototype.trackChanged = function(data) { + $(this.el).find("#track-description").text(data.title); + return $(this.el).find("#track-description").attr("href", "#" + data.item_url); + }; + + HeaderView.prototype.trackPlaying = function(data) { + $(this.el).find("#header-play-button-icon").removeClass("icon-play"); + return $(this.el).find("#header-play-button-icon").addClass("icon-pause"); + }; + + HeaderView.prototype.trackPaused = function(data) { + $(this.el).find("#header-play-button-icon").removeClass("icon-pause"); + return $(this.el).find("#header-play-button-icon").addClass("icon-play"); + }; + + HeaderView.prototype.render = function() { + $(this.el).html(this.template()); + return this; + }; + + HeaderView.prototype.playLive = function() { + var button, ref; + ref = this; + dssSoundHandler.playLive(); + _eventAggregator.trigger("track_playing"); + button = $(this.el).find("#header-play-pause-button"); + button.data("mode", "pause"); + return $.getJSON("ajax/live_now_playing/", function(data) { + alert(data.title); + return $(ref.el).find("#live-now-playing").text(data.title); + }); + }; + + HeaderView.prototype.togglePlayState = function() { + var button, mode; + button = $(this.el).find("#header-play-pause-button"); + mode = button.data("mode"); + if (mode === "play") { + dssSoundHandler.resumeSound(); + _eventAggregator.trigger("track_playing"); + return button.data("mode", "pause"); + } else { + dssSoundHandler.pauseSound(); + _eventAggregator.trigger("track_paused"); + return button.data("mode", "play"); + } + }; + + return HeaderView; + + })(Backbone.View); + return HeaderView; + }); + +}).call(this); diff --git a/static/js/app/views/mix/mixItemView.js b/static/js/app/views/mix/mixItemView.js index 31a85a1..2f504e7 100644 --- a/static/js/app/views/mix/mixItemView.js +++ b/static/js/app/views/mix/mixItemView.js @@ -1,22 +1,26 @@ -// Generated by CoffeeScript 1.6.2 +// Generated by CoffeeScript 1.3.3 (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __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(['moment', 'app', 'vent', 'marionette', 'models/comment/commentCollection', 'views/comment/commentListView', 'text!/tpl/MixListItemView'], function(moment, App, vent, Marionette, CommentsCollection, CommentsListView, Template) { - var MixItemView, _ref; - + var MixItemView; MixItemView = (function(_super) { + __extends(MixItemView, _super); function MixItemView() { this.doStart = __bind(this.doStart, this); + this.renderComments = __bind(this.renderComments, this); + this.renderGenres = __bind(this.renderGenres, this); + this.onRender = __bind(this.onRender, this); - this.initialize = __bind(this.initialize, this); _ref = MixItemView.__super__.constructor.apply(this, arguments); - return _ref; + + this.initialize = __bind(this.initialize, this); + return MixItemView.__super__.constructor.apply(this, arguments); } MixItemView.prototype.template = _.template(Template); @@ -50,7 +54,6 @@ MixItemView.prototype.onRender = function() { var id, totalDuration, totalDurationText; - id = this.model.get('id'); if (this.model.get('duration')) { totalDuration = moment.duration(this.model.get('duration'), "seconds"); @@ -70,7 +73,6 @@ MixItemView.prototype.renderGenres = function() { var el; - el = this.el; $.each(this.model.get("genre-list"), function(data) { $("#genre-list", el).append('' + this.text + ''); @@ -81,7 +83,6 @@ MixItemView.prototype.renderComments = function() { var comments; - comments = new CommentsCollection(); comments.url = this.model.get("resource_uri") + "comments/"; comments.mix_id = this.model.id; @@ -89,7 +90,6 @@ comments.fetch({ success: function(data) { var content; - console.log(data); content = new CommentsListView({ collection: comments @@ -133,7 +133,6 @@ MixItemView.prototype.mixFavourite = function() { var app; - console.log("MixItemView: favouriteMix"); app = require('app'); app.vent.trigger("mix:favourite", this.model); @@ -142,7 +141,6 @@ MixItemView.prototype.mixLike = function() { var app; - console.log("MixItemView: likeMix"); app = require('app'); app.vent.trigger("mix:like", this.model); @@ -151,7 +149,6 @@ MixItemView.prototype.mixShare = function(e) { var app, mode; - console.log("MixItemView: shareMix"); mode = $(e.currentTarget).data("mode"); console.log("MixItemView: " + mode); diff --git a/static/js/app/views/user/userListView.js b/static/js/app/views/user/userListView.js index db84b7f..83c4475 100644 --- a/static/js/app/views/user/userListView.js +++ b/static/js/app/views/user/userListView.js @@ -1,18 +1,18 @@ -// Generated by CoffeeScript 1.6.2 +// Generated by CoffeeScript 1.3.3 (function() { var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __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(['jquery', 'marionette', 'models/user/userCollection', 'views/user/userItemView', 'text!/tpl/UserListView', 'libs/bootstrap/bootpag'], function($, Marionette, UserCollection, UserItemView, Template) { - var UserListView, _ref; - + var UserListView; UserListView = (function(_super) { + __extends(UserListView, _super); function UserListView() { - this.initialize = __bind(this.initialize, this); _ref = UserListView.__super__.constructor.apply(this, arguments); - return _ref; + this.initialize = __bind(this.initialize, this); + return UserListView.__super__.constructor.apply(this, arguments); } UserListView.prototype.template = _.template(Template); @@ -23,7 +23,6 @@ UserListView.prototype.initialize = function() { var _this = this; - console.log("UserListView: initialize"); this.collection = new UserCollection(); this.collection.fetch({