More stable, I hope...
This commit is contained in:
parent
8cf69faf32
commit
453e809646
|
@ -3,6 +3,14 @@ class window.Ajax
|
||||||
referer: false
|
referer: false
|
||||||
previous_page: null
|
previous_page: null
|
||||||
|
|
||||||
|
showSpinner: ->
|
||||||
|
$('#artist-load-spinner').show()
|
||||||
|
false
|
||||||
|
|
||||||
|
hideSpinner: ->
|
||||||
|
$('#artist-load-spinner').hide()
|
||||||
|
false
|
||||||
|
|
||||||
load404Page: ->
|
load404Page: ->
|
||||||
$.get '/404.html', (data) ->
|
$.get '/404.html', (data) ->
|
||||||
$('.data-container .inner').html data
|
$('.data-container .inner').html data
|
||||||
|
@ -43,19 +51,22 @@ class window.Ajax
|
||||||
detectPage: () ->
|
detectPage: () ->
|
||||||
return false if @previous_page == _ajax.getAnchor()
|
return false if @previous_page == _ajax.getAnchor()
|
||||||
@previous_page = _ajax.getAnchor()
|
@previous_page = _ajax.getAnchor()
|
||||||
|
path = _ajax.getAnchor()
|
||||||
|
if path == "/"
|
||||||
|
path = "/greetings/"
|
||||||
|
|
||||||
log "Ajax controller is detecting page ..."
|
log "Ajax controller is detecting page for #{path} ..."
|
||||||
|
|
||||||
if m = _ajax.getAnchor().match /\/artist\/(.+)\//
|
if m = path.match /\/artist\/(.+)\//
|
||||||
_search.loadArtistData m[1]
|
_search.loadArtistData m[1]
|
||||||
else if _ajax.getAnchor().match /\/settings\//
|
else if path.match /\/settings\//
|
||||||
_settings.loadSettingsPage()
|
_settings.loadSettingsPage()
|
||||||
else if _ajax.getAnchor().match /\/about\//
|
|
||||||
_ajax.loadAboutPage()
|
|
||||||
else if _ajax.getAnchor().match /\/stat\//
|
|
||||||
_ajax.loadStatPage()
|
|
||||||
else
|
else
|
||||||
_ajax.loadIndexPage();
|
this.showSpinner()
|
||||||
|
_session.query path, {}, (response) ->
|
||||||
|
_page.render response
|
||||||
|
_ajax.hideSpinner()
|
||||||
|
false
|
||||||
false
|
false
|
||||||
|
|
||||||
$(window).bind 'hashchange', ->
|
$(window).bind 'hashchange', ->
|
||||||
|
|
|
@ -15,6 +15,9 @@ jQuery ->
|
||||||
l.href = 'http://beathaven.org/'+ l.hash
|
l.href = 'http://beathaven.org/'+ l.hash
|
||||||
|
|
||||||
window.log = (str) ->
|
window.log = (str) ->
|
||||||
|
_beathaven.logs.push
|
||||||
|
timestamp: Date()
|
||||||
|
info: str
|
||||||
console.log(str) if console?
|
console.log(str) if console?
|
||||||
|
|
||||||
$.ajaxSetup
|
$.ajaxSetup
|
||||||
|
@ -28,9 +31,10 @@ class window.BeatHaven
|
||||||
|
|
||||||
last_height: false
|
last_height: false
|
||||||
lang: 'ru'
|
lang: 'ru'
|
||||||
|
logs: []
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
log "Initiatin BeatHaven ..."
|
log "Initiating BeatHaven ..."
|
||||||
|
|
||||||
window._vkontakte = new Vkontakte(2335068)
|
window._vkontakte = new Vkontakte(2335068)
|
||||||
window._vkontakte.init()
|
window._vkontakte.init()
|
||||||
|
|
|
@ -1,5 +1,22 @@
|
||||||
class window.Page
|
class window.Page
|
||||||
|
|
||||||
|
@data: {}
|
||||||
|
@html: ""
|
||||||
|
@status: ""
|
||||||
|
|
||||||
|
render: (params) ->
|
||||||
|
@data = params.data
|
||||||
|
@html = params.html
|
||||||
|
@title = params.title
|
||||||
|
@status = params.status
|
||||||
|
|
||||||
|
log "Rendering page titled \"#{@title}\" of type \"#{params.renderer}\" ..."
|
||||||
|
$('#content').html(@html)
|
||||||
|
|
||||||
|
# yaCounter7596904.hit _ajax.getAnchor(), @title, _ajax.referer
|
||||||
|
_ajax.setTitle @title
|
||||||
|
false
|
||||||
|
|
||||||
print: (html) ->
|
print: (html) ->
|
||||||
$('#content').html(html)
|
$('#content').html(html)
|
||||||
false
|
false
|
||||||
|
|
|
@ -12,7 +12,9 @@ class window.Session
|
||||||
@vk_params = _params
|
@vk_params = _params
|
||||||
|
|
||||||
setUser: (user) ->
|
setUser: (user) ->
|
||||||
|
log "Setting user ..."
|
||||||
@user = user
|
@user = user
|
||||||
|
log "Hello, #{if user.name? then user.name else "%username%"}!"
|
||||||
false
|
false
|
||||||
|
|
||||||
getUser: ->
|
getUser: ->
|
||||||
|
|
|
@ -8,11 +8,10 @@ class window.Vkontakte
|
||||||
@api_id
|
@api_id
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
log "Initiatin Vkontakte API ..."
|
log "Initiating Vkontakte API ..."
|
||||||
window.vkAsyncInit = ->
|
window.vkAsyncInit = ->
|
||||||
VK.init apiId: _vkontakte.getApiId()
|
VK.init apiId: _vkontakte.getApiId()
|
||||||
VK.Auth.getLoginStatus (response) ->
|
_vkontakte.auth()
|
||||||
_vkontakte.authInfo(response)
|
|
||||||
|
|
||||||
setTimeout ->
|
setTimeout ->
|
||||||
$('#vk_api_transport').append($('<script async="async" type="text/javascript" src="http://vkontakte.ru/js/api/openapi.js">'))
|
$('#vk_api_transport').append($('<script async="async" type="text/javascript" src="http://vkontakte.ru/js/api/openapi.js">'))
|
||||||
|
@ -50,10 +49,13 @@ class window.Vkontakte
|
||||||
$('.fullscreen').hide();
|
$('.fullscreen').hide();
|
||||||
|
|
||||||
if response.session.expire?
|
if response.session.expire?
|
||||||
|
expire_in = response.session.expire * 1000 - new Date().getTime()
|
||||||
|
log "Session will expire in #{Math.round(expire_in / 1000)} seconds"
|
||||||
setTimeout ->
|
setTimeout ->
|
||||||
|
log "Session expired"
|
||||||
_vkontakte.auth()
|
_vkontakte.auth()
|
||||||
false
|
false
|
||||||
, response.session.expire * 1000 - new Date().getTime() + 1000
|
, expire_in + 1000
|
||||||
else
|
else
|
||||||
_session = new Session({})
|
_session = new Session({})
|
||||||
_session.setUser {}
|
_session.setUser {}
|
||||||
|
@ -63,6 +65,7 @@ class window.Vkontakte
|
||||||
$('.fullscreen').hide();
|
$('.fullscreen').hide();
|
||||||
|
|
||||||
auth: ->
|
auth: ->
|
||||||
|
log "Requesting new Vkontakte session ..."
|
||||||
VK.Auth.getLoginStatus (response) ->
|
VK.Auth.getLoginStatus (response) ->
|
||||||
_vkontakte.authInfo(response)
|
_vkontakte.authInfo(response)
|
||||||
false
|
false
|
||||||
|
|
|
@ -10,11 +10,13 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def compile_page params
|
def compile_page params
|
||||||
@data = params[:data]
|
@data = params[:data] unless params[:data].nil?
|
||||||
render json: {
|
render json: {
|
||||||
status: (params[:status] unless params[:status].nil?),
|
renderer: "unified",
|
||||||
data: @data,
|
data: @data,
|
||||||
html: render_compact_partial(params[:partial])
|
html: render_compact_partial(params[:partial]),
|
||||||
|
title: params[:title],
|
||||||
|
status: (params[:status] unless params[:status].nil?)
|
||||||
}, include: (params[:include] unless params[:include].nil?)
|
}, include: (params[:include] unless params[:include].nil?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,18 +4,20 @@ class PageController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def greetings
|
def greetings
|
||||||
render partial: 'greetings'
|
compile_page(partial: "page/greetings", title: t("title.greetings"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def about
|
def about
|
||||||
render partial: 'about'
|
compile_page(partial: "page/about", title: t("title.about"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def stat
|
def stat
|
||||||
@artists = Artist.count
|
data = {
|
||||||
@albums = Album.count
|
artists: Artist.count,
|
||||||
@tracks = Track.count
|
albums: Album.count,
|
||||||
@users = User.count
|
tracks: Track.count,
|
||||||
render partial: 'stat'
|
users: User.count
|
||||||
|
}
|
||||||
|
compile_page(data: data, partial: "page/stat", title: t("title.stat"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
%h2 BeatHaven statistics
|
|
||||||
|
|
||||||
%table.zebra-striped.stats
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
%strong Artists
|
|
||||||
%td= @artists
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
%strong Albums
|
|
||||||
%td= @albums
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
%strong Tracks
|
|
||||||
%td= @tracks
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
%strong Users
|
|
||||||
%td= @users
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
%h2= t('stat.title')
|
||||||
|
|
||||||
|
%table.zebra-striped.stats
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%strong= t('stat.artists')
|
||||||
|
%td= @data[:artists]
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%strong= t('stat.albums')
|
||||||
|
%td= @data[:albums]
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%strong= t('stat.tracks')
|
||||||
|
%td= @data[:tracks]
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%strong= t('stat.users')
|
||||||
|
%td= @data[:users]
|
|
@ -1,19 +0,0 @@
|
||||||
%h2 Статистика BeatHaven
|
|
||||||
|
|
||||||
%table.zebra-striped.stats
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
%strong Исполнителей
|
|
||||||
%td= @artists
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
%strong Альбомов
|
|
||||||
%td= @albums
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
%strong Треков
|
|
||||||
%td= @tracks
|
|
||||||
%tr
|
|
||||||
%td
|
|
||||||
%strong Пользователей
|
|
||||||
%td= @users
|
|
|
@ -12,11 +12,23 @@ en:
|
||||||
settings: "Settings"
|
settings: "Settings"
|
||||||
your_ad_here: "Your ad couldn't<br/>be here"
|
your_ad_here: "Your ad couldn't<br/>be here"
|
||||||
|
|
||||||
|
title:
|
||||||
|
greetings: Greetings
|
||||||
|
about: About
|
||||||
|
stat: Stats
|
||||||
|
|
||||||
search:
|
search:
|
||||||
fail: "Something very bad happened while we tried out to load some info about this artist. How about some other one?"
|
fail: "Something very bad happened while we tried out to load some info about this artist. How about some other one?"
|
||||||
loading: "Artist info is loading for the first time now. Usually it takes less than a minute, please wait a bit."
|
loading: "Artist info is loading for the first time now. Usually it takes less than a minute, please wait a bit."
|
||||||
typo: "Misspelled?"
|
typo: "Misspelled?"
|
||||||
|
|
||||||
|
stat:
|
||||||
|
title: BeatHaven stats
|
||||||
|
artists: Artists
|
||||||
|
albums: Albums
|
||||||
|
tracks: Tracks
|
||||||
|
users: Users
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
title: "Settings"
|
title: "Settings"
|
||||||
tab:
|
tab:
|
||||||
|
|
|
@ -12,11 +12,23 @@ ru:
|
||||||
settings: "Настройки"
|
settings: "Настройки"
|
||||||
your_ad_here: "Здесь не могла бы<br/>быть Ваша реклама"
|
your_ad_here: "Здесь не могла бы<br/>быть Ваша реклама"
|
||||||
|
|
||||||
|
title:
|
||||||
|
greetings: Привет
|
||||||
|
about: О проекте
|
||||||
|
stat: Статистика
|
||||||
|
|
||||||
search:
|
search:
|
||||||
fail: "Что-то ужасное произошло пока мы собирали информацию об этом исполнителе. Может пока поищем другого?"
|
fail: "Что-то ужасное произошло пока мы собирали информацию об этом исполнителе. Может пока поищем другого?"
|
||||||
loading: "Прямо сейчас мы собираем всю возможною информацию об этом исполнителе в первый раз. Обычно это занимает меньше минуты."
|
loading: "Прямо сейчас мы собираем всю возможною информацию об этом исполнителе в первый раз. Обычно это занимает меньше минуты."
|
||||||
typo: "Опечатались?"
|
typo: "Опечатались?"
|
||||||
|
|
||||||
|
stat:
|
||||||
|
title: Статистика BeatHaven
|
||||||
|
artists: Исполнителей
|
||||||
|
albums: Альбомов
|
||||||
|
tracks: Треков
|
||||||
|
users: Пользователей
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
title: "Настройки"
|
title: "Настройки"
|
||||||
tab:
|
tab:
|
||||||
|
|
Loading…
Reference in New Issue