1
0
Fork 0

Font Awesome, jbuilder templates, getting rid of beatparser

This commit is contained in:
Gregory Eremin 2012-09-09 17:48:24 +04:00
parent be5a643b55
commit 9cb145f0d7
42 changed files with 520 additions and 233 deletions

View File

@ -16,6 +16,7 @@ group :assets do
gem "bourbon"
gem "bootstrap-sass", "~> 2.0.4.0"
gem "soundmanager-rails"
gem "font-awesome-rails"
end
group :development do
@ -25,8 +26,8 @@ group :development do
gem "capistrano"
end
# To use Jbuilder templates for JSON
gem "jbuilder"
gem "haml"
gem "robbie", path: "../robbie"
gem "beatparser", path: "../beatparser"

View File

@ -69,6 +69,9 @@ GEM
eventmachine (0.12.10)
execjs (1.4.0)
multi_json (~> 1.0)
font-awesome-rails (0.4.0)
railties (~> 3.1)
haml (3.1.7)
highline (1.6.13)
hike (1.2.1)
hogan_assets (1.3.2)
@ -175,6 +178,8 @@ DEPENDENCIES
bourbon
capistrano
coffee-rails (~> 3.2.1)
font-awesome-rails
haml
hogan_assets
jbuilder
jquery-rails

View File

@ -1,15 +0,0 @@
//= require jquery
//= require jquery_ujs
//= require jquery.autocomplete
//= require soundmanager
//= require vk_music
//= require mustache
//= require hogan
//= require underscore
//= require backbone
//= require backbone_rails_sync
//= require backbone_datalink
//= require backbone/beat_haven
//= require bootstrap-dropdown
//= require_tree .

View File

@ -0,0 +1,21 @@
#= require jquery
#= require jquery_ujs
#= require jquery.autocomplete
#= require soundmanager
#= require vk_music
#= require hogan
#= require underscore
#= require backbone
#= require backbone_rails_sync
#= require backbone_datalink
#= require backbone/beat_haven
#= require bootstrap-dropdown
#= require bootstrap-tooltip
#= require bootstrap-popover
#= require_tree .

View File

@ -7,6 +7,6 @@ $ ->
$(".player").animate(width: 518)
window.desired = $(".navbar-search input").autocomplete
serviceUrl: "/api/search/complete"
serviceUrl: "/api/search/complete.json"
onSelect: (selected) ->
Backbone.history.navigate("/search/"+selected.replace(/\s/g, "+"), true)

View File

@ -14,6 +14,7 @@ window.BeatHaven =
User: null
init: ->
new BeatHaven.Routers.Main()
new BeatHaven.Routers.Artist()
new BeatHaven.Routers.Album()
new BeatHaven.Routers.Search()
@ -21,7 +22,7 @@ window.BeatHaven =
@User = new BeatHaven.Models.User()
@VK = new BeatHaven.Models.VK()
@VK.init()
# @VK.init()
Backbone.history.start(pushState: true);
$("a").live "click", (e) ->
@ -30,6 +31,8 @@ window.BeatHaven =
Backbone.history.navigate($(this).attr("href"), true)
false
# Backbone.history.navigate("/tour", true)
log: (data) ->
console.log data

View File

@ -2,6 +2,7 @@ class BeatHaven.Models.VK extends Backbone.Model
session_length: 3600 # seconds
Music: null
BITMASK: 8
popup: ->
alert(1)
@ -13,12 +14,13 @@ class BeatHaven.Models.VK extends Backbone.Model
BH.VK.auth()
# VK.Widgets.Like("vk-like", {type: "mini", height: 20, pageUrl: "http://beathaven.org/", text: "Like"})
auth: ->
auth: (callback) ->
BH.log "Requesting new Vkontakte session ..."
window.VK.Auth.getLoginStatus (response) ->
BH.VK.auth_info(response)
callback() if callback?
false
, 8
, window.BH.VK.BITMASK
false
auth_info: (response) ->
@ -38,6 +40,7 @@ class BeatHaven.Models.VK extends Backbone.Model
else
BH.log "Not authorized"
set_favorites: ->
window.VK.Api.call "audio.get", uid: BH.User.vk_id(), (response) ->
BH.User.set_favorites(response.response)

View File

