ADDED: artist; FIXED: hash navigation
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
require 'uri'
|
||||
|
||||
class ArtistsController < ApplicationController
|
||||
def show
|
||||
@artist = LastFM::Artist.getInfo CGI.unescape(params[:id])
|
||||
@tracks = LastFM::Artist.getTopTracks @artist.name, 10
|
||||
@albums = LastFM::Artist.getTopAlbums @artist.name, 8
|
||||
end
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,2 @@
|
||||
module ArtistHelper
|
||||
end
|
||||
@@ -0,0 +1 @@
|
||||
#empty
|
||||
@@ -0,0 +1,51 @@
|
||||
#artist
|
||||
.side
|
||||
.img= image_tag validate_img_url(@artist.image, "artist", :mega)
|
||||
%p.description
|
||||
%span
|
||||
%b Tags:
|
||||
- @artist.tags.tag.each_with_index do |tag, i|
|
||||
= (i!=0) ? ", "+tag.name : tag.name
|
||||
|
||||
%br
|
||||
%br
|
||||
=raw @artist.bio.summary
|
||||
.main
|
||||
%h2.headline.blue= @artist.name
|
||||
%ul.navigation.hash{:steering=>"artist"}
|
||||
%li Music
|
||||
%li Related
|
||||
%li Pics
|
||||
.main_content{:wheel=>"artist"}
|
||||
%div
|
||||
%ul.navigation.sub{:steering=>"music"}
|
||||
%li.active Top Songs
|
||||
%li Top Albums
|
||||
%div{:wheel=>"music"}
|
||||
%div
|
||||
%ul.songs
|
||||
- @tracks.track.each do |track|
|
||||
%li
|
||||
= image_tag "ico/play.png", :class=>"play"
|
||||
= image_tag "ico/add.png", :class=>"add"
|
||||
%span= track.name
|
||||
=raw " "
|
||||
= "by #{trimString(track.artist.name, 50)}"
|
||||
%br.clean
|
||||
= link_to "NACHLADEN", :class => "more" do
|
||||
= image_tag "ico/more.png"
|
||||
%div
|
||||
%ul.albums
|
||||
- @albums.album.each do |album|
|
||||
%li
|
||||
.img= image_tag validate_img_url(album.image, "album", :medium)
|
||||
%p
|
||||
%span= trimString(album.name, 38)
|
||||
%br
|
||||
= trimString(album.artist.name, 22)
|
||||
%sub
|
||||
%br.clean
|
||||
= link_to "NACHLADEN", :class => "more" do
|
||||
= image_tag "ico/more.png"
|
||||
%div Related
|
||||
%div Pics
|
||||
@@ -1,6 +1,6 @@
|
||||
%h2.headline
|
||||
=raw "Search for „#{params[:q]}“"
|
||||
%ul.navigation{:steering => "search"}
|
||||
%ul.navigation.hash{:steering => "search"}
|
||||
%li.active ALL
|
||||
%li ARTISTS
|
||||
%li ALBUMS
|
||||
@@ -13,10 +13,10 @@
|
||||
- @artists.artist.each_with_index do |artist, i|
|
||||
- break if i >= 6
|
||||
%li
|
||||
= link_to "LINK" do
|
||||
= image_tag validate_img_url(artist.image, :artist, :large), :alt => artist.name
|
||||
%p
|
||||
= trimString(artist.name, 22)
|
||||
- puts artist.name
|
||||
- link_to :controller=>"artists",:action=>"show",:id=>CGI.escape(artist.name) do
|
||||
= image_tag validate_img_url(artist.image, "artist", :large)
|
||||
%p= trimString(artist.name, 22)
|
||||
%br.clean
|
||||
#search_all_songs
|
||||
%h2.headline.small Songs
|
||||
@@ -37,7 +37,7 @@
|
||||
- break if i == 6
|
||||
%li
|
||||
.img
|
||||
= image_tag validate_img_url(album.image, :album, :medium)
|
||||
= image_tag validate_img_url(album.image, "album", :medium)
|
||||
%p
|
||||
%span
|
||||
= trimString(album.name, 38)
|
||||
@@ -50,9 +50,8 @@
|
||||
- break if i >= 12
|
||||
%li
|
||||
= link_to "LINK" do
|
||||
= image_tag validate_img_url(artist.image, :artist, :large)
|
||||
%p
|
||||
= trimString(artist.name, 22)
|
||||
= image_tag validate_img_url(artist.image, "artist", :large)
|
||||
%p= trimString(artist.name, 22)
|
||||
%br.clean
|
||||
= link_to "NACHLADEN", :class => "more" do
|
||||
= image_tag "ico/more.png"
|
||||
@@ -62,7 +61,7 @@
|
||||
- break if i == 16
|
||||
%li
|
||||
.img
|
||||
= image_tag validate_img_url(album.image, :album, :medium)
|
||||
= image_tag validate_img_url(album.image, "album", :medium)
|
||||
%p
|
||||
%span
|
||||
= trimString(album.name, 38)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Nineminutes::Application.routes.draw do
|
||||
resources :artists, :constraints => { :id => /.*/ }
|
||||
resources :search
|
||||
# The priority is based upon order of creation:
|
||||
# first created -> highest priority.
|
||||
|
||||
@@ -7,7 +7,7 @@ module LastFM
|
||||
|
||||
# return: artist name, tags, similar artists, artist bio (summary / long), mbid, image urls ( different sizes )
|
||||
def self.getInfo artist
|
||||
artist_request "getInfo", nil, artist
|
||||
artist_request "getInfo", "artist", artist
|
||||
end
|
||||
|
||||
# return: artists ( name, mbid, image urls ( different sizes ) )
|
||||
|
||||
@@ -97,34 +97,111 @@ function initNavigation()
|
||||
});
|
||||
|
||||
// add actives
|
||||
$str = $.deparam.fragment(window.location.href);
|
||||
$active = $(".navigation li[hashcontrol="+$str.category+"]");
|
||||
if($active.text() == "" || $active == null) $id = 0;
|
||||
else $id = $active.parent().children().index($active);
|
||||
$('.navigation li:eq('+$id+')').addClass('active');
|
||||
$('div[wheel] > div:eq('+$id+')').addClass('active').css("opacity", 1.0).show();
|
||||
$i = 0;
|
||||
$('.navigation').each(function(){
|
||||
if($(this).hasClass("hash"))
|
||||
{
|
||||
$str = $.deparam.fragment(window.location.href);
|
||||
$active = $(".navigation li[hashcontrol="+$str.category+"]");
|
||||
if($active.text() == "" || $active == null) $id = 0;
|
||||
else $id = $active.parent().children().index($active);
|
||||
}
|
||||
else $id = 0;
|
||||
|
||||
$(this).children('li:eq('+$id+')').addClass('active');
|
||||
$('div[wheel]:eq('+$i+') > div:eq('+$id+')').addClass('active').css("opacity", 1.0).show();
|
||||
$i++;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// order if predefined category
|
||||
function orderNavigation(){
|
||||
$str = $.deparam.fragment(window.location.href);
|
||||
$active = $(".navigation li[hashcontrol="+$str.category+"]");
|
||||
if($active==null) return;
|
||||
$(".navigation.hash").each(function(){
|
||||
$str = $.deparam.fragment(window.location.href);
|
||||
$active = $(this).children("[hashcontrol="+$str.category+"]");
|
||||
if($active.text() == "" || $active == null) return;
|
||||
|
||||
$id = $active.parent().children().index($active);
|
||||
$size = $(this).children().size();
|
||||
|
||||
$id = $active.parent().children().index($active);
|
||||
$size = $(".navigation li").size();
|
||||
|
||||
for($i=0;$i<$id;$i++){
|
||||
$element = $(".navigation li:eq("+$i+")");
|
||||
$(".navigation").append("<li hashcontrol='"+$element.attr('hashcontrol')
|
||||
+"' position='"+$element.attr('position')+"'>"+$element.text()+"</li>");
|
||||
}
|
||||
for($i=0;$i<$id;$i++){
|
||||
$(".navigation li:first-child").remove();
|
||||
}
|
||||
for($i=0;$i<$id;$i++){
|
||||
$element = $(this).children(":eq("+$i+")");
|
||||
$(this).append("<li hashcontrol='"+$element.attr('hashcontrol')
|
||||
+"' position='"+$element.attr('position')+"'>"+$element.text()+"</li>");
|
||||
}
|
||||
for($i=0;$i<$id;$i++){
|
||||
$(this).children().first().remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// navigation handling
|
||||
function handleNavigation()
|
||||
{
|
||||
$("ul[steering] li").live("click", function(){
|
||||
if($(this).is('.active')) return;
|
||||
|
||||
// VARS
|
||||
$settings = [];
|
||||
$fadeOutWidth = 0;
|
||||
$settings['nav'] = $(this).parent();
|
||||
$settings['newpos'] = $settings['nav'].children().index(this);
|
||||
$settings['oldpos'] = $(this).attr("position");
|
||||
$settings['wheel'] = $settings['nav'].attr("steering");
|
||||
|
||||
// get the width of the navigation elements which will fade out
|
||||
for(var i=0; i<$settings['newpos'];i++){
|
||||
$fadeOutWidth += $settings['nav'].children("li:eq("+i+")").width();
|
||||
}
|
||||
|
||||
// change :active
|
||||
$settings['nav'].children().removeClass("active");
|
||||
$(this).addClass("active");
|
||||
|
||||
// change URL
|
||||
if(!$settings['nav'].hasClass('sub')){
|
||||
$str = $.param.fragment(window.location.href, 'category='+$(this).attr("hashcontrol"));
|
||||
window.location.href = $str;
|
||||
}
|
||||
|
||||
// move navigation container
|
||||
$settings['nav'].animate({
|
||||
marginLeft: -$fadeOutWidth-5
|
||||
}, 300);
|
||||
|
||||
// move navigation elements
|
||||
for(var i=0; i<$settings['newpos'];i++){
|
||||
$element = $settings['nav'].children("li:eq("+i+")");
|
||||
$element.animate({
|
||||
opacity: 0
|
||||
}, 300, function(){
|
||||
$(this).remove();
|
||||
$settings['nav'].css("marginLeft", 0);
|
||||
});
|
||||
|
||||
$settings['nav'].append("<li style='opacity:0;margin-left: 20px;' hashcontrol='"+$element.attr('hashcontrol')+"' position='"+$element.attr('position')+"'>"+$element.text()+"</li>");
|
||||
$settings['nav'].children().last().animate({
|
||||
opacity: 1, marginLeft: 0
|
||||
}, 500);
|
||||
}
|
||||
|
||||
$speed = 200;
|
||||
$range = 200;
|
||||
|
||||
// animation for content
|
||||
$("div[wheel="+$settings['wheel']+"] > .active").css("left", 0).animate({
|
||||
left: -$range, opacity: 0
|
||||
}, $speed, function(){
|
||||
$(this).hide();
|
||||
$("div[wheel="+$settings['wheel']+"] > div:eq("+$settings['oldpos']+")").css("left", $range).show().addClass("active").animate({
|
||||
left: 0, opacity: 1
|
||||
}, $speed);
|
||||
}).removeClass("active");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Overlay
|
||||
@@ -156,68 +233,6 @@ function overlay(id)
|
||||
});
|
||||
}
|
||||
|
||||
// navigation handling
|
||||
function handleNavigation()
|
||||
{
|
||||
$("ul[steering] li").live("click", function(){
|
||||
if($(this).is('.active')) return;
|
||||
|
||||
// VARS
|
||||
$settings = [];
|
||||
$fadeOutWidth = 0;
|
||||
$settings['nav'] = $(this).parent();
|
||||
$settings['newpos'] = $settings['nav'].children().index(this);
|
||||
$settings['oldpos'] = $(this).attr("position");
|
||||
$settings['wheel'] = $settings['nav'].attr("steering");
|
||||
|
||||
// get the width of the navigation elements which will fade out
|
||||
for(var i=0; i<$settings['newpos'];i++){
|
||||
$fadeOutWidth += $settings['nav'].children("li:eq("+i+")").width();
|
||||
}
|
||||
|
||||
// change :active
|
||||
$settings['nav'].children().removeClass("active");
|
||||
$(this).addClass("active");
|
||||
|
||||
// change URL
|
||||
$str = $.param.fragment(window.location.href, 'category='+$(this).text().toLowerCase());
|
||||
window.location.href = $str;
|
||||
|
||||
// move navigation container
|
||||
$settings['nav'].animate({
|
||||
marginLeft: -$fadeOutWidth-5
|
||||
}, 300);
|
||||
|
||||
// move navigation elements
|
||||
for(var i=0; i<$settings['newpos'];i++){
|
||||
$element = $settings['nav'].children("li:eq("+i+")");
|
||||
$element.animate({
|
||||
opacity: 0
|
||||
}, 300, function(){
|
||||
$(this).remove();
|
||||
$settings['nav'].css("marginLeft", 0);
|
||||
});
|
||||
|
||||
$settings['nav'].append("<li style='opacity:0;margin-left: 20px;' position='"+$element.attr('position')+"'>"+$element.text()+"</li>");
|
||||
$settings['nav'].children().last().animate({
|
||||
opacity: 1, marginLeft: 0
|
||||
}, 500);
|
||||
}
|
||||
|
||||
$speed = 200;
|
||||
$range = 200;
|
||||
|
||||
// animation for content
|
||||
$("div[wheel="+$settings['wheel']+"] > .active").css("left", 0).animate({
|
||||
left: -$range, opacity: 0
|
||||
}, $speed, function(){
|
||||
$(this).hide();
|
||||
$("div[wheel="+$settings['wheel']+"] > div:eq("+$settings['oldpos']+")").css("left", $range).show().addClass("active").animate({
|
||||
left: 0, opacity: 1
|
||||
}, $speed);
|
||||
}).removeClass("active");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function onImageError(){
|
||||
|
||||
@@ -284,6 +284,7 @@ div[wheel] > div { display: none; opacity: 0.0; position: relative; }
|
||||
height: 281px;
|
||||
background: url('../images/bg/fuse.png') -401px 160px no-repeat;
|
||||
}
|
||||
#artist .side .img img { width: 363px; height: 241px; }
|
||||
#artist .description { width: 363px; font-size: 12px; }
|
||||
#artist .description span { color: #2e353c; }
|
||||
#artist .main
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ArtistControllerTest < ActionController::TestCase
|
||||
test "should get show" do
|
||||
get :show
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ArtistHelperTest < ActionView::TestCase
|
||||
end
|
||||
Reference in New Issue
Block a user