VRFS-986 landing page dev complete

This commit is contained in:
Brian Smith 2014-01-28 02:35:35 -05:00
parent 40a8dbd89e
commit 374a9da957
10 changed files with 226 additions and 41 deletions

View File

@ -7,7 +7,7 @@ module JamRuby
default_scope order('created_at DESC')
belongs_to :music_session, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id"
belongs_to :music_session_history, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id"
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "creator_id"
end

View File

@ -3,7 +3,7 @@ module JamRuby
self.table_name = "music_sessions_history"
self.primary_key = 'id'
self.primary_key = 'music_session_id'
belongs_to(:user,
:class_name => 'JamRuby::User',

View File

@ -5,7 +5,7 @@ module JamRuby
self.primary_key = 'id'
belongs_to :music_session, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id"
belongs_to :music_session_history, :class_name => "JamRuby::MusicSessionHistory", :foreign_key => "music_session_id"
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "liker_id"
end

View File

@ -35,7 +35,6 @@
}
function updateSession(id, newSession, onSuccess) {
logger.debug('Rest.updateSession');
return $.ajax('/api/sessions/' + id, {
type: "PUT",
data : newSession,
@ -44,6 +43,56 @@
});
}
function addSessionComment(sessionId, userId, comment) {
return $.ajax({
url: '/api/sessions/' + sessionId + "/comments",
type: "POST",
data : JSON.stringify({"comment": comment, "user_id": userId}),
dataType : 'json',
contentType: 'application/json'
});
}
function addSessionLike(sessionId, userId) {
return $.ajax({
url: '/api/sessions/' + sessionId + "/likes",
type: "POST",
data : JSON.stringify({"user_id": userId}),
dataType : 'json',
contentType: 'application/json'
});
}
function addRecordingComment(recordingId, userId, comment) {
return $.ajax({
url: '/api/recordings/' + recordingId + "/comments",
type: "POST",
data : JSON.stringify({"comment": comment, "user_id": userId}),
dataType : 'json',
contentType: 'application/json'
});
}
function addRecordingLike(recordingId, userId) {
return $.ajax({
url: '/api/recordings/' + recordingId + "/likes",
type: "POST",
data : JSON.stringify({"user_id": userId}),
dataType : 'json',
contentType: 'application/json'
});
}
function addRecordingPlay(recordingId, userId) {
return $.ajax({
url: '/api/recordings/' + recordingId + "/plays",
type: "POST",
data : JSON.stringify({"user_id": userId}),
dataType : 'json',
contentType: 'application/json'
});
}
function getBand(bandId) {
return $.ajax({
type: "GET",
@ -705,6 +754,11 @@
this.getBandFollowing = getBandFollowing;
this.getBands = getBands;
this.updateSession = updateSession;
this.addSessionComment = addSessionComment;
this.addSessionLike = addSessionLike;
this.addRecordingComment = addRecordingComment;
this.addRecordingLike = addRecordingLike;
this.addRecordingPlay = addRecordingPlay;
this.getSession = getSession;
this.getClientDownloads = getClientDownloads;
this.createInvitation = createInvitation;

View File

@ -89,7 +89,6 @@ class ApiMusicSessionsController < ApiController
end
def participant_create
@connection = MusicSessionManager.new.participant_create(
current_user,
params[:id],
@ -243,14 +242,17 @@ class ApiMusicSessionsController < ApiController
def add_comment
if params[:id].blank?
render :json => { :message => "Session ID is required" }, :status => 400
return
end
if params[:user_id].blank?
render :json => { :message => "User ID is required" }, :status => 400
return
end
if params[:comment].blank?
render :json => { :message => "Comment is required" }, :status => 400
return
end
comment = MusicSessionComment.new
@ -262,18 +264,17 @@ class ApiMusicSessionsController < ApiController
if comment.errors.any?
render :json => { :message => "Unexpected error occurred" }, :status => 500
return
else
render :json => {}, :status => 201
return
end
end
def add_like
if params[:id].blank?
render :json => { :message => "Session ID is required" }, :status => 400
end
if params[:user_id].blank?
render :json => { :message => "User ID is required" }, :status => 400
return
end
liker = MusicSessionLiker.new
@ -284,8 +285,10 @@ class ApiMusicSessionsController < ApiController
if liker.errors.any?
render :json => { :message => "Unexpected error occurred" }, :status => 500
return
else
render :json => {}, :status => 201
return
end
end

View File

@ -83,14 +83,17 @@ class ApiRecordingsController < ApiController
def add_comment
if params[:id].blank?
render :json => { :message => "Recording ID is required" }, :status => 400
return
end
if params[:user_id].blank?
render :json => { :message => "User ID is required" }, :status => 400
return
end
if params[:comment].blank?
render :json => { :message => "Comment is required" }, :status => 400
return
end
comment = RecordingComment.new
@ -102,18 +105,17 @@ class ApiRecordingsController < ApiController
if comment.errors.any?
render :json => { :message => "Unexpected error occurred" }, :status => 500
return
else
render :json => {}, :status => 201
return
end
end
def add_like
if params[:id].blank?
render :json => { :message => "Recording ID is required" }, :status => 400
end
if params[:user_id].blank?
render :json => { :message => "User ID is required" }, :status => 400
return
end
liker = RecordingLiker.new
@ -124,18 +126,17 @@ class ApiRecordingsController < ApiController
if liker.errors.any?
render :json => { :message => "Unexpected error occurred" }, :status => 500
return
else
render :json => {}, :status => 201
return
end
end
def add_play
if params[:id].blank?
render :json => { :message => "Recording ID is required" }, :status => 400
end
if params[:user_id].blank?
render :json => { :message => "User ID is required" }, :status => 400
return
end
play = RecordingPlay.new
@ -146,8 +147,10 @@ class ApiRecordingsController < ApiController
if play.errors.any?
render :json => { :message => "Unexpected error occurred" }, :status => 500
return
else
render :json => {}, :status => 201
return
end
end

View File

@ -27,14 +27,16 @@
<div class="right f14 grey"><%= @music_session.created_at.strftime("%b %e %Y, %l:%M %p") %></div>
<br clear="all" /><br />
<div class="left w70"><%= @music_session.description %><br /><br /></div>
<div class="right">
<a href="#"><%= image_tag "content/icon_like.png", {:width => 12, :height => 12} %>&nbsp;LIKE</a>&nbsp;&nbsp;&nbsp;
<a href="#"><%= image_tag "content/icon_share.png", {:width => 13, :height => 15} %>&nbsp;SHARE</a>
</div>
<% if @music_session.session_removed_at.blank? %>
<div class="right">
<a id="btnLike"><%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :alt => ""} %>&nbsp;LIKE</a>&nbsp;&nbsp;&nbsp;
<a id="btnShare"><%= image_tag "content/icon_share.png", {:width => 13, :height => 15, :alt => ""} %>&nbsp;SHARE</a>
</div>
<% end %>
<br clear="all" />
<div class="w100">
<div class="recording-controls">
<a class="left mr20" href="#"><%= image_tag "content/icon_playbutton.png", {:width => 20, :height => 20} %></a>
<a class="left mr20" href="#"><%= image_tag "content/icon_playbutton.png", {:width => 20, :height => 20, :alt => ""} %></a>
<% if @music_session.session_removed_at.blank? %>
<div class="session-status">SESSION IN PROGRESS</div>
<div class="recording-current">1:23</div>
@ -45,10 +47,13 @@
<div class="left white"><%= @music_session.genres.split('|').first.capitalize %></div>
<div class="right white">
<%= @music_session.comment_count %>
<%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle", :style => "vertical-align:middle"} %>&nbsp;&nbsp;&nbsp;&nbsp;
<%= @music_session.like_count %>
<%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle", :style => "vertical-align:middle"} %>
<span id="spnCommentCount"><%= @music_session.comment_count %></span>
<%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle", :style => "vertical-align:middle", :alt => ""} %>&nbsp;&nbsp;&nbsp;&nbsp;
<span id="spnLikeCount"><%= @music_session.like_count %></span>
<%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle", :style => "vertical-align:middle", :alt => ""} %>
</div>
</div>
<br clear="all" /><br />
@ -68,9 +73,65 @@
<% content_for :after_black_bar do %>
<br />
<%= render :partial => "shared/comments", :locals => {:comments => @music_session.comments} %>
<%= render :partial => "shared/comments", :locals => {:comments => @music_session.comments, :id => "txtSessionComment"} %>
<% end %>
<%= javascript_include_tag "web/sessions" %>
<%= render "clients/shareDialog" %>
<script type="text/javascript">
$(function () {
JK = JK || {};
<% if current_user %>
JK.currentUserId = '<%= current_user.id %>';
<% else %>
JK.currentUserId = null;
<% end %>
if (JK.currentUserId) {
JK.app = JK.JamKazam();
JK.app.initialize({inClient: false, layoutOpts: {layoutFooter: false}});
var shareDialog = new JK.ShareDialog(JK.app);
shareDialog.initialize();
$("#txtSessionComment").keypress(function(e) {
if (e.which === 13) {
addComment();
}
});
}
else {
$("#txtSessionComment").attr("disabled", "disabled");
$("#txtSessionComment").val("You must be logged in to add a comment.");
}
JK.sessionId = "<%= @music_session.music_session_id %>";
var rest = new JK.Rest();
$("#btnLike").click(like);
function like() {
rest.addSessionLike(JK.sessionId, JK.currentUserId)
.done(function(response) {
$("#spnLikeCount").html(parseInt($("#spnLikeCount").text()) + 1);
$("#btnLike").unbind("click");
});
}
function addComment() {
var comment = $("#txtSessionComment").val();
if ($.trim(comment).length > 0) {
rest.addSessionComment(JK.sessionId, JK.currentUserId, comment)
.done(function(response) {
$("#spnCommentCount").html(parseInt($("#spnCommentCount").text()) + 1);
$(".landing-comment-scroller").prepend(comment);
});
}
}
})
</script>

View File

@ -28,17 +28,17 @@
<br clear="all" /><br />
<h2 class="left"><%= @claimed_recording.name %></h2>
<div class="right">
<a href="#"><%= image_tag "content/icon_like.png", {:width => 12, :height => 12} %>&nbsp;LIKE</a>&nbsp;&nbsp;&nbsp;
<a href="#"><%= image_tag "content/icon_share.png", {:width => 13, :height => 15} %>&nbsp;SHARE</a>
<a id="btnLike"><%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :alt => ""} %>&nbsp;LIKE</a>&nbsp;&nbsp;&nbsp;
<a id="btnShare"><%= image_tag "content/icon_share.png", {:width => 13, :height => 15, :alt => ""} %>&nbsp;SHARE</a>
</div>
<br clear="all" /><%= @claimed_recording.description %><br /><br />
<div class="w100">
<div class="recording-controls">
<a class="left" href="#"><%= image_tag "content/icon_playbutton.png", {:width => 20, :height => 20} %></a>
<a id="btnPlay" class="left"><%= image_tag "content/icon_playbutton.png", {:width => 20, :height => 20, :alt => ""} %></a>
<div class="recording-position">
<div class="recording-time">0:00</div>
<div class="recording-playback">
<div class="recording-slider"><%= image_tag "content/slider_playcontrols.png", {:width => 5, :height => 16} %></div>
<div class="recording-slider"><%= image_tag "content/slider_playcontrols.png", {:width => 5, :height => 16, :alt => ""} %></div>
</div>
<div class="recording-time">4:59</div>
</div>
@ -47,12 +47,12 @@
<div class="left white"><%= @claimed_recording.genre_id.capitalize %></div>
<div class="right white">
<%= @claimed_recording.recording.play_count %>
<%= image_tag "content/icon_arrow.png", {:width => 7, :height => 12, :align => "absmiddle"} %>&nbsp;&nbsp;&nbsp;&nbsp;
<%= @claimed_recording.recording.comment_count %>
<%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle"} %>&nbsp;&nbsp;&nbsp;&nbsp;
<%= @claimed_recording.recording.like_count %>
<%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle"} %>
<span id="spnPlayCount"><%= @claimed_recording.recording.play_count %></span>
<%= image_tag "content/icon_arrow.png", {:width => 7, :height => 12, :align => "absmiddle", :alt => ""} %>&nbsp;&nbsp;&nbsp;&nbsp;
<span id="spnCommentCount"><%= @claimed_recording.recording.comment_count %></span>
<%= image_tag "content/icon_comment.png", {:width => 13, :height => 12, :align => "absmiddle", :alt => ""} %>&nbsp;&nbsp;&nbsp;&nbsp;
<span id="spnLikeCount"><%= @claimed_recording.recording.like_count %></span>
<%= image_tag "content/icon_like.png", {:width => 12, :height => 12, :align => "absmiddle", :alt => ""} %>
</div>
</div>
<br clear="all" /><br />
@ -72,9 +72,73 @@
<% content_for :after_black_bar do %>
<br />
<%= render :partial => "shared/comments", :locals => {:comments => @claimed_recording.recording.comments} %>
<%= render :partial => "shared/comments", :locals => {:comments => @claimed_recording.recording.comments, :id => "txtRecordingComment"} %>
<% end %>
<%= javascript_include_tag "web/recordings" %>
<%= render "clients/shareDialog" %>
<%= render "clients/shareDialog" %>
<script type="text/javascript">
$(function () {
JK = JK || {};
<% if current_user %>
JK.currentUserId = '<%= current_user.id %>';
<% else %>
JK.currentUserId = null;
<% end %>
if (JK.currentUserId) {
JK.app = JK.JamKazam();
JK.app.initialize({inClient: false, layoutOpts: {layoutFooter: false}});
var shareDialog = new JK.ShareDialog(JK.app);
shareDialog.initialize();
$("#txtRecordingComment").keypress(function(e) {
if (e.which === 13) {
addComment();
}
});
}
else {
$("#txtRecordingComment").attr("disabled", "disabled");
$("#txtRecordingComment").val("You must be logged in to add a comment.");
}
JK.recordingId = "<%= @claimed_recording.recording.id %>";
var rest = new JK.Rest();
$("#btnLike").click(like);
$("#btnPlay").click(play);
function like() {
rest.addRecordingLike(JK.recordingId, JK.currentUserId)
.done(function(response) {
$("#spnLikeCount").html(parseInt($("#spnLikeCount").text()) + 1);
$("#btnLike").unbind("click");
});
}
function play() {
rest.addRecordingPlay(JK.recordingId, JK.currentUserId)
.done(function(response) {
$("#spnPlayCount").html(parseInt($("#spnPlayCount").text()) + 1);
});
}
function addComment() {
var comment = $("#txtRecordingComment").val();
if ($.trim(comment).length > 0) {
rest.addRecordingComment(JK.recordingId, JK.currentUserId, comment)
.done(function(response) {
$("#spnCommentCount").html(parseInt($("#spnCommentCount").text()) + 1);
$(".landing-comment-scroller").prepend(comment);
});
}
}
})
</script>

View File

@ -4,7 +4,7 @@
<%= image_tag "shared/avatar_generic.png", {:alt => ""} %>
</div>
<div class="left w80 p10">
<textarea class="w100 p5 f15" rows="2" onfocus="$(this).html('')" onblur="if($(this).html() == ''){$(this).html('Enter a comment...')}">Enter a comment...</textarea>
<textarea id="<%= id %>" class="w100 p5 f15" rows="2" onfocus="$(this).html('')" onblur="if($(this).html() == ''){$(this).html('Enter a comment...')}">Enter a comment...</textarea>
</div>
<br clear="all" />

View File

@ -48,7 +48,7 @@ SampleApp::Application.configure do
config.assets.debug = false
# Set the logging destination(s)
# config.log_to = %w[stdout file]
config.log_to = %w[stdout file]
# Show the logging configuration on STDOUT
config.show_log_configuration = true