@ -3,7 +3,7 @@ class BeatHaven.Routers.Artist extends Backbone.Router
"artist/:name": "show"
show: (name) ->
artist = new BeatHaven.Models.Artist(id: name)
artist = new BeatHaven.Models.Artist(id: name.replace(/\s|%2BF/g, "+"))
artist.fetch()
view = new BeatHaven.Views.ArtistShow(model: artist)
$("#main").html(view.render().el)

View File

@ -0,0 +1,7 @@
class BeatHaven.Routers.Main extends Backbone.Router
routes:
"tour": "tour"
tour: ->
view = new BeatHaven.Views.MainTour()
$(".tour").html(view.render().el)

View File

@ -0,0 +1,36 @@
.artist-page
%h1 {{ artist_title }}
.artist-info
.pic
%img{ src: "{{ artist_pic }}", alt: "{{ artist_title }}" }
.bio {{& artist_bio}}
.albums
{{#artist_albums}}
.album
.pic
%img{ src: "{{ album_pic }}", alt: "{{ album_title }}" }
%br
.bh-underlay-blue
%a.btn.btn-bh-dark.album-add{ href: "" }
%i.icon-plus.icon-white
Add to playlist
.bh-underlay-green
%a.btn.btn-bh-dark.album-play{ href: "" }
%i.icon-play.icon-white
Play
%h2.title {{ album_title }} ({{ album_year }})
%ul.tracks
{{# album_tracks }}
%li{ "data-id" => "{{ track_id }}" }
%a.btn.btn-round.track-play{ href: "" }
%i.icon-play
%a.btn.btn-round.track-pause{ href: "" }
%i.icon-pause
.title
.inner
%a.track-link{ href: "{{track_url}}" } {{ track_title }}
%span.length {{ track_length }}
%a.btn.btn-round.track-add{ href: "" }
%i.icon-plus

View File

@ -12,7 +12,7 @@
<div class="pic">
<img src="{{album_pic}}" alt="{{album_title}}"><br>
<div class="bh-underlay-blue">
<a href="" class="btn btn-bh-dark album-add"><i class="icon-plus icon-white"></i> Add to playlist</a>
<a href="" class="btn btn-bh-dark album-add"><i class="icon-plus"></i> Add to playlist</a>
</div>
<div class="bh-underlay-green">
<a href="" class="btn btn-bh-dark album-play"><i class="icon-play icon-white"></i> Play</a>

View File

@ -0,0 +1,63 @@
<div class="hero-unit popup step step-1">
<h1>Привет!</h1>
<p></p>
<p>Это Битхейвен, сайт с музыкой. Наверное, ты у нас первый раз, так что давай я в двух словах расскажу что к чему.</p>
<p>Битхейвен не содержит музыки как таковой, он просто умеет хорошо и удобно ее проигрывать. А саму музыку он специально для тебя ищет на <strong>VK.com</strong>. Поэтому прошу тебя для начала авторизоваться через <strong>VK.com</strong>, а потом я покажу что делать дальше.</p>
<p>Авторизуемся?</p>
<p></p>
<p><a href="" class="btn btn-primary btn-large">Хорошо</a></p>
</div>
<div class="hero-unit popup step step-1a">
<h1>Ой!</h1>
<p></p>
<p>Авторизация не сработала.</p>
<p>Скорее всего так вышло из-за того, что ты не стал авторизовываться или разрешать приложению доступ. Напрасно, оно абсолютно безобидное и в принципе не может сделать тебе ничего плохого.</p>
<p>К сожалению, без авторизации <strong>VK.com</strong> я не смогу играть для тебя музыку, извини.</p>
<p>Попробуем еще раз или заглянешь позже?</p>
<p></p>
<p><a href="" class="btn btn-primary btn-large again">Еще раз</a></p>
</div>
<div class="hero-unit popup step step-2">
<h1>Отлично!</h1>
<p></p>
<p>Добро пожаловать домой, <span class="your-name-here"></span>!</p>
<p>Я заглянул в твои музыкальные записи и обратил внимание, что тебе нравится <strong class="your-favorite-artist-here"></strong>. Давай перейдем на страницу этого исполнителя и я покажу тебе куда нажимать.</p>
<p></p>
<p><a href="" class="btn btn-primary btn-large">Пошли!</a></p>
</div>
<div class="step step-3">
<div class="title">Это поиск</div>
<div class="content">
<p>Он твой лучший друг.</p>
<p>Начни вписывать в него название группы или альбома и он с первой же буквы постарается угадать что ты хочешь послушать.</p>
<p></p>
<a href="" class="btn btn-primary tour-step-3">Дальше!</a>
</div>
</div>
<div class="step step-4">
<div class="title">Музыка!</div>
<div class="content">
<p>Чтобы начать слушать музыку достаточно нажать на кнопку слева от любимой песни</p>
<p>Послушаем?</p>
<p></p>
<a href="" class="btn btn-primary tour-step-4">Давай!</a>
</div>
</div>
<div class="step step-5">
<div class="title">Прогресс-бар</div>
<div class="content">
<p>На нем всегда отображается название песни, которая играет в данный момент.</p>
<p>Еще с его помощью можно перематывать песню.</p>
<p></p>
<a href="" class="btn btn-primary tour-step-5">Понял</a>
</div>
</div>
<div class="step step-6">
<div class="title">Кнопочки</div>
<div class="content">
<p>Предыдущая и следующая песня, плей/пауза, все как обычно.</p>
<p>Думаю, ты уже достаточно освоился. Наслаждайся музыкой!</p>
<p></p>
<a href="" class="btn btn-primary tour-step-6">Спасибо!</a>
</div>
</div>

View File

@ -1,5 +1,5 @@
class BeatHaven.Views.ArtistShow extends Backbone.View
template: HoganTemplates["backbone/templates/artist/show"]
template: HoganTemplates["artist/show"]
initialize: ->
@model.on("change", @render, this)

View File

@ -0,0 +1,7 @@
class BeatHaven.Views.MainTour extends Backbone.View
template: HoganTemplates["backbone/templates/main/tour"]
render: ->
$(".fullscreen").show()
$(@el).html(@template.render())
this

View File

@ -0,0 +1,75 @@
window.tour_auth = ->
VK.Auth.login (response) ->
BH.VK.auth_info(response)
if response.session?
$(".tour .step").hide()
$(".tour .step-2").show()
$(".tour .step-2 .your-name-here").text("#{response.session.user.first_name}")
$(".tour .step-2 .your-favorite-artist-here").text("Foo Fighters")
Backbone.history.navigate("/artist/Foo+Fighters", true)
else
$(".tour .step").hide()
$(".tour .step-1a").show()
, BH.VK.BITMASK
$ ->
$(".tour .step-1 a").live "click", (e) ->
e.preventDefault()
tour_auth()
$(".tour .step-1a a.again").live "click", (e) ->
e.preventDefault()
tour_auth()
$(".tour .step-2 a").live "click", (e) ->
e.preventDefault()
$(".tour").hide()
$(".fullscreen").css(opacity: .3)
$(".navbar .search-query").popover(
placement: "bottom"
title: $(".tour .step-3 .title")
content: $(".tour .step-3 .content").html()
html: true
trigger: "manual"
).popover("show")
$("a.tour-step-3").live "click", (e) ->
e.preventDefault()
$(".navbar .search-query").popover("hide")
$(".artist-page .tracks li:first .track-play").popover(
placement: "top"
title: $(".tour .step-4 .title")
content: $(".tour .step-4 .content").html()
html: true
trigger: "manual"
).popover("show")
$("a.tour-step-4").live "click", (e) ->
e.preventDefault()
$(".artist-page .tracks li:first .track-play").popover("hide").trigger("click")
$(".player .progress-bar").popover(
placement: "bottom"
title: $(".tour .step-5 .title")
content: $(".tour .step-5 .content").html()
html: true
trigger: "manual"
).popover("show")
$("a.tour-step-5").live "click", (e) ->
e.preventDefault()
$(".player .progress-bar").popover("hide")
$(".player .controls").popover(
placement: "bottom"
title: $(".tour .step-6 .title")
content: $(".tour .step-6 .content").html()
html: true
trigger: "manual"
).popover("show")
$("a.tour-step-6").live "click", (e) ->
e.preventDefault()
$(".player .controls").popover("hide")
$(".popover").remove()
$(".fullscreen").hide()

View File

@ -59,7 +59,7 @@
border-radius: 50px;
i {
margin: 3px 0 0 -1px;
margin: 6px 0 0 -2px;
}
}
@ -102,6 +102,7 @@
margin: 0;
padding: 0;
color: #808080;
text-shadow: none;
.artist-page {
color: #808080;
@ -132,6 +133,10 @@
top: 3px;
right: 5px;
display: none;
i {
margin-left: -3px;
}
}
// li:hover

View File

@ -1,5 +1,7 @@
@import "bourbon";
@import "bootstrap";
@import "bootstrap_custom";
@import "font-awesome";
@import "noise";
@import "buttons";
@import "autocomplete";
@ -7,6 +9,8 @@
@import "album-track";
@import "player";
@import "auth";
@import "popup";
@import "tour";
@import url(http://fonts.googleapis.com/css?family=Lobster+Two:400,400italic,700);
@import url(http://fonts.googleapis.com/css?family=Source+Sans+Pro);

View File

@ -1,3 +1,14 @@
.navbar .auth {
margin: 14px 10px 0 15px;
.navbar {
.preferences {
margin: 14px 10px 0 15px;
font-size: 27px;
color: #e0e0e0;
text-shadow: 0 0 2px rgba(255, 255, 255, .6);
text-decoration: none;
&:hover {
color: #fafafa;
text-shadow: 0 0 4px rgba(255, 255, 255, .9);
}
}
}

View File

@ -0,0 +1,51 @@
@import "bootstrap/variables"; // Modify this for custom colors, font-sizes, etc
@import "bootstrap/mixins";
// CSS Reset
@import "bootstrap/reset";
// Grid system and page structure
@import "bootstrap/scaffolding";
@import "bootstrap/grid";
@import "bootstrap/layouts";
// Base CSS
@import "bootstrap/type";
@import "bootstrap/code";
@import "bootstrap/forms";
// @import "bootstrap/tables";
// Components: common
// @import "bootstrap/sprites";
// @import "bootstrap/dropdowns";
// @import "bootstrap/wells";
@import "bootstrap/component-animations";
// @import "bootstrap/close";
// Components: Buttons & Alerts
@import "bootstrap/buttons";
// @import "bootstrap/button-groups";
@import "bootstrap/alerts"; // Note: alerts share common CSS with buttons and thus have styles in buttons.less
// Components: Nav
@import "bootstrap/navs";
@import "bootstrap/navbar";
// @import "bootstrap/breadcrumbs";
// @import "bootstrap/pagination";
// @import "bootstrap/pager";
// Components: Popovers
@import "bootstrap/modals";
@import "bootstrap/tooltip";
@import "bootstrap/popovers";
// Components: Misc
// @import "bootstrap/thumbnails";
// @import "bootstrap/labels-badges";
// @import "bootstrap/progress-bars";
// @import "bootstrap/accordion";
// @import "bootstrap/carousel";
@import "bootstrap/hero-unit";
// Utility classes
@import "bootstrap/utilities"; // Has to be last to override when necessary

View File

@ -16,6 +16,7 @@
background-position: 0 0 !important;
color: #fafafa;
text-shadow: 0 1px 1px rgba(0, 0, 0, .35);
&:hover {
color: #ffffff;
}

View File

@ -6,7 +6,17 @@
margin: 3px 0 0 -103px;
a {
margin: 5px 6px 0 -9px;
@include inline-block;
margin: 11px 10px 0 0;
font-size: 27px;
color: #e0e0e0;
text-shadow: 0 0 2px rgba(255, 255, 255, .6);
text-decoration: none;
&:hover {
color: #fafafa;
text-shadow: 0 0 4px rgba(255, 255, 255, .9);
}
}
.pause {

View File

@ -0,0 +1,19 @@
.fullscreen {
display: none;
position: absolute;
z-index: 9999;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .7);
}
.popup {
position: absolute;
z-index: 99999;
top: 50%;
left: 50%;
width: 640px;
height: 360px;
margin: -240px 0 0 -380px;
}

View File

@ -0,0 +1,13 @@
.tour .step {
display: none;
}
.tour .step-1 {
display: block;
}
.popover {
z-index: 99999;
p {
margin: 8px 0;
}
}

View File

@ -1,15 +1,13 @@
module Api
class AlbumsController < ::ApplicationController
class AlbumsController < BaseController
def picture
album = Album.find(params[:id])
redirect_to album.load_pic
end
def show
album = Album.find(params[:id])
return render json: { fail: true } if album.nil?
render json: album.dump_json
@album = Album.find(params[:id])
return render json: { fail: true } if @album.nil?
end
end
end

View File

@ -1,10 +1,8 @@
module Api
class ArtistsController < ::ApplicationController
class ArtistsController < BaseController
def show
artist = Artist.with_name(params[:id].gsub("+", " "))
return render json: { fail: true } if artist.nil?
render json: artist.dump_json
@artist = Artist.with_name(params[:id].gsub("+", " "))
return render json: { fail: true } if @artist.nil?
end
end
end

View File

@ -0,0 +1,5 @@
module Api
class BaseController < ::ApplicationController
respond_to :json
end
end

View File

@ -1,5 +1,5 @@
module Api
class SearchController < ApplicationController
class SearchController < BaseController
def complete
return render json: { suggestions: [] } if params[:query].to_s.length == 0

View File

@ -1,5 +1,5 @@
module Api
class SessionController < ApplicationController
class SessionController < BaseController
def auth
render json: { error: "Signature verification failed!" } unless request_valid?

View File

@ -6,10 +6,10 @@ class Album < ActiveRecord::Base
self
.where('"albums"."year" > ?', 0)
.where(is_hidden: false)
.joins(:tracks)
.group('"albums"."id"')
.having('count("tracks"."id") > ?', 0)
.order('"albums"."year" ASC')
.includes(:tracks)
# .group('"albums"."id"')
# .having('count("tracks"."id") > ?', 0)
# .order('"albums"."year" ASC')
}
attr_accessible :artist_id, :pic, :rovi_id, :title, :year, :is_hidden
@ -24,7 +24,13 @@ class Album < ActiveRecord::Base
end
def load_pic
info = BeatParser::Sources::Lastfm.album_info((artist.nil? ? VA : artist.name), title)
info = begin
response = LastFM::Album.get_info(artist: (artist.nil? ? VA : artist.name), album: title)
{ pic: response["album"]["image"][3]["#text"] }
rescue => e
{ pic: nil }
end
unless info[:pic].nil?
update_attributes(pic: info[:pic])
info[:pic]
@ -37,69 +43,35 @@ class Album < ActiveRecord::Base
"/album/#{id}"
end
def dump_json
Jbuilder.encode do |j|
j.album_title title
j.album_year year
j.album_pic pic_safe
j.album_tracks tracks.to_a do |j, track|
j.track_id track.id
j.track_title track.title
j.track_duration track.duration
j.track_artists track.artists do |j, artist|
j.artist_title artist.name
j.artist_url artist.url
end
j.track_disc track.disc_id
j.track_position track.position
j.track_length track.length
j.meta do |j|
j.id track.id
j.title track.title
j.duration track.duration
j.length track.length
j.artists track.artists.map(&:name)
j.album title
j.album_pic pic_safe
end
end
end
end
def import
return unless rovi_id?
Album.import(Robbie::Album.find(rovi_id))
robbie_album = Robbie::Album.find(rovi_id)
return if robbie_album.nil?
update_attributes(
title: robbie_album.title,
year: robbie_album.year,
tracks: robbie_album.tracks.each { |robbie_track|
track = Track.find_or_create_by_rovi_id(robbie_track.id)
track.update_attributes(
disc_id: robbie_track.disc_id,
position: robbie_track.position,
title: robbie_track.title,
duration: robbie_track.duration,
artists: robbie_track.artists.map { |robbie_artist|
track_artist = Artist.find_or_create_by_rovi_id(robbie_artist.id)
track_artist.update_attributes(
name: robbie_artist.name
)
track_artist
}
)
track
}
)
self
end
class << self
def import(rovi_album)
data = BeatParser::Aggregator.new.album(rovi_album.id)
album = Album.find_or_create_by_rovi_id(data[:id])
album.update_attributes(
title: data[:title],
year: data[:year].to_i
)
data[:tracks].each do |track_meta|
track = Track.find_or_create_by_rovi_id(track_meta[:id])
track.update_attributes(
album_id: album.id,
disc_id: track_meta[:disc_id],
position: track_meta[:position],
title: track_meta[:title],
duration: track_meta[:duration]
)
track_meta[:artists].each do |performer|
performer_artist = Artist.find_or_create_by_rovi_id(performer[:id])
performer_artist.update_attributes(
name: performer[:name]
)
Performer.find_or_create_by_artist_id_and_track_id(performer_artist.id, track.id)
end
end
album
end
end
end

View File

@ -6,6 +6,10 @@ class Artist < ActiveRecord::Base
attr_accessible :bio, :is_group, :name, :pic, :rovi_id
scope :discography, lambda {
includes(:albums).includes(:tracks)
}
def loaded?
pic? && bio?
end
@ -14,47 +18,36 @@ class Artist < ActiveRecord::Base
"/artist/#{name.gsub(/\s/, "+")}"
end
def dump_json
Jbuilder.encode do |j|
j.artist_title name
j.artist_pic pic
j.artist_bio bio
j.artist_loaded loaded?
j.artist_url url
j.artist_albums albums.shown.to_a do |j, album|
j.album_title album.title
j.album_year album.year
j.album_pic album.pic_safe
j.album_tracks album.tracks.to_a do |j, track|
j.track_id track.id
j.track_title track.title
j.track_duration track.duration
j.track_disc track.disc_id
j.track_position track.position
j.meta do |j|
j.id track.id
j.title track.title
j.duration track.duration
j.length track.length
j.artists track.artists.map(&:name)
j.album album.title
j.album_pic album.pic_safe
end
end
end
end
end
def import
return unless rovi_id?
Artist.import(Robbie::Artist.find(rovi_id))
robbie_artist = Robbie::Artist.find(rovi_id)
return if robbie_artist.nil?
update_attributes(
name: robbie_artist.name,
is_group: robbie_artist.is_group,
pic: nil,
bio: nil,
albums: robbie_artist.albums.map{ |robbie_album|
Album.find_or_create_by_rovi_id(robbie_album.id).import
},
genres: robbie_artist.genres.map{ |robbie_genre|
genre = Genre.find_or_create_by_rovi_id(robbie_genre.id)
genre.update_attributes(
name: robbie_genre.name
)
genre
}
)
self
end
class << self
def with_name(name)
# DB lookup
artist = find_by_name(name)
artist = where(name: name).discography.first
return artist unless artist.nil?
# Rovi correction
@ -62,51 +55,7 @@ class Artist < ActiveRecord::Base
return artist if rovi_artist && artist = find_by_rovi_id(rovi_artist.id)
# Parsing artist if ok
import(rovi_artist) if rovi_artist
end
def import(rovi_artist)
data = BeatParser::Aggregator.new.artist(rovi_artist.id)
artist = Artist.find_or_create_by_rovi_id(data[:id])
artist.update_attributes(
name: data[:name],
is_group: data[:is_group],
pic: data[:pic],
bio: data[:bio]
)
data[:albums].each do |album_meta|
album = Album.find_or_create_by_rovi_id(album_meta[:id])
album.update_attributes(
artist_id: artist.id,
title: album_meta[:title],
year: album_meta[:year].to_i
)
album_meta[:tracks].each do |track_meta|
track = Track.find_or_create_by_rovi_id(track_meta[:id])
track.update_attributes(
album_id: album.id,
disc_id: track_meta[:disc_id],
position: track_meta[:position],
title: track_meta[:title],
duration: track_meta[:duration]
)
track_meta[:artists].each do |performer|
performer_artist = Artist.find_or_create_by_rovi_id(performer[:id])
performer_artist.update_attributes(
name: performer[:name]
)
Performer.find_or_create_by_artist_id_and_track_id(performer_artist.id, track.id)
end
end
end
data[:genres].each do |genre_meta|
genre = Genre.find_or_create_by_rovi_id(genre_meta[:id])
genre.update_attributes(
name: genre_meta[:name]
)
ArtistGenre.find_or_create_by_artist_id_and_genre_id(artist.id, genre.id)
end
artist
Artist.create(rovi_id: robbie_artist.id).import
end
end
end

View File

@ -4,6 +4,9 @@ class Track < ActiveRecord::Base
has_many :artists, through: :performers
attr_accessible :album_id, :disc_id, :duration, :position, :rovi_id, :title
scope :with_artists, lambda{
includes(:artists)
}
def length
return if duration.nil?

View File

@ -0,0 +1,24 @@
json.album_title @album.title
json.album_year @album.year
json.album_pic @album.pic_safe
json.album_tracks @album.tracks.to_a do |json, track|
json.track_id track.id
json.track_title track.title
json.track_duration track.duration
json.track_artists track.artists do |json, artist|
json.artist_title artist.name
json.artist_url artist.url
end
json.track_disc track.disc_id
json.track_position track.position
json.track_length track.length
json.meta do |json|
json.id track.id
json.title track.title
json.duration track.duration
json.length track.length
json.artists track.artists.map(&:name)
json.album title
json.album_pic pic_safe
end
end

View File

@ -0,0 +1,26 @@
json.artist_title @artist.name
json.artist_pic @artist.pic
json.artist_bio @artist.bio
json.artist_loaded @artist.loaded?
json.artist_url @artist.url
json.artist_albums @artist.albums.shown.to_a do |json, album|
json.album_title album.title
json.album_year album.year
json.album_pic album.pic_safe
json.album_tracks album.tracks.to_a do |json, track|
json.track_id track.id
json.track_title track.title
json.track_length track.length
json.track_disc track.disc_id
json.track_position track.position
json.meta do |json|
json.id track.id
json.title track.title
json.duration track.duration
json.length track.length
json.artists track.artists.map(&:name)
json.album album.title
json.album_pic album.pic_safe
end
end
end

View File

@ -1,13 +0,0 @@
<div class="player pull-right">
<div class="controls">
<a href="" class="btn btn-bh-dark prev"><i class="icon-backward icon-white"></i></a>
<a href="" class="btn btn-bh-dark play"><i class="icon-play icon-white"></i></a>
<a href="" class="btn btn-bh-dark pause"><i class="icon-pause icon-white"></i></a>
<a href="" class="btn btn-bh-dark next"><i class="icon-forward icon-white"></i></a>
</div>
<div class="progress-bar">
<div class="bar"></div>
<div class="title">Waiting...</div>
<div class="move-it"></div>
</div>
</div>

View File

@ -0,0 +1,10 @@
.player.pull-right
.controls
%a.icon-backward.prev{ href: "" }
%a.icon-play.play{ href: "" }
%a.icon-pause.pause{ href: "" }
%a.icon-forward.next{ href: "" }
.progress-bar
.bar
.title Waiting...
.move-it

View File

@ -1,32 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>BeatHaven</title>
<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
<%= javascript_include_tag "http://vkontakte.ru/js/api/openapi.js" %>
<%= csrf_meta_tags %>
<script type="text/javascript" charset="utf-8">
window.VK_APP_ID = 2335068;
</script>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="">BeatHaven</a>
<form class="navbar-search pull-left">
<input type="search" placeholder="Search" class="search-query">
</form>
<div class="auth pull-right">
<a href=""><i class="icon-user icon-white"></i></a>
</div>
<%= render partial: "player" %>
</div>
</div>
</div>
<div class="container" id="main">You can't steal what's free</div>
</body>
</html>

View File

@ -0,0 +1,26 @@
!!!
%html
%head
%title BeatHaven
= stylesheet_link_tag "application", media: "all"
= javascript_include_tag "application"
= javascript_include_tag "http://vkontakte.ru/js/api/openapi.js"
= csrf_meta_tags
:javascript
window.VK_APP_ID = 2335068;
%body
%div.navbar.navbar-fixed-top
.navbar-inner
.container
%a.brand{ href: "/" } BeatHaven
%form.navbar-search.pull-left
%input.search-query{ type: "search", placeholder: "Search" }
.pull-right
%a.icon-cog.preferences{ href: "/preferences" }
= render partial: "player"
.container#main You can't steal what's free
.fullscreen
.tour
%div{ style: "font: 32px FontAwesome;"} &#024

View File

@ -10,7 +10,7 @@ require "sprockets/railtie"
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
Bundler.require(*Rails.groups(:assets => %w[ development test ]))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end

View File

@ -33,5 +33,6 @@ BeatHaven::Application.configure do
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
config.assets.debug = false
config.assets.logger = nil
end

View File

@ -25,7 +25,7 @@ BeatHaven::Application.configure do
# Specifies the header that your server uses for sending files
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true

View File

@ -1,3 +1,3 @@
HoganAssets::Config.configure do |config|
config.path_prefix = "backbone/templates/"
config.path_prefix = "backbone/templates"
end

View File

@ -1,6 +1,6 @@
BeatHaven::Application.routes.draw do
namespace :api do
resources :artists, only: [:show], constraints: { id: /.+/ }
resources :artists, only: [:show], constraints: { id: /.+/ }, format: :json
resources :albums, only: [:show, :picture] do
member { get :picture }
end