Skip to content

Commit

Permalink
added button
Browse files Browse the repository at this point in the history
  • Loading branch information
tombrightbill committed Jan 22, 2015
1 parent 2d16370 commit 20a3f38
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 13 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ gem 'sqlite3'

gem 'soundcloud'



gem 'devise'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
Expand Down
7 changes: 7 additions & 0 deletions app/assets/javascripts/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
$(document).ready(function(){

$('.add-song').on('click',function(e){
console.log($(this).closest('div[class="track"]'));
});

});
3 changes: 3 additions & 0 deletions app/assets/javascripts/song.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/song.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the song controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
11 changes: 11 additions & 0 deletions app/controllers/song_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class SongController < ApplicationController
def index
end

def create

end

def destroy
end
end
2 changes: 2 additions & 0 deletions app/helpers/song_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module SongHelper
end
3 changes: 3 additions & 0 deletions app/models/song.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Song < ActiveRecord::Base
belongs_to :user
end
2 changes: 2 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ class User < ActiveRecord::Base
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

has_many :songs
end
25 changes: 14 additions & 11 deletions app/views/home/_track.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<h3><em><%=track.title %></em><h3>
<ul>
<li><img src="<%=track.artwork_url%>"/></li>
<li><%=track.uri%></li>
<li> <object height="81" width="100%" class="myPlayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fmatas%2Fhobnotropic&enable_api=true&object_id=yourPlayerId"></param>
<param name="allowscriptaccess" value="always"></param>
<param name='show_comments' value='false'></param>
<embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=<%=track.uri%>&enable_api=true&object_id=yourPlayerId&show_comments=false" type="application/x-shockwave-flash" width="100%" name="yourPlayerId"></embed>
</object></li>
</ul>
<div class='track'>
<h3 class='title'><em><%=track.title %></em><h3>
<ul>
<li><img class='artwork' src="<%=track.artwork_url%>"/></li>
<li class='track_url'><%=track.uri%></li>
<li> <object height="81" width="100" class="myPlayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
<param name="movie" value="http://player.soundcloud.com/player.swf?url=http%3A%2F%2Fsoundcloud.com%2Fmatas%2Fhobnotropic&enable_api=true&object_id=yourPlayerId"></param>
<param name="allowscriptaccess" value="always"></param>
<param name='show_comments' value='false'></param>
<embed allowscriptaccess="always" height="81" src="http://player.soundcloud.com/player.swf?url=<%=track.uri%>&enable_api=true&object_id=yourPlayerId&show_comments=false" type="application/x-shockwave-flash" width="100%" name="yourPlayerId"></embed>
</object></li>
<li><button type='button' class='btn btn-default add-song' href='songs_path'/>Add to Playlist</button></li>
</ul>
</div>
5 changes: 4 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
<title>WorkBeats</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<script type="text/javascript" src="scripts/soundcloud.player.api.js"></script>
<!-- // <script type="text/javascript" src="/assets/javascripts/soundcloud.player.api.js"></script> -->
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"
rel="stylesheet">
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>
<script type="text/javascript">
soundcloud.addEventListener('onPlayerReady', function(player, data) {
player.api_play();
Expand Down
2 changes: 2 additions & 0 deletions app/views/song/create.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Song#create</h1>
<p>Find me in app/views/song/create.html.erb</p>
2 changes: 2 additions & 0 deletions app/views/song/destroy.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Song#destroy</h1>
<p>Find me in app/views/song/destroy.html.erb</p>
2 changes: 2 additions & 0 deletions app/views/song/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Song#index</h1>
<p>Find me in app/views/song/index.html.erb</p>
8 changes: 8 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Rails.application.routes.draw do
get 'song/index'

get 'song/create'

get 'song/destroy'

devise_for :users
root 'home#index'

resources :songs, only: [:index, :create, :destroy]


end
8 changes: 8 additions & 0 deletions db/migrate/20150122223020_songs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Songs < ActiveRecord::Migration
def change
create_table :songs do |t|
t.string :url_track, :url_image, :title
t.belongs_to :user
end
end
end
9 changes: 8 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20150122200436) do
ActiveRecord::Schema.define(version: 20150122223020) do

create_table "songs", force: true do |t|
t.string "url_track"
t.string "url_image"
t.string "title"
t.integer "user_id"
end

create_table "users", force: true do |t|
t.string "email", default: "", null: false
Expand Down

0 comments on commit 20a3f38

Please sign in to comment.