1
0
Fork 0

Cache fixes, vk like

This commit is contained in:
magnolia-fan 2011-11-29 00:44:51 +04:00
parent 23cf09613d
commit 06f6b7a9d2
8 changed files with 14 additions and 12 deletions

View File

@ -32,7 +32,7 @@ class window.Ajax
return false if @previous_page == _ajax.getAnchor()
@previous_page = _ajax.getAnchor()
path = _ajax.getAnchor()
if path == "/"
if path in ["", "/"]
path = "/greetings/"
log "Ajax controller is detecting page for #{path} ..."

View File

@ -13,6 +13,7 @@ class window.Vkontakte
window.vkAsyncInit = ->
VK.init apiId: _vkontakte.getApiId()
_vkontakte.auth()
VK.Widgets.Like("vk-like", {type: "mini", height: 20})
setTimeout ->

View File

@ -42,11 +42,12 @@ table.stats {
}
}
.fb-like, .vk-like {
.fb-like, #vk-like {
float: left;
clear: none !important;
}
.vk-like td {
#vk-like td {
padding: 0 !important;
border: none;
line-height: 12px;

View File

@ -11,8 +11,8 @@ class ApplicationController < ActionController::Base
def compile_page params
compiler = lambda do |params|
@data = params[:data].call(&(params[:data].lambda? ? :call : :serialize)) unless params[:data].nil?
@status = params[:status] unless params[:status].nil?
@data = params[:data].is_a?(Proc) ? params[:data].call : params[:data].serialize unless params[:data].nil?
@status = params[:status]
{
renderer: "unified",
data: @data,
@ -23,8 +23,8 @@ class ApplicationController < ActionController::Base
}.to_json.to_s
end
unless params[:cache].nil?
data = Rails.cache.fetch(params[:cache_key] || cache_key_for(params[:data]), expires_in: params[:cache]) do
unless params[:cache_for].nil?
data = Rails.cache.fetch(params[:cache_key] || cache_key_for(params[:data]), expires_in: params[:cache_for]) do
compiler.call(params)
end
else

View File

@ -32,7 +32,7 @@ class ArtistController < ApplicationController
title: @artist.name,
status: @artist.status_str,
callback: {object: :player, action: :updateLibrary},
cache: 3.minutes
cache_for: 1.day
)
end

View File

@ -22,7 +22,7 @@ class PlaylistController < ApplicationController
partial: "playlist/tracks",
title: "#{artist.name}: Last.fm TOP 50",
callback: {object: :player, action: :updateLibrary},
cache: 3.minutes,
cache_for: 7.days,
cache_key: "lastfmtop50_#{artist.id}"
)
end

View File

@ -1,4 +1,4 @@
.fb-like{ "data-href" => "http://facebook.com/BeatHavenHQ", "data-send" => "false", "data-layout" => "button_count", "data-width" => "100", "data-show-faces" => "false", "data-font" => "lucida grande" }
.vk-like
#vk-like
%script{ type: "text/javascript" }
= "document.write(VK.Share.button(false, {type: \"round\", text: \"#{t('global.like')}\"}));".html_safe
= "VK.Widgets.Like(\"vk_like\", {type: \"button\", height: 20, pageUrl: \"http://beathaven.org/\", text: \"#{t('global.like')}\"})"

View File

@ -10,7 +10,7 @@
%link{ rel: "search", type: "application/opensearchdescription+xml", title: "BeatHaven", href: "/opensearch.xml"}
= stylesheet_link_tag :application, cache: true
= javascript_include_tag :application, cache: true
= javascript_include_tag "http://vkontakte.ru/js/api/share.js", charset: "windows-1251"
= javascript_include_tag "http://userapi.com/js/api/openapi.js?45", charset: "windows-1251"
%body
#fb-root
.topbar-wrapper