outsourced tracklists to partial + finally fixed autoloading 'lib' path
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
class TracksController < ApplicationController
|
||||
def index
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
module TracksHelper
|
||||
end
|
||||
@@ -10,17 +10,15 @@
|
||||
.navigate
|
||||
%a.left
|
||||
%a.right
|
||||
%ul.songs.short{:count=>"5"}
|
||||
%ul.tracks.short{:count=>"5"}
|
||||
- @tracks.track.each_with_index do |track, i|
|
||||
- id = @youtube_client.videos_by(:query => "#{track.name} #{track.artist.name} official", :page => 1, :per_page => 1, :order_by => "relevance")
|
||||
%li
|
||||
= image_tag "ico/play.png", :class=>"play", :videoid=>id.videos.first.unique_id
|
||||
= image_tag "ico/add.png", :class=>"add"
|
||||
%span
|
||||
%span= (i+1).to_s+"."
|
||||
= track.name
|
||||
=raw " by "
|
||||
= link_to trimString(track.artist.name, 50), :controller=>"artists",:action=>"show",:id=>CGI.escape(track.artist.name)
|
||||
= link_to trimString(track.artist.name, 50), artist_path(CGI.escape(track.artist.name))
|
||||
.right
|
||||
%h2.headline.small
|
||||
%span.left Top Artists
|
||||
@@ -30,12 +28,12 @@
|
||||
%ul.artists.big{:count=>"2"}
|
||||
- @artists.artist.each do |artist|
|
||||
%li
|
||||
= link_to :controller=>:artists,:action=>:show,:id=>CGI.escape(artist.name) do
|
||||
= link_to artist_path(CGI.escape(artist.name)) do
|
||||
= image_tag validate_img_url(artist.image, "artist", :extralarge)
|
||||
%p
|
||||
= trimString(artist.name, 30)
|
||||
%br><
|
||||
=raw "<span>#{artist.listeners} Listeners, #{artist.playcount} Plays</span>"
|
||||
%span= "#{artist.listeners} Listeners, #{artist.playcount} Plays"
|
||||
%br.clean
|
||||
.bottom
|
||||
%hr
|
||||
|
||||
@@ -21,18 +21,9 @@
|
||||
=raw "<span>#{artist.listeners} Listeners</span>"
|
||||
%br.clean
|
||||
%br
|
||||
#search_all_songs
|
||||
#search_all_tracks
|
||||
-#%h2.headline.small Songs
|
||||
%ul.songs.short
|
||||
- @tracks.track.each_with_index do |track, i|
|
||||
- break if i == 13
|
||||
- id = @youtube_client.videos_by(:query => "#{track.name} #{track.artist} official", :page => 1, :per_page => 1, :order_by => "relevance")
|
||||
%li
|
||||
= image_tag "ico/play.png", :class=>"play", :videoid=>id.videos.first.unique_id
|
||||
= image_tag "ico/add.png", :class=>"add"
|
||||
%span= track.name
|
||||
=raw " by "
|
||||
= link_to trimString(track.artist, 50), :controller=>"artists",:action=>"show",:id=>CGI.escape(track.artist)
|
||||
= render :partial => "tracks/list", :locals => { :tracks => @tracks, :additional_class => "short", :count => 13 }
|
||||
#search_all_albums
|
||||
-#%h2.headline.small Albums
|
||||
%ul.albums.wide
|
||||
@@ -49,7 +40,7 @@
|
||||
- @artists.artist.each_with_index do |artist, i|
|
||||
- break if i >= 8
|
||||
%li
|
||||
= link_to :controller=>:artists,:action=>:show,:id=>CGI.escape(artist.name) do
|
||||
= link_to artist_path(CGI.escape(artist.name)) do
|
||||
= image_tag validate_img_url(artist.image, "artist", :extralarge)
|
||||
%p
|
||||
= trimString(artist.name, 26)
|
||||
@@ -74,17 +65,8 @@
|
||||
%br.clean
|
||||
= link_to "NACHLADEN", :class => "more" do
|
||||
= image_tag "ico/more.png"
|
||||
#search_songs
|
||||
%ul.songs.tab
|
||||
- @tracks.track.each_with_index do |track, i|
|
||||
- break if i == 18
|
||||
- id = @youtube_client.videos_by(:query => "#{track.name} #{track.artist} official", :page => 1, :per_page => 1, :order_by => "relevance")
|
||||
%li
|
||||
= image_tag "ico/play.png", :class=>"play", :videoid=>id.videos.first.unique_id
|
||||
= image_tag "ico/add.png", :class=>"add"
|
||||
%span= track.name
|
||||
=raw " by "
|
||||
= link_to trimString(track.artist, 50), :controller=>"artists",:action=>"show",:id=>CGI.escape(track.artist)
|
||||
#search_tracks
|
||||
= render :partial => "tracks/list", :locals => { :tracks => @tracks, :additional_class => "tab", :count => 26 }
|
||||
%br.clean
|
||||
%br
|
||||
= link_to "NACHLADEN", :class => "more" do
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
- count = "" if !local_assigns.has_key? :count
|
||||
|
||||
%ul.tracks{ :class => additional_class, :count => count }
|
||||
- tracks.track.each_with_index do |track, i|
|
||||
- id = @youtube_client.videos_by(:query => "#{track.name} #{track.artist} official", :page => 1, :per_page => 1, :order_by => "relevance")
|
||||
%li
|
||||
= image_tag "ico/play.png", :class=>"play", :videoid=>id.videos.first.unique_id
|
||||
= image_tag "ico/add.png", :class=>"add"
|
||||
%span= track.name
|
||||
= link_to trimString(track.artist, 50), artist_path(CGI.escape(track.artist))
|
||||
@@ -1,5 +1,7 @@
|
||||
Nineminutes::Application.routes.draw do
|
||||
|
||||
get "tracks/index"
|
||||
|
||||
resources :artists, :constraints => { :id => /.*/ }
|
||||
resources :search
|
||||
resources :home
|
||||
|
||||
@@ -12,14 +12,14 @@ $(document).ready(function(){
|
||||
initArtistDescription();
|
||||
|
||||
initPlaylist();
|
||||
makeSongsAddable(); // bind click-event to "add" button (for each song)
|
||||
makeTracksAddable(); // bind click-event to "add" button (for each track)
|
||||
|
||||
initTopMusic();
|
||||
initTrackAndArtistLists();
|
||||
navigateTopMusic();
|
||||
|
||||
initPlayer();
|
||||
|
||||
playSong();
|
||||
playTrack();
|
||||
|
||||
fitImages(".artists.big img"); // resize and resposition images (artists, album)
|
||||
fitImages(".artists.small img");
|
||||
@@ -34,12 +34,12 @@ $(window).load(function() {
|
||||
});
|
||||
|
||||
|
||||
function playSong(){
|
||||
$('.songs .play').live('click',function(){
|
||||
function playTrack(){
|
||||
$('.tracks .play').live('click',function(){
|
||||
$id = $(this).attr("videoid");
|
||||
loadVideo($id);
|
||||
$('#song .artist').text($(this).parents('li').children('a').text());
|
||||
$('#song .song').text($(this).parents('li').children('span').text());
|
||||
$('#track .artist').text($(this).parents('li').children('a').text());
|
||||
$('#track .track').text($(this).parents('li').children('span').text());
|
||||
});
|
||||
}
|
||||
|
||||
@@ -78,29 +78,26 @@ function initPlaylist() {
|
||||
}
|
||||
|
||||
function savePlaylist() {
|
||||
var songs = [];
|
||||
var tracks = [];
|
||||
$('ul#playlist li').each(function(i) {
|
||||
songs[i] = {
|
||||
tracks[i] = {
|
||||
title : $(this).children('span').text(),
|
||||
artist : $(this).children('a').text(),
|
||||
videoid : $(this).attr('videoid')
|
||||
}
|
||||
});
|
||||
|
||||
//console.log(songs);
|
||||
$.store.set("9minutesPlaylist", songs);
|
||||
//console.log(tracks);
|
||||
$.store.set("9minutesPlaylist", tracks);
|
||||
//console.log("playlist saved ;)");
|
||||
}
|
||||
|
||||
function makeSongsAddable() {
|
||||
$('.songs li .add').live("click", onAddSongToPlaylist);
|
||||
function makeTracksAddable() {
|
||||
$('.tracks li .add').live("click", onAddTrackToPlaylist);
|
||||
}
|
||||
|
||||
function onAddSongToPlaylist(event) {
|
||||
function onAddTrackToPlaylist(event) {
|
||||
// if already in playlist
|
||||
|
||||
|
||||
|
||||
$listElement = $(event.target).parents('li').clone();
|
||||
$vuid = $listElement.children('.play').attr('videoid');
|
||||
|
||||
@@ -121,12 +118,9 @@ function onAddSongToPlaylist(event) {
|
||||
$(this).slideDown(500);
|
||||
});
|
||||
savePlaylist();
|
||||
|
||||
// TODO: prevent double entries
|
||||
// TODO: get video-id from youtube
|
||||
}
|
||||
|
||||
function onRemoveSongFromPlaylist(event) {
|
||||
function onRemoveTrackFromPlaylist(event) {
|
||||
$listElement = $(event.target).parent();
|
||||
$listElement.fadeTo(300, 0.1, function() {
|
||||
$(this).hide("blind", function() {
|
||||
@@ -202,12 +196,14 @@ function getTimeFromInt(number) {
|
||||
return ((m >= 10) ? '' : '0') + m + ":" + ((s >= 10) ? '' : '0') + s;
|
||||
}
|
||||
|
||||
function initTopMusic(){
|
||||
$('#home .songs li').each(function(){
|
||||
if($(this).parent().children().index(this)>=5) $(this).hide();
|
||||
function initTrackAndArtistLists(){
|
||||
$('.tracks li').each(function() {
|
||||
$count = parseInt($(this).parent().attr("count"));
|
||||
if($(this).parent().children().index(this)>=$count) $(this).hide();
|
||||
});
|
||||
$('#home .artists li').each(function(){
|
||||
if($(this).parent().children().index(this)>=2) $(this).hide();
|
||||
$('#home .artists li').each(function() {
|
||||
$count = parseInt($(this).parent().attr("count"));
|
||||
if($(this).parent().children().index(this)>=$count) $(this).hide();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -218,7 +214,7 @@ function navigateTopMusic(){
|
||||
$start = $id.parent().children().index($id);
|
||||
$count = parseInt($selector.attr("count"));
|
||||
$size = $selector.children().size();
|
||||
|
||||
|
||||
if($(this).hasClass("left")) {
|
||||
$start -= $count;
|
||||
if($start < 0) return;
|
||||
@@ -242,7 +238,6 @@ function ajj(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
function initArtistDescription(){
|
||||
$("#artist .description .text a").each(function(){
|
||||
$text = $(this).html();
|
||||
@@ -251,8 +246,6 @@ function initArtistDescription(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function fitImages(selector) {
|
||||
switch(selector)
|
||||
{
|
||||
@@ -337,7 +330,7 @@ function fixLists()
|
||||
{
|
||||
$(".artists.small li:nth-child(4n)").css("marginRight", 0);
|
||||
$(".artists.ultrasmall li:nth-child(3n)").css("marginRight", 0);
|
||||
$(".songs.tab li:nth-child(2n)").css("marginRight", 0);
|
||||
$(".tracks.tab li:nth-child(2n)").css("marginRight", 0);
|
||||
$("#artist .gallery a:nth-child(6n)").css("marginRight", 0);
|
||||
$("#home .artists li:nth-child(2n)").css("marginRight", 0);
|
||||
}
|
||||
|
||||
@@ -290,30 +290,30 @@ a { text-decoration: none; color: #7d8791; }
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.songs li
|
||||
.tracks li
|
||||
{
|
||||
height: 32px; line-height: 32px;
|
||||
border-bottom: 1px dotted #dce2e6;
|
||||
font-size: 12px;
|
||||
width: 465px;
|
||||
}
|
||||
.songs.short li { width: 395px; }
|
||||
.songs.long li { width: 530px; }
|
||||
.songs.tab { overflow: hidden; }
|
||||
.songs.tab li { float: left; margin-right: 20px; }
|
||||
.songs li span
|
||||
.tracks.short li { width: 395px; }
|
||||
.tracks.long li { width: 530px; }
|
||||
.tracks.tab { overflow: hidden; }
|
||||
.tracks.tab li { float: left; margin-right: 20px; }
|
||||
.tracks li span
|
||||
{
|
||||
color: #2d3135;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.songs.long li span { color: #027bbf; }
|
||||
.songs li img { vertical-align: middle; }
|
||||
.songs a:hover, .albums a:hover { color: #505861;}
|
||||
.songs .play, .songs .add { cursor: pointer; }
|
||||
.tracks.long li span { color: #027bbf; }
|
||||
.tracks li img { vertical-align: middle; }
|
||||
.tracks a:hover, .albums a:hover { color: #505861;}
|
||||
.tracks .play, .tracks .add { cursor: pointer; }
|
||||
|
||||
|
||||
#search_all_artists { float: left; }
|
||||
#search_all_songs { float: right; }
|
||||
#search_all_tracks { float: right; }
|
||||
#search_all_albums { float: left; width: 514px; }
|
||||
|
||||
.albums li
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TracksControllerTest < ActionController::TestCase
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TracksHelperTest < ActionView::TestCase
|
||||
end
|
||||
Reference in New Issue
Block a user