Skip to content
Browse files

Basic web UI for stars (#closes 23)

  • Loading branch information...
1 parent e52b2bf commit 8f6d79269cf8cfc889f96b001f3ac7057d2d3b9a @holman holman committed
Showing with 12 additions and 4 deletions.
  1. +8 −2 lib/play/app.rb
  2. +2 −0 lib/play/templates/song.mustache
  3. +2 −2 public/js/play.js
View
10 lib/play/app.rb
@@ -71,7 +71,13 @@ def current_user
mustache :now_playing
end
- get "/add/:id" do
+ post "/star/:id" do
+ @song = Song.find(params[:id])
+ @song.star!(current_user)
+ "Starred"
+ end
+
+ post "/add/:id" do
@song = Song.find(params[:id])
@song.enqueue!(current_user)
"Queued"
@@ -83,7 +89,7 @@ def current_user
redirect '/'
end
- get "/remove/:id" do
+ post "/remove/:id" do
@song = Song.find(params[:id])
@song.dequeue!(current_user)
"Removed"
View
2 lib/play/templates/song.mustache
@@ -21,6 +21,8 @@
<a href="/artist/{{artist_name}}/album/{{album_name}}">Show Album</a>
+ <span><a href="/star/{{id}}" title="star song" class="star">Star</a></span>
+
{{#queued?}}
<span><a href="/remove/{{id}}" title="remove from queue" class="remove">Don't Play</a></span>
{{/queued?}}
View
4 public/js/play.js
@@ -1,10 +1,10 @@
$(document).ready(function() {
- $(".add, .remove").click(function(){
+ $(".add, .remove, .star").click(function(){
element = $(this)
element
.parent()
.html('<img src="/images/spinner.gif" />')
- .load(element.attr("href"))
+ .load(element.attr("href"), {q: ''})
return false
})
})

0 comments on commit 8f6d792

Please sign in to comment.
Something went wrong with that request. Please try again.