mirror of
https://github.com/fergalmoran/dss.git
synced 2025-12-22 09:38:18 +00:00
Fixed up some sharing and changed mix limit to 100 (MUST CHANGE)
This commit is contained in:
@@ -7,7 +7,7 @@ from tastypie.exceptions import ImmediateHttpResponse
|
||||
from tastypie.http import HttpUnauthorized
|
||||
from tastypie.utils import trailing_slash
|
||||
from spa.api.v1.BackboneCompatibleResource import BackboneCompatibleResource
|
||||
from spa.models import Playlist, Mix
|
||||
from spa.models import Playlist, Mix, UserProfile
|
||||
|
||||
|
||||
class PlaylistResource(BackboneCompatibleResource):
|
||||
@@ -46,6 +46,15 @@ class PlaylistResource(BackboneCompatibleResource):
|
||||
bundle.obj.user = bundle.request.user.get_profile()
|
||||
return bundle
|
||||
|
||||
def dehydrate(self, bundle):
|
||||
try:
|
||||
bundle.data['playlist_image'] = bundle.obj.mixes.objects.all()[0].get_image_url()
|
||||
except:
|
||||
bundle.data['playlist_image'] = UserProfile.get_default_avatar_image()
|
||||
|
||||
bundle.data['item_url'] = '/playlist/%s' % bundle.obj.slug
|
||||
return bundle
|
||||
|
||||
def obj_update(self, bundle, skip_errors=False, **kwargs):
|
||||
mixes = bundle.data['mixes']
|
||||
bundle.data.pop('mixes')
|
||||
|
||||
@@ -775,9 +775,10 @@ img.mix-listing-image {
|
||||
|
||||
.playlist-functions {
|
||||
position: absolute;
|
||||
top: 8px;
|
||||
top: 16px;
|
||||
right: 0;
|
||||
}
|
||||
.share-button{
|
||||
|
||||
.btn-group a{
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -116,6 +116,15 @@
|
||||
|
||||
true
|
||||
|
||||
@listenTo @vent, "playlist:share", (mode, model) ->
|
||||
console.log "App(vent): playlist:share (" + mode + ")"
|
||||
if (mode == "facebook")
|
||||
social.sharePlaylistToFacebook(model)
|
||||
else if (mode == "twitter")
|
||||
social.sharePlaylistToTwitter(model)
|
||||
|
||||
true
|
||||
|
||||
App.on "start", ->
|
||||
if Backbone.history
|
||||
Backbone.history.start
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
class Models.MixCollection extends Backbone.Collection
|
||||
model: Models.MixItem
|
||||
url:com.podnoms.settings.urlRoot + "mix/?limit=10"
|
||||
url:com.podnoms.settings.urlRoot + "mix/?limit=100"
|
||||
|
||||
Models.MixCollection
|
||||
@@ -4,7 +4,14 @@
|
||||
|
||||
events:
|
||||
"click #playlist-rss-feed": "showPlaylistRssFeed"
|
||||
"click .share-button": "playlistShare",
|
||||
|
||||
|
||||
showPlaylistRssFeed: (e) ->
|
||||
window.open("/podcast/playlist?type=playlist&name=" + @model.get("name"))
|
||||
|
||||
playlistShare: (e) ->
|
||||
mode = $(e.currentTarget).data("mode");
|
||||
console.log("PlaylistDetailHeaderView: " + mode)
|
||||
App.vent.trigger("playlist:share", mode, @model)
|
||||
|
||||
|
||||
@@ -11,21 +11,25 @@
|
||||
utils.modal "/dlg/embed/" + model.get('slug')
|
||||
|
||||
sharePageToTwitter: (model) ->
|
||||
|
||||
#We get the URL of the link
|
||||
loc = $(this).attr("href")
|
||||
|
||||
#We get the title of the link
|
||||
title = $(this).attr("title")
|
||||
url = "http://" + window.location.host + model.get("item_url")
|
||||
text = model.get("title")
|
||||
window.open "http://twitter.com/share?url=#{url}&text={#text}", "twitterwindow", "height=450, width=550, top=" + ($(window).height() / 2 - 225) + ", left=" + $(window).width() / 2 + ", toolbar=0, location=0, menubar=0, directories=0, scrollbars=0"
|
||||
|
||||
#We trigger a new window with the Twitter dialog, in the middle of the page
|
||||
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"
|
||||
sharePlaylistToTwitter: (model) ->
|
||||
url = "http://" + window.location.host + model.get("item_url")
|
||||
text = model.get("name")
|
||||
window.open "http://twitter.com/share?url=#{url}&text={#text}", "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: (model) ->
|
||||
_initFacebook: ->
|
||||
FB.init({
|
||||
appId : '154504534677009',
|
||||
xfbml : true
|
||||
});
|
||||
|
||||
sharePageToFacebook: (model) ->
|
||||
@_initFacebook()
|
||||
|
||||
FB.getLoginStatus (oResponse) ->
|
||||
if oResponse.status is "connected"
|
||||
FB.ui
|
||||
@@ -42,3 +46,20 @@
|
||||
else
|
||||
utils.showError "Error", "Failure sharing post"
|
||||
|
||||
sharePlaylistToFacebook: (model) ->
|
||||
@_initFacebook()
|
||||
FB.getLoginStatus (oResponse) ->
|
||||
if oResponse.status is "connected"
|
||||
FB.ui
|
||||
method: "feed"
|
||||
name: "Check out this playlist on Deep South Sounds"
|
||||
display: "iframe"
|
||||
link: "http://" + window.location.host + "/" + model.get("item_url")
|
||||
picture: model.get("playlist_image")
|
||||
caption: model.get("name")
|
||||
description: model.get("name")
|
||||
, (response) ->
|
||||
if response and response.post_id
|
||||
utils.showAlert "Success", "Post shared to facebook"
|
||||
else
|
||||
utils.showError "Error", "Failure sharing post"
|
||||
|
||||
@@ -2,17 +2,22 @@
|
||||
<h1>
|
||||
<%= name %>
|
||||
</h1>
|
||||
|
||||
<div class="pull-right playlist-functions">
|
||||
<div class="btn-toolbar inline middle no-margin">
|
||||
<div data-toggle="buttons" class="btn-group no-margin">
|
||||
<button class="btn btn-white btn-info btn-bold" id="playlist-rss-feed">
|
||||
<i class="ace-icon fa fa-rss bigger-120 blue"></i>
|
||||
Podcast
|
||||
</button>
|
||||
<button class="btn btn-white btn-warning btn-bold">
|
||||
<i class="ace-icon fa fa-trash-o bigger-120 orange"></i>
|
||||
Delete
|
||||
</button>
|
||||
<div class="footer-button">
|
||||
<div class="btn-group">
|
||||
<a data-mode="facebook" class="share-button">
|
||||
<i class="ace-icon fa fa-facebook-square text-primary bigger-180"></i>
|
||||
</a>
|
||||
<a data-mode="twitter" class="share-button">
|
||||
<i class="ace-icon fa fa-twitter-square light-blue bigger-180"></i>
|
||||
</a>
|
||||
<a data-bypass="true" target="_blank" href="/podcast/playlist?type=playlist&name=<%= name %>">
|
||||
<i class="ace-icon fa fa-rss light-orange bigger-180"></i>
|
||||
</a>
|
||||
<a data-mode="delete">
|
||||
<i class="ace-icon fa fa-trash-o red2 bigger-180"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user