From f01cc4b257725aa38147b58bbba3aaefb3a4a9bf Mon Sep 17 00:00:00 2001
From: Fergal Moran
Date: Fri, 25 Oct 2013 02:10:27 +0100
Subject: [PATCH] New header functions
---
INSTALL | 2 +-
core/utils/waveform.py | 5 +-
spa/signals.py | 8 +-
spa/urls.py | 3 +-
static/js/app/appv2.coffee | 11 +-
static/js/app/appv2.js | 15 +++
static/js/app/lib/controller.coffee | 1 +
static/js/app/lib/controller.js | 59 ++++++----
static/js/app/lib/realtimeController.coffee | 14 ++-
static/js/app/lib/realtimeController.js | 16 ++-
static/js/app/lib/router.coffee | 1 +
static/js/app/lib/social.js | 51 ++++++++
static/js/app/lib/utils.coffee | 20 ++++
static/js/app/lib/utils.js | 31 ++++-
static/js/app/models/mix/mixCollection.coffee | 2 +-
static/js/app/models/mix/mixCollection.js | 2 +-
static/js/app/views/mix/mixEditView.js | 2 +-
static/js/app/views/mix/mixItemView.coffee | 5 +
static/js/app/views/mix/mixItemView.js | 6 +
static/js/app/views/user/userEditView.js | 111 ++++++++++++++++++
static/js/app/views/widgets/headerView.coffee | 6 +-
static/js/app/views/widgets/headerView.js | 7 +-
static/js/lib/ace.js | 61 +++++-----
static/js/main.js | 6 +-
templates/views/HeaderView.html | 11 +-
templates/views/_MixItemInsert.html | 4 +-
templates/views/dlg/DeleteMixConfirm.html | 18 +++
templates/views/dlg/Donate.html | 2 +-
templates/views/dlg/EmbedCodes.html | 2 +-
templates/views/dlg/LoginView.html | 2 +-
templates/views/dlg/PlayCountLoginAlert.html | 2 +-
31 files changed, 393 insertions(+), 93 deletions(-)
create mode 100644 templates/views/dlg/DeleteMixConfirm.html
diff --git a/INSTALL b/INSTALL
index 7889add..5fc4c36 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,6 +1,6 @@
#curl -u hb_client_2862_1:j2CbCM8H -H 'Accept: application/json' -H 'Content-type: application/json' http://c1.lon2.dediserve.com/virtual_machines.xml
-apt-get install git python-virtualenv postgresql postgresql-client postgresql-client-common postgresql-dev-all rabbitmq-server libsndfile1-dev libpng++-dev libpng12-dev libboost-program-options-dev libjpeg-dev
+apt-get install git python-virtualenv postgresql postgresql-client postgresql-client-common postgresql-dev-all rabbitmq-server libsndfile1-dev libpng++-dev libpng12-dev libboost-program-options-dev libjpeg-dev python-dev
virtualenv env
source env/bin/activate
diff --git a/core/utils/waveform.py b/core/utils/waveform.py
index fbda0f3..30eb407 100755
--- a/core/utils/waveform.py
+++ b/core/utils/waveform.py
@@ -14,7 +14,10 @@ def generate_waveform(input_file, output_file):
print "Finished decode"
if os.path.exists(working_file):
print "Starting waveform generation"
- ret = subprocess.call([settings.DSS_WAVE_PATH, "-w", "800", "-h", "120", "-o", output_file, working_file], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
+ ret = subprocess.call([
+ settings.DSS_WAVE_PATH, "-w", "800", "-h", "120", "-o",
+ output_file,
+ working_file], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
if os.path.isfile(output_file):
os.remove(working_file)
print "Generated waveform"
diff --git a/spa/signals.py b/spa/signals.py
index 01f6833..45a53cd 100755
--- a/spa/signals.py
+++ b/spa/signals.py
@@ -70,8 +70,10 @@ def session_pre_save(sender, **kwargs):
if s is not None:
uid = s.get_decoded().get('_auth_user_id')
if uid is not None:
- user = User.objects.get(pk=uid)
- if user is not None:
+ try:
+ user = User.objects.get(pk=uid)
p = user.get_profile()
p.last_known_session = s.session_key
- p.save()
\ No newline at end of file
+ p.save()
+ except ObjectDoesNotExist:
+ pass
\ No newline at end of file
diff --git a/spa/urls.py b/spa/urls.py
index 57fe8ed..6c5aa66 100755
--- a/spa/urls.py
+++ b/spa/urls.py
@@ -37,9 +37,8 @@ urlpatterns = patterns(
url(r'^js/(?P\w+)/$', 'spa.templates.get_javascript'),
url(r'^tplex/(?P\w+)/$', 'spa.templates.get_template_ex'),
- url(r'^podcast\.xml', 'spa.podcast.get_default_podcast'),
url(r'^podcast', 'spa.podcast.get_default_podcast'),
- url(r'^podcasts', 'spa.podcast.get_default_podcast'),
+ url(r'^podcast\.xml', 'spa.podcast.get_default_podcast'),
url(r'^social/', include('spa.social.urls')),
url(r'^embed/', include('spa.embedding.urls')),
url(r'_upload/', 'spa.ajax.upload', name='jfu_upload'),
diff --git a/static/js/app/appv2.coffee b/static/js/app/appv2.coffee
index eb747fa..23c9d8b 100755
--- a/static/js/app/appv2.coffee
+++ b/static/js/app/appv2.coffee
@@ -65,6 +65,16 @@ define ['backbone', 'marionette', 'vent', 'utils',
model.save 'liked', !model.get('liked'), patch: true
true
+ @listenTo vent, "mix:delete", (model) ->
+ console.log "App(vent): mix:like"
+ utils.messageBox "/dlg/DeleteMixConfirm"
+ yes: ->
+ console.log("Controller: mixDeleteYES!!")
+ mix.destroy()
+ Backbone.history.navigate "/", trigger: true
+ no: ->
+ console.log("Controller: mixDeleteNO!!")
+
@listenTo vent, "user:follow", (model)->
console.log "App(vent): user:follow"
user = new UserItem({id: com.podnoms.settings.currentUser })
@@ -106,7 +116,6 @@ define ['backbone', 'marionette', 'vent', 'utils',
social.generateEmbedCode(model)
true
-
App.headerRegion.show(new HeaderView());
sidebarView = new SidebarView();
App.sidebarRegion.show(sidebarView)
diff --git a/static/js/app/appv2.js b/static/js/app/appv2.js
index ad07045..46821ca 100755
--- a/static/js/app/appv2.js
+++ b/static/js/app/appv2.js
@@ -71,6 +71,21 @@
});
return true;
});
+ this.listenTo(vent, "mix:delete", function(model) {
+ console.log("App(vent): mix:like");
+ return utils.messageBox("/dlg/DeleteMixConfirm", {
+ yes: function() {
+ console.log("Controller: mixDeleteYES!!");
+ mix.destroy();
+ return Backbone.history.navigate("/", {
+ trigger: true
+ });
+ },
+ no: function() {
+ return console.log("Controller: mixDeleteNO!!");
+ }
+ });
+ });
this.listenTo(vent, "user:follow", function(model) {
var target, user,
_this = this;
diff --git a/static/js/app/lib/controller.coffee b/static/js/app/lib/controller.coffee
index 296cdb3..3f7a617 100755
--- a/static/js/app/lib/controller.coffee
+++ b/static/js/app/lib/controller.coffee
@@ -40,6 +40,7 @@ define ['app', 'marionette', 'vent', 'utils'
app.contentRegion.show(new MixDetailView({model: mix}))
)
Backbone.history.navigate "/random", trigger: false
+
uploadMix: ->
console.log("Controller: mixUpload")
app = require('app')
diff --git a/static/js/app/lib/controller.js b/static/js/app/lib/controller.js
index f3d5883..247fe7d 100755
--- a/static/js/app/lib/controller.js
+++ b/static/js/app/lib/controller.js
@@ -1,64 +1,78 @@
-// Generated by CoffeeScript 1.6.2
+// Generated by CoffeeScript 1.4.0
(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', 'vent', 'models/mix/mixItem', 'views/mix/mixListLayout', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView', 'views/user/userProfileView', 'models/user/userItem', 'views/user/userListView', 'views/user/userEditView'], function(App, Marionette, vent, MixItem, MixListLayout, MixListView, MixDetailView, MixEditView, UserProfileView, UserItem, UserListView, UserEditView) {
- var DssController, _ref;
-
+ define(['app', 'marionette', 'vent', 'utils', 'views/mix/mixListLayout', 'views/mix/mixListView', 'views/mix/mixDetailView', 'views/mix/mixEditView', 'views/user/userProfileView', 'views/user/userListView', 'views/user/userEditView', 'models/mix/mixItem', 'models/mix/mixCollection', 'models/user/userItem'], function(App, Marionette, vent, utils, MixListLayout, MixListView, MixDetailView, MixEditView, UserProfileView, UserListView, UserEditView, MixItem, MixCollection, UserItem) {
+ 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.initialize = function() {
+ return this.listenTo(vent, "mix:random", this.showRandomMix);
+ };
+
DssController.prototype.home = function() {
console.log("Controller: home");
- this.showMixList();
- return true;
+ return this.showMixList();
};
DssController.prototype.showMixList = function(options) {
var app;
-
app = require('app');
- app.contentRegion.show(new MixListLayout(options || {
+ return app.contentRegion.show(new MixListLayout(options || {
order_by: 'latest'
}));
- return true;
};
DssController.prototype.showMixListType = function(type) {
- this.showMixList({
+ return this.showMixList({
order_by: type
});
- return true;
};
DssController.prototype.showMix = function(slug) {
var app, mix;
-
console.log("Controller: showMix");
app = require('app');
mix = new MixItem({
id: slug
});
- mix.fetch({
+ return mix.fetch({
success: function() {
- app.contentRegion.show(new MixDetailView({
+ return app.contentRegion.show(new MixDetailView({
model: mix
}));
- return true;
}
});
- return true;
+ };
+
+ DssController.prototype.showRandomMix = function() {
+ var app, mix;
+ console.log("Controller: showRandomMix");
+ app = require('app');
+ mix = new MixItem({
+ id: 'random'
+ });
+ mix.fetch({
+ success: function() {
+ return app.contentRegion.show(new MixDetailView({
+ model: mix
+ }));
+ }
+ });
+ return Backbone.history.navigate("/random", {
+ trigger: false
+ });
};
DssController.prototype.uploadMix = function() {
var app, mix;
-
console.log("Controller: mixUpload");
app = require('app');
mix = new MixItem({
@@ -75,7 +89,6 @@
DssController.prototype.editMix = function(slug) {
var app, mix;
-
console.log("Controller: mixEdit");
app = require('app');
mix = new MixItem({
@@ -93,7 +106,6 @@
DssController.prototype.showChat = function() {
var app;
-
console.log("Controller: showChat");
app = require('app');
return app.contentRegion.show(new ChatView());
@@ -101,7 +113,6 @@
DssController.prototype.showUserList = function() {
var app;
-
console.log("Controller: showUserList");
app = require('app');
return app.contentRegion.show(new UserListView());
@@ -109,7 +120,6 @@
DssController.prototype.showUserProfile = function(slug) {
var app, user;
-
console.log("Controller: showUserProfile");
app = require('app');
user = new UserItem({
@@ -153,7 +163,6 @@
DssController.prototype.showUserFollowing = function(slug) {
var app;
-
console.log("Controller: showUserFollowing");
app = require('app');
return app.contentRegion.show(new UserListView({
@@ -163,7 +172,6 @@
DssController.prototype.showUserFollowers = function(slug) {
var app;
-
console.log("Controller: showUserFollowers");
app = require('app');
return app.contentRegion.show(new UserListView({
@@ -173,7 +181,6 @@
DssController.prototype.editUser = function() {
var app, user;
-
console.log("Controller: editUser");
app = require('app');
user = new UserItem({
diff --git a/static/js/app/lib/realtimeController.coffee b/static/js/app/lib/realtimeController.coffee
index 833c1a9..3cc42f5 100644
--- a/static/js/app/lib/realtimeController.coffee
+++ b/static/js/app/lib/realtimeController.coffee
@@ -3,9 +3,17 @@ define ['vent', 'socket.io'],
class RealtimeController
startSocketIO: ->
console.log("RealtimeController: SocketIO starting on " + com.podnoms.settings.REALTIME_HOST)
- @socket = SocketIO.connect(com.podnoms.settings.REALTIME_HOST)
- @socket.on "hello", (data) =>
- console.log("RealtimeController: Connected " + data['message'])
+ @socket = SocketIO.connect(com.podnoms.settings.REALTIME_HOST);
+
+ @socket.on 'connect', ->
+ console.log("RealtimeController: Socket connected")
+ @socket.emit('client-reg', {sessionId: com.podnoms.settings.currentUser, userName: com.podnoms.settings.userName})
+
+ @socket.on "server-session", (data) =>
+ if data
+ console.log("RealtimeController: Connected " + data['sessionId'])
+ else
+ console.log("RealtimeController: Can't read sessionId from socket")
"""
@socket.on "activity", (data) =>
diff --git a/static/js/app/lib/realtimeController.js b/static/js/app/lib/realtimeController.js
index 15b659d..64b0c3c 100644
--- a/static/js/app/lib/realtimeController.js
+++ b/static/js/app/lib/realtimeController.js
@@ -11,8 +11,20 @@
var _this = this;
console.log("RealtimeController: SocketIO starting on " + com.podnoms.settings.REALTIME_HOST);
this.socket = SocketIO.connect(com.podnoms.settings.REALTIME_HOST);
- this.socket.on("hello", function(data) {
- return console.log("RealtimeController: Connected " + data['message']);
+ this.socket.on('connect', function() {
+ var _this = this;
+ console.log("RealtimeController: Socket connected");
+ this.socket.emit('client-reg', {
+ sessionId: com.podnoms.settings.currentUser,
+ userName: com.podnoms.settings.userName
+ });
+ return this.socket.on("server-session", function(data) {
+ if (data) {
+ return console.log("RealtimeController: Connected " + data['sessionId']);
+ } else {
+ return console.log("RealtimeController: Can't read sessionId from socket");
+ }
+ });
});
"@socket.on \"activity\", (data) =>\n console.log(\"RealtimeController: activity \" + data['message'])\n vent.trigger(\"model:activity:new\", data['message'])";
diff --git a/static/js/app/lib/router.coffee b/static/js/app/lib/router.coffee
index 69634ba..b07658e 100755
--- a/static/js/app/lib/router.coffee
+++ b/static/js/app/lib/router.coffee
@@ -13,6 +13,7 @@ define ['marionette', 'vent', 'app.lib/controller'],
"mix/edit/:slug": "editMix",
"chat": "showChat",
+ #"random": "showRandomMix",
"users": "showUserList"
"user/:slug/favourites": "showUserFavourites"
diff --git a/static/js/app/lib/social.js b/static/js/app/lib/social.js
index e69de29..27750a0 100644
--- a/static/js/app/lib/social.js
+++ b/static/js/app/lib/social.js
@@ -0,0 +1,51 @@
+// Generated by CoffeeScript 1.4.0
+(function() {
+
+ define(['jquery', 'utils', 'facebook'], function($, utils) {
+ return {
+ postFacebookLike: function(mixId) {
+ return $.getJSON("social/like/" + mixId + "/", function(data) {
+ return com.podnoms.utils.showAlert("Posted your like to facebook, you can stop this in your settings page.", "Cheers feen");
+ });
+ },
+ generateEmbedCode: function(model) {
+ console.log("Generating embed code");
+ return utils.modal("/dlg/embed/" + model.get('slug'));
+ },
+ sharePageToTwitter: function(model) {
+ var loc, title;
+ loc = $(this).attr("href");
+ title = $(this).attr("title");
+ return window.open("http://twitter.com/share?url=" + "http://" + window.location.host + "/" + model.get("item_url") + "&text=" + model.get("title"), "twitterwindow", "height=450, width=550, top=" + ($(window).height() / 2 - 225) + ", left=" + $(window).width() / 2 + ", toolbar=0, location=0, menubar=0, directories=0, scrollbars=0");
+ },
+ sharePageToFacebook: function(model) {
+ FB.init({
+ appId: '154504534677009',
+ xfbml: true
+ });
+ return FB.getLoginStatus(function(oResponse) {
+ if (oResponse.status === "connected") {
+ return FB.ui({
+ method: "feed",
+ name: "Check out this mix on Deep South Sounds",
+ display: "popup",
+ link: "http://" + window.location.host + "/" + model.get("item_url"),
+ picture: com.podnoms.settings.staticUrl + model.get("mix_image"),
+ caption: model.get("title"),
+ description: model.get("description")
+ }, function(response) {
+ if (response && response.post_id) {
+ return utils.showAlert("Success", "Post shared to facebook");
+ } else {
+ return utils.showError("Error", "Failure sharing post");
+ }
+ });
+ } else {
+ return utils.showError("Error", "Failure sharing post");
+ }
+ });
+ }
+ };
+ });
+
+}).call(this);
diff --git a/static/js/app/lib/utils.coffee b/static/js/app/lib/utils.coffee
index 289edc1..4e91828 100755
--- a/static/js/app/lib/utils.coffee
+++ b/static/js/app/lib/utils.coffee
@@ -5,6 +5,26 @@ define ['jquery', 'bootstrap', 'toastr'], ($, bootstrap, toastr) ->
$(url).modal "open"
else
$.get(url,(data) ->
+ $(data).modal().on "hidden", ->
+ $(this).remove()
+ true
+ $(data).proceed().on "hidden", ->
+ alert("Go on so")
+ true
+ ).success ->
+ $("input:text:visible:first").focus()
+ true
+ true
+
+ messageBox: (url) ->
+ if url
+ if url.indexOf("#") is 0
+ $(url).modal "open"
+ else
+ $.get(url,(data) ->
+ $("#yes-no-positive", data).click ->
+ alert("Oh yes")
+
$(data).modal().on "hidden", ->
$(this).remove()
true
diff --git a/static/js/app/lib/utils.js b/static/js/app/lib/utils.js
index 5b2e648..ff2aed9 100755
--- a/static/js/app/lib/utils.js
+++ b/static/js/app/lib/utils.js
@@ -1,5 +1,6 @@
-// Generated by CoffeeScript 1.6.2
+// Generated by CoffeeScript 1.4.0
(function() {
+
define(['jquery', 'bootstrap', 'toastr'], function($, bootstrap, toastr) {
return {
modal: function(url) {
@@ -8,6 +9,31 @@
$(url).modal("open");
} else {
$.get(url, function(data) {
+ $(data).modal().on("hidden", function() {
+ $(this).remove();
+ return true;
+ });
+ return $(data).proceed().on("hidden", function() {
+ alert("Go on so");
+ return true;
+ });
+ }).success(function() {
+ $("input:text:visible:first").focus();
+ return true;
+ });
+ }
+ }
+ return true;
+ },
+ messageBox: function(url) {
+ if (url) {
+ if (url.indexOf("#") === 0) {
+ $(url).modal("open");
+ } else {
+ $.get(url, function(data) {
+ $("#yes-no-positive", data).click(function() {
+ return alert("Oh yes");
+ });
return $(data).modal().on("hidden", function() {
$(this).remove();
return true;
@@ -22,7 +48,6 @@
},
checkPlayCount: function() {
var _this = this;
-
if (document.cookie.indexOf("sessionId")) {
$.getJSON("/ajax/session_play_count", function(data) {
console.log("utils: got playcount");
@@ -48,7 +73,6 @@
generateGuid: function() {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
var r, v;
-
r = Math.random() * 16 | 0;
v = (c === "x" ? r : r & 0x3 | 0x8);
return v.toString(16);
@@ -56,7 +80,6 @@
},
downloadURL: function(url) {
var iframe;
-
iframe = document.getElementById("hiddenDownloader");
if (iframe === null) {
iframe = document.createElement("iframe");
diff --git a/static/js/app/models/mix/mixCollection.coffee b/static/js/app/models/mix/mixCollection.coffee
index eb922bd..3f96151 100755
--- a/static/js/app/models/mix/mixCollection.coffee
+++ b/static/js/app/models/mix/mixCollection.coffee
@@ -2,6 +2,6 @@ define ['backbone', 'models/mix/mixItem', 'app.lib/backbone.dss.model.collection
(Backbone, MixItem, DssCollection) ->
class MixCollection extends DssCollection
model: MixItem
- url:com.podnoms.settings.urlRoot + "mix/"
+ url:com.podnoms.settings.urlRoot + "mix/?limit=5"
MixCollection
diff --git a/static/js/app/models/mix/mixCollection.js b/static/js/app/models/mix/mixCollection.js
index ab486b1..72f8bfc 100755
--- a/static/js/app/models/mix/mixCollection.js
+++ b/static/js/app/models/mix/mixCollection.js
@@ -15,7 +15,7 @@
MixCollection.prototype.model = MixItem;
- MixCollection.prototype.url = com.podnoms.settings.urlRoot + "mix/";
+ MixCollection.prototype.url = com.podnoms.settings.urlRoot + "mix/?limit=5";
return MixCollection;
diff --git a/static/js/app/views/mix/mixEditView.js b/static/js/app/views/mix/mixEditView.js
index 2b04aa5..54a1734 100755
--- a/static/js/app/views/mix/mixEditView.js
+++ b/static/js/app/views/mix/mixEditView.js
@@ -1,4 +1,4 @@
-// Generated by CoffeeScript 1.3.3
+// Generated by CoffeeScript 1.4.0
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
diff --git a/static/js/app/views/mix/mixItemView.coffee b/static/js/app/views/mix/mixItemView.coffee
index 6432c4a..0fbd660 100755
--- a/static/js/app/views/mix/mixItemView.coffee
+++ b/static/js/app/views/mix/mixItemView.coffee
@@ -16,6 +16,7 @@ define ['moment', 'app', 'vent', 'marionette', 'utils',
"click .play-button-small-resume": "doResume",
"click .play-button-small-pause": "doPause",
"click .mix-link": "mixLink",
+ "click .delete-button a": "mixDelete",
"click .like-button a": "mixLike",
"click .favourite-button a": "mixFavourite",
"click .share-button": "mixShare",
@@ -119,6 +120,10 @@ define ['moment', 'app', 'vent', 'marionette', 'utils',
vent.trigger("mix:favourite", @model)
true
+ mixDelete: ->
+ console.log("MixItemView: mixDelete")
+ vent.trigger("mix:delete", @model)
+
mixLike: ->
console.log("MixItemView: likeMix")
vent.trigger("mix:like", @model)
diff --git a/static/js/app/views/mix/mixItemView.js b/static/js/app/views/mix/mixItemView.js
index 3a631f6..bfe7994 100755
--- a/static/js/app/views/mix/mixItemView.js
+++ b/static/js/app/views/mix/mixItemView.js
@@ -34,6 +34,7 @@
"click .play-button-small-resume": "doResume",
"click .play-button-small-pause": "doPause",
"click .mix-link": "mixLink",
+ "click .delete-button a": "mixDelete",
"click .like-button a": "mixLike",
"click .favourite-button a": "mixFavourite",
"click .share-button": "mixShare",
@@ -143,6 +144,11 @@
return true;
};
+ MixItemView.prototype.mixDelete = function() {
+ console.log("MixItemView: mixDelete");
+ return vent.trigger("mix:delete", this.model);
+ };
+
MixItemView.prototype.mixLike = function() {
console.log("MixItemView: likeMix");
vent.trigger("mix:like", this.model);
diff --git a/static/js/app/views/user/userEditView.js b/static/js/app/views/user/userEditView.js
index e69de29..6f1647a 100755
--- a/static/js/app/views/user/userEditView.js
+++ b/static/js/app/views/user/userEditView.js
@@ -0,0 +1,111 @@
+// Generated by CoffeeScript 1.4.0
+(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', 'toastr', 'app.lib/editableView', 'moment', 'utils', 'backbone.syphon', 'text!/tpl/UserEditView'], function(App, toastr, EditableView, moment, utils, Syphon, Template) {
+ var UserEditView;
+ UserEditView = (function(_super) {
+
+ __extends(UserEditView, _super);
+
+ function UserEditView() {
+ return UserEditView.__super__.constructor.apply(this, arguments);
+ }
+
+ UserEditView.prototype.template = _.template(Template);
+
+ UserEditView.prototype.events = {
+ "click #save-changes": "saveChanges",
+ "change input[type=radio]": "selectAvatar"
+ };
+
+ UserEditView.prototype.onRender = function() {
+ var avatarType;
+ console.log("MixEditView: onRender");
+ avatarType = this.model.get('avatar_type');
+ $('#avatar_' + avatarType, this.el).attr('checked', true);
+ if (avatarType === "custom") {
+ $("#div_avatar_image_upload", this.el).show();
+ } else {
+ $("#div_avatar_image_upload", this.el).hide();
+ }
+ return true;
+ };
+
+ UserEditView.prototype.selectAvatar = function(evt) {
+ var type;
+ type = $(evt.currentTarget).val();
+ this.model.set("avatar_type", type);
+ if (type === "custom") {
+ return $("#custom_avatar_helptext", this.el).show();
+ } else {
+ return $("#custom_avatar_helptext", this.el).hide();
+ }
+ };
+
+ UserEditView.prototype.saveChanges = function() {
+ var data, ref;
+ data = Backbone.Syphon.serialize(this);
+ this.model.set(data);
+ ref = this;
+ this._saveChanges({
+ success: function() {
+ var _this = this;
+ if (ref.model.get('avatar_type') === "custom") {
+ $.ajaxFileUpload({
+ url: "ajax/upload_avatar_image/",
+ secureuri: false,
+ fileElementId: "mix_image",
+ success: function(data, status) {
+ if (typeof data.error !== "undefined") {
+ if (data.error !== "") {
+ return alert(data.error);
+ } else {
+ return alert(data.msg);
+ }
+ } else {
+ $("#mix-details", _this.el).hide();
+ return Backbone.history.navigate("/", {
+ trigger: true
+ });
+ }
+ },
+ error: function(data, status, e) {
+ return utils.showError(e);
+ }
+ });
+ this.uploadImage({
+ el: $('#avatar_image'),
+ success: function() {
+ utils.showMessage("Successfully updated yourself");
+ return Backbone.history.navigate("/", {
+ trigger: true
+ });
+ }
+ });
+ } else {
+ toastr.info("Successfully updated yourself");
+ Backbone.history.navigate("/", {
+ trigger: true
+ });
+ }
+ return true;
+ },
+ error: function() {
+ toastr.error("There was an error updating your info. Please try again later.");
+ return true;
+ }
+ });
+ return true;
+ };
+
+ false;
+
+ return UserEditView;
+
+ })(EditableView);
+ return UserEditView;
+ });
+
+}).call(this);
diff --git a/static/js/app/views/widgets/headerView.coffee b/static/js/app/views/widgets/headerView.coffee
index 104e183..6d24c9b 100755
--- a/static/js/app/views/widgets/headerView.coffee
+++ b/static/js/app/views/widgets/headerView.coffee
@@ -16,6 +16,7 @@ define ["underscore", "marionette", "vent", "utils", "views/widgets/searchView",
template: _.template(Template)
className: "navbar navbar-default"
events:
+ "click #header-random-button": "showRandom"
"click #header-play-pause-button": "togglePlayState"
"click #header-login-button": "login"
"click #header-donate-button": "donate"
@@ -40,11 +41,14 @@ define ["underscore", "marionette", "vent", "utils", "views/widgets/searchView",
if com.podnoms.settings.currentUser != -1
@notificationsRegion.show(new NotificationsListView())
+ showRandom: ->
+ console.log("headerView: showRandom")
+ vent.trigger("mix:random")
+
login: ->
vent.trigger('app:login')
donate: ->
- console.log("headerView: donate")
vent.trigger('app:donate')
logout: ->
diff --git a/static/js/app/views/widgets/headerView.js b/static/js/app/views/widgets/headerView.js
index 8922cb3..6bb2cee 100644
--- a/static/js/app/views/widgets/headerView.js
+++ b/static/js/app/views/widgets/headerView.js
@@ -36,6 +36,7 @@ Code provided under the BSD License:
HeaderView.prototype.className = "navbar navbar-default";
HeaderView.prototype.events = {
+ "click #header-random-button": "showRandom",
"click #header-play-pause-button": "togglePlayState",
"click #header-login-button": "login",
"click #header-donate-button": "donate",
@@ -67,12 +68,16 @@ Code provided under the BSD License:
}
};
+ HeaderView.prototype.showRandom = function() {
+ console.log("headerView: showRandom");
+ return vent.trigger("mix:random");
+ };
+
HeaderView.prototype.login = function() {
return vent.trigger('app:login');
};
HeaderView.prototype.donate = function() {
- console.log("headerView: donate");
return vent.trigger('app:donate');
};
diff --git a/static/js/lib/ace.js b/static/js/lib/ace.js
index 22d20a0..7d5d1c1 100644
--- a/static/js/lib/ace.js
+++ b/static/js/lib/ace.js
@@ -4,31 +4,6 @@ jQuery(function($) {
window['ace'].click_event = $.fn.tap ? "tap" : "click";
});
-jQuery(function($) {
- //ace.click_event defined in ace-elements.js
- ace.handle_side_menu(jQuery);
-
- ace.enable_search_ahead(jQuery);
-
- ace.general_things(jQuery);//and settings
-
- ace.widget_boxes(jQuery);
- ace.widget_reload_handler(jQuery);//this is for demo only, you can remove and have your own function, please see examples/widget.html
-
- /**
- //make sidebar scrollbar when it is fixed and some parts of it is out of view
- //>> you should include jquery-ui and slimscroll javascript files in your file
- //>> you can call this function when sidebar is clicked to be fixed
- $('.nav-list').slimScroll({
- height: '400px',
- distance:0,
- size : '6px'
- });
- */
-});
-
-
-
ace.handle_side_menu = function($) {
$('#menu-toggler').on(ace.click_event, function() {
$('#sidebar').toggleClass('display');
@@ -183,7 +158,7 @@ ace.general_things = function($) {
}
});
-}
+};
@@ -212,7 +187,7 @@ ace.widget_boxes = function($) {
}
});
- })
+ });
$(document).on('click.ace.widget', '[data-action]', function (ev) {
@@ -291,7 +266,7 @@ ace.widget_boxes = function($) {
}
});
-}
+};
ace.widget_reload_handler = function($) {
@@ -315,7 +290,7 @@ ace.widget_reload_handler = function($) {
$(this).trigger('reloaded.ace.widget');
});
*/
-}
+};
@@ -332,7 +307,7 @@ ace.enable_search_ahead = function($) {
}
});
} catch(e) {}
-}
+};
@@ -384,4 +359,28 @@ ace.switch_direction = function($) {
var pos = $(document.body).hasClass('rtl') ? 'nw' : 'ne';//draw on north-west or north-east?
placeholder.data('draw').call(placeholder.get(0) , placeholder, placeholder.data('chart'), pos);
}
-}
+};
+
+jQuery(function($) {
+ //ace.click_event defined in ace-elements.js
+ ace.handle_side_menu(jQuery);
+
+ ace.enable_search_ahead(jQuery);
+
+ ace.general_things(jQuery);//and settings
+
+ ace.widget_boxes(jQuery);
+ ace.widget_reload_handler(jQuery);//this is for demo only, you can remove and have your own function, please see examples/widget.html
+
+ /**
+ //make sidebar scrollbar when it is fixed and some parts of it is out of view
+ //>> you should include jquery-ui and slimscroll javascript files in your file
+ //>> you can call this function when sidebar is clicked to be fixed
+ $('.nav-list').slimScroll({
+ height: '400px',
+ distance:0,
+ size : '6px'
+ });
+ */
+});
+
diff --git a/static/js/main.js b/static/js/main.js
index 72f1100..d9278c2 100644
--- a/static/js/main.js
+++ b/static/js/main.js
@@ -22,7 +22,7 @@ requirejs.config({
ace: 'lib/ace',
wysiwyg: 'lib/bootstrap-wysiwyg',
'ace-editable': 'lib/ace-editable',
- //'facebook': '//connect.facebook.net/en_US/all',
+ 'facebook': '//connect.facebook.net/en_US/all',
/*File upload */
/*TOOD: Move this to a shim */
@@ -61,10 +61,10 @@ requirejs.config({
bootstrap: {
exports: 'bootstrap',
deps: ['jquery']
- }/*,
+ },
'facebook': {
export: 'FB'
- }*/,
+ },
'ace': {
exports: 'ace',
deps: ['jquery', 'lib/ace-elements', 'lib/ace-extra']
diff --git a/templates/views/HeaderView.html b/templates/views/HeaderView.html
index cb5c942..5032a92 100755
--- a/templates/views/HeaderView.html
+++ b/templates/views/HeaderView.html
@@ -9,8 +9,10 @@
-
<% } %>
diff --git a/templates/views/dlg/DeleteMixConfirm.html b/templates/views/dlg/DeleteMixConfirm.html
new file mode 100644
index 0000000..1b16bdb
--- /dev/null
+++ b/templates/views/dlg/DeleteMixConfirm.html
@@ -0,0 +1,18 @@
+{% extends 'views/dlg/_DialogBase.html' %}
+
+{% load account %}
+{% load static %}
+{% load socialaccount %}
+{% block header %}
+ You sure about this chief??
+{% endblock %}
+{% block content %}
+ Hit Proceed here and your mix is gone.
+ Comments, likes, favourites, all gone, never to return.
+{% endblock %}
+{% block primarybutton %}Cancel{% endblock %}
+{% block extrabuttons %}
+
+ Proceed
+
+{% endblock %}
\ No newline at end of file
diff --git a/templates/views/dlg/Donate.html b/templates/views/dlg/Donate.html
index 97bdb86..925cba1 100644
--- a/templates/views/dlg/Donate.html
+++ b/templates/views/dlg/Donate.html
@@ -48,4 +48,4 @@
{% endblock %}
-{% block primarybutton %}Another time...{% endblock %}
\ No newline at end of file
+{% block positivebutton %}Another time...{% endblock %}
\ No newline at end of file
diff --git a/templates/views/dlg/EmbedCodes.html b/templates/views/dlg/EmbedCodes.html
index f8e50b1..0a61a11 100644
--- a/templates/views/dlg/EmbedCodes.html
+++ b/templates/views/dlg/EmbedCodes.html
@@ -22,4 +22,4 @@
{% endblock %}
-{% block primarybutton %}Got it...{% endblock %}
\ No newline at end of file
+{% block positivebutton %}Got it...{% endblock %}
\ No newline at end of file
diff --git a/templates/views/dlg/LoginView.html b/templates/views/dlg/LoginView.html
index 9b2224f..91b4403 100644
--- a/templates/views/dlg/LoginView.html
+++ b/templates/views/dlg/LoginView.html
@@ -28,4 +28,4 @@
Please note that using a social account
does not give us access to your private information
{% endblock %}
-{% block primarybutton %}Nah...{% endblock %}
\ No newline at end of file
+{% block positivebutton %}Nah...{% endblock %}
\ No newline at end of file
diff --git a/templates/views/dlg/PlayCountLoginAlert.html b/templates/views/dlg/PlayCountLoginAlert.html
index 9ff1905..7affae4 100755
--- a/templates/views/dlg/PlayCountLoginAlert.html
+++ b/templates/views/dlg/PlayCountLoginAlert.html
@@ -26,4 +26,4 @@
{% endblock %}
-{% block primarybutton %}Okies...{% endblock %}
\ No newline at end of file
+{% block positivebutton %}Okies...{% endblock %}
\ No newline at end of file