FIX: Search with category, lastfm lib requests, play button

This commit is contained in:
Tobias Klika
2011-05-11 00:02:10 +02:00
parent 24a4f3dc98
commit 334a832140
10 changed files with 65 additions and 30 deletions
+3 -1
View File
@@ -4,9 +4,11 @@ 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
@images = LastFM::Artist.getImages @artist.name, 18
@related= LastFM::Artist.getSimilar @artist.name, 6
@albums = LastFM::Artist.getTopAlbums @artist.name, 8
end
def index
-1
View File
@@ -11,7 +11,6 @@ class SearchController < ApplicationController
@albums = LastFM::Album.search(params[:q].to_s.lstrip, 16)
end
puts params
end
end
+4 -5
View File
@@ -12,17 +12,16 @@
%body
#playlist-container
%ul#playlist
#site
#head
%h1
= link_to image_tag("9minutes.png"), "/"
= form_tag search_index_path, :method => 'get', :id => "search_form", :class => "right" do
= form_tag '/search', :method => 'get', :id => "search_form", :class => "right" do
.wrap
= text_field_tag 'q', params[:q], :class => "input", :placeholder => "Search for"
-# TODO: image_submit_tag
.selection{:dropping=>"true"}
%span ALL
%span.selected ALL
.box
%span.arr
%ul
@@ -30,8 +29,8 @@
%li Artists
%li Albums
%li Songs
= hidden_field_tag 'tab', 'all'
= submit_tag '', :class=>"submit"
= submit_tag '', :class=>"submit", :name => nil
#predefinedTab
= yield
#player
#videoDiv Loading
-1
View File
@@ -1,4 +1,3 @@
#predefinedTab= params[:tab]
%h2.headline
=raw "Search for <span class='blue'>#{params[:q]}</span>"
%ul.navigation.hash.main{:steering => "search"}
+3
View File
@@ -4,3 +4,6 @@ require 'rubygems'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
require 'yaml'
YAML::ENGINE.yamler= 'syck'
+5 -1
View File
@@ -27,7 +27,11 @@ module LastFM
# return: albums ( name, mbid, album url, image urls ( different sizes ) ) ordered by popularity
def self.getTopAlbums artist, limit = nil, page = nil
artist_request "getTopAlbums", "topalbums", artist, limit, page
@albums = artist_request "getTopAlbums", "topalbums", artist, limit, page
if @albums["@attr"].total.to_i == 1
@albums.album = [@albums.album] # wrap with Array
end
@albums
end
def self.getImages artist, limit = nil
+15 -6
View File
@@ -286,7 +286,7 @@ function initSearchDropdown()
{
// hover and out
$("div[dropping]").hoverIntent(function(){
$(this).children(".box").fadeIn(500);
$(this).children(".box").fadeIn(300);
}, function(){
$(this).children(".box").fadeOut(300);
});
@@ -296,10 +296,13 @@ function initSearchDropdown()
$(this).fadeOut(300);
});
$fm = $("#search_form").attr("action");
$fm = $fm.split("#",1);
$("div[dropping] .box li").live("click", function(){
$("div[dropping] > span").html($(this).html());
$("div[dropping] #tab").attr("value", $(this).html().toLowerCase());
$("#search_form").attr("action", $fm+"#tab="+$(this).html().toLowerCase());
});
}
// list fixes
@@ -316,11 +319,15 @@ function fixLists()
function initNavigation()
{
// set hash if submitted by search form
$str = $.deparam.fragment(window.location.href);
$("#predefinedTab").text($str.tab);
$searchTab = $("#predefinedTab").text();
if($searchTab != "")
{
$("#search_form #tab").attr("value", $searchTab);
$("#search_form .selection > span").text($searchTab);
$fm = $("#search_form").attr("action");
$fm = $fm.split("#",1);
$("#search_form .selection .selected").text($searchTab);
$("#search_form").attr("action", $fm+"#tab="+$searchTab.toLowerCase());
}
// add positions and hash control
$(".navigation").each(function(){
@@ -341,7 +348,7 @@ function initNavigation()
if($(this).hasClass("main") && $searchTab != "")
{
$str = $searchTab;
$("#search_form .selection > span").text($searchTab);
$("#search_form .selection .selected").text($searchTab);
}
else
{
@@ -402,8 +409,10 @@ function handleNavigation()
// for search bar
if($(this).parent().hasClass("main"))
{
$fm = $("#search_form").attr("action");
$fm = $fm.split("#",1);
$("#search_form .selection > span").text($settings['hash']);
$("#search_form #tab").attr("value", $settings['hash']);
$("#search_form").attr("action", $fm+"#tab="+$(this).html().toLowerCase());
}
// get the width of the navigation elements which will fade out
+14
View File
@@ -636,3 +636,17 @@ jQuery.store = (function(){
return api
})();
/*
$.fn.hilight = function(option) {
var opts = $.extend({}, $.fn.hilight.defaults, options);
$fn.hilight.defaults = {
foreground: 'red',
background: 'yellow'
};
};
*/
+7 -2
View File
@@ -36,6 +36,9 @@
updateHTML("startBytes", ytplayer.getVideoStartBytes());
updateHTML("bytesLoaded", ytplayer.getVideoBytesLoaded());*/
if(ytplayer.getPlayerState() == 1) $('#player .play').addClass('pause');
else $('#player .play').removeClass('pause');
if(!dragging)
{
var api = $("#scrubbar input").data("rangeinput");
@@ -113,10 +116,11 @@
clearInterval(updateInterval);
}
// Loads the selected video into the player.
function loadVideo(vid) {
function loadVideo(vid) {
var videoID = vid;
if(ytplayer) {
ytplayer.loadVideoById(videoID);
ytplayer.setPlaybackQuality("medium");
}
active = videoID;
$li = activeVid();
@@ -124,7 +128,7 @@ function loadVideo(vid) {
$(this).removeClass("active");
});
$li.addClass("active");
}
}
// This function is automatically called by the player once it loads
function onYouTubePlayerReady(playerId) {
@@ -137,6 +141,7 @@ function loadVideo(vid) {
ytplayer.addEventListener("onError", "onPlayerError");
//Load an initial video into the player
ytplayer.cueVideoById("sCziT0ZWBDQ");
ytplayer.setPlaybackQuality("medium");
}
// The "main method" of this sample. Called when someone clicks "Run".
+2 -1
View File
@@ -1,5 +1,5 @@
@charset "utf-8";
/** FONTS **/
/**FONTS */
@font-face{
font-family: AauxNextLight;
@@ -182,6 +182,7 @@ a { text-decoration: none; color: #7d8791; }
height: 29px; line-height: 29px;
display: block;
opacity: 0.85;
z-index: 800;
}
#search_form .selection > span { text-transform: uppercase;}
#search_form .box