Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Style change, copy paste finally working, image preload

  • Loading branch information...
commit 12bbc779d656794c9caebfac5d02f5897806d370 1 parent 707113e
Julian Connor authored
View
BIN  .DS_Store
Binary file not shown
View
23 app/controllers/songs_controller.rb
@@ -85,28 +85,27 @@ def similar
@artists = []
@spotify_urls = []
- #puts "Query for 10 similar artists to the artist of the song with params[:id]"
+ # puts "Query for 10 similar artists to the artist of the song with params[:id]"
similar_artists = "http://ws.audioscrobbler.com/2.0/?method=artist.getsimilar&artist=" + URI.encode(@s.artist) + "&limit=30&api_key=46717f37e986f321258ffb9d1191b489"
- #puts "artistUrls holds the last.fm url of each artist"
+ # puts "artistUrls holds the last.fm url of each artist"
artistUrls = Hash.new
- #puts "Fetch xml of similar artists."
+ # puts "Fetch xml of similar artists."
@doc = Nokogiri::XML(open(similar_artists))
- #puts "Loop through each artist and grab their name and url."
+ # puts "Loop through each artist and grab their name and url."
@doc.xpath("//artist").each do |node|
- @artists << node.xpath("./name").text
+ @artists << node.xpath("./name").text if !@artists.include?(node.xpath("./name").text)
artistUrls[@artists.last] = node.xpath("./url").text
end
EventMachine.run do
-
- #puts "Instantiate multi request."
+ # puts "Instantiate multi request."
multi_lastfm = EventMachine::MultiRequest.new
- #puts "Build new MultiRequest for Last.fm."
+ # puts "Build new MultiRequest for Last.fm."
url = "http://ws.audioscrobbler.com/2.0/?method=artist.gettoptracks&limit=1&api_key=46717f37e986f321258ffb9d1191b489&artist="
@artists.each {|artist| multi_lastfm.add(EventMachine::HttpRequest.new(url+"#{URI.encode(artist)}").get)}
@@ -116,7 +115,7 @@ def similar
@doc = Nokogiri::XML(resp.response)
- #puts "Solely fetch artist and track names for spotify lookup."
+ # puts "Solely fetch artist and track names for spotify lookup."
@doc.xpath("//track").each do |node|
t = CGI.escape(node.xpath("./name").text)
a = CGI.escape(node.xpath(".//artist/name").text)
@@ -125,13 +124,13 @@ def similar
end
- #puts "Build new MultiRequest for Spotify."
+ # puts "Build new MultiRequest for Spotify."
multi_spotify = EventMachine::MultiRequest.new
@spotify_urls.each {|url| multi_spotify.add(EventMachine::HttpRequest.new(url).get)}
multi_spotify.callback {
- #puts "Handle successfull fetches from spotify and build @out object."
+ # puts "Handle successfull fetches from spotify and build @out object."
multi_spotify.responses[:succeeded].each do |resp|
@doc = Nokogiri::XML(resp.response)
@node = @doc.xpath("//xmlns:track").first
@@ -149,7 +148,7 @@ def similar
end
end
- #puts "Stop Event Machine."
+ # puts "Stop Event Machine."
EventMachine.stop
}
}
View
BIN  app/views/songs/ZeroClipboard.swf
Binary file not shown
View
27 app/views/songs/index.html.erb
@@ -5,23 +5,36 @@
</ol>
<%= render 'form' %>
</div>
-
+
+<script type="text/javascript">
+ $(document).ready(function(){
+ });
+</script>
+
<script id="song_item" type="text/html">
<div id='{{id}}'>
<div class='listTrackContent'>
<div class="content">
- <div class="trackInfo">
- <a href="{{trackUrl}}" target="_blank">{{track}}</a> - <a href="{{artistUrl}}" target="_blank">{{artist}}</a>
+ <div class="trackInfo clearfix">
+ <a class="trackName" href="{{trackUrl}}" target="_blank">{{track}} - {{artist}}</a>
<div class="icons">
- <span class="delete"><img src="images/delete.png"/></span>
- <span class="expand"><img src="images/expand.png"/></span>
+ <span class="delete">
+ <img src="images/delete.png"/>
+ </span>
+ <span class="expand">
+ <img src="images/expand.png"/>
+ </span>
</div>
<span class="genre">{{genre}}</span>
+ <div class="dragicon {{id}}">
+ <a class="uriTxt"></a>
+ </div>
</div>
</div>
<ol class="{{id}}">
- </ol>
- </div>
+ </ol>
+
+ </div>
</div>
</script>
View
3  config/assets.yml
@@ -11,4 +11,5 @@ javascripts:
- public/javascripts/backbone-0.5.0.js
- public/javascripts/icanhaz.js
- public/javascripts/songs.js
- - app/views/songs/*.jst
+ - public/javascripts/preload.js
+ - public/javascripts/jquery.zclip.js
View
BIN  public/.DS_Store
Binary file not shown
View
BIN  public/images/delete.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  public/javascripts/.songs.js.swp
Binary file not shown
View
20 public/javascripts/songs.js
@@ -82,9 +82,27 @@ $(function(){
//alert(JSON.stringify(i));
return jQuery.parseJSON('{"track":"'+i.track+'","artist":"'+i.artist+'","image":"'+i.image+'","artistUrl":"'+i.artistUrl+'","trackUrl":"'+i.trackUrl+'","album":"'+i.album+'","albumUrl":"'+i.albumUrl+'","released":"'+i.year+'"}');
});
+
+ // Store drag icon in var
+ var d_icon = $(".dragicon."+id);
+ var txt = d_icon.find(".uriTxt")[0];
+ txt.value = "";
+
+ // Loop through song items and append spotify URI
$.each(songs,function(){
- //alert(JSON.stringify(this));
$("ol."+id).append(ich.similar_song_item(this));
+ console.log(id);
+ txt.value += this.trackUrl + " ";
+ });
+
+ d_icon.slideToggle(25,function(){
+ d_icon.zclip({
+ path: '/ZeroClipboard.swf',
+ copy: txt.value,
+ afterCopy:function(){
+ alert("Copied your playlist to clipboard. Please paste (CMD+V) into a blank spotify playlist.");
+ }
+ });
});
expand.html("<img src='images/contract.png'/>");
}
View
BIN  public/stylesheets/.style.css.swp
Binary file not shown
View
42 public/stylesheets/style.css
@@ -1,7 +1,19 @@
+.clearfix:after {
+ content: ".";
+ display: block;
+ height: 0;
+ clear: both;
+ visibility: hidden;
+}
+
+.clearfix {
+ display: block;
+}
+
body {
line-height: 1.45em;
margin: 0 auto;
- background-color:#FFE1D6;
+ background-color:#E6FFF1;
font: normal normal normal 1em/1.4 Cambria, Georgia, sans-serif;
}
@@ -48,6 +60,9 @@ h1#logo {
ol#song_list, ol#song_list ol {
padding: 0;
}
+ol#song_list {
+ list-style: none;
+}
ol#song_list ol {
margin-left: 30px;
list-style: decimal-leading-zero;
@@ -64,7 +79,7 @@ ol#song_list li.track {
background-attachment:initial;
background-clip:initial;
background-color:rgba(0, 0, 0, 0.0351562);
- background-image:initial;
+ ackground-image:initial;
background-origin:initial;
background-position:initial initial;
background-repeat:initial initial;
@@ -95,17 +110,13 @@ li .expand, li .delete {
cursor: pointer;
}
-span.delete img {
- -webkit-transform: rotate(45deg);
- -moz-transform: rotate(45deg);
-}
-
li .expand:hover {
color: #fcfcfc;
}
li div.icons {
padding: 0;
+ height:25px;
display: inline;
list-style: none;
}
@@ -116,7 +127,7 @@ li div.icons {
.genre {
background-attachment:initial;
background-clip:initial;
- background-color:#BFA9A1;
+ background-color:#559676;
background-image:initial;
background-origin:initial;
border-bottom-left-radius:10px 10px;
@@ -132,3 +143,18 @@ li div.icons {
color: white;
text-shadow: 0 !important;
}
+.trackName {
+ color: #05372D !important;
+ float: left;
+ padding-top: 3px;
+}
+
+.dragicon {
+ padding: 0 5px 0 0;
+ display:none;
+ width: 25px;
+ height: 25px;
+ float: right;
+ cursor: pointer;
+ background: url("/images/spotify-32.png") no-repeat !important;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.