CSRF token fix
This commit is contained in:
parent
69b392b739
commit
0dc5f24c6c
app
@ -10,91 +10,95 @@ window._page = null
|
|||||||
window._settings = null
|
window._settings = null
|
||||||
|
|
||||||
$ ->
|
$ ->
|
||||||
l = document.location
|
l = document.location
|
||||||
if l.hostname not in ['beathaven.org', 'dev.beathaven.org']
|
if l.hostname not in ['beathaven.org', 'dev.beathaven.org']
|
||||||
l.href = 'http://beathaven.org/'+ l.hash
|
l.href = 'http://beathaven.org/'+ l.hash
|
||||||
|
|
||||||
window._beathaven = new BeatHaven()
|
$.ajaxSetup
|
||||||
window._beathaven.init()
|
beforeSend: (xhr) ->
|
||||||
|
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))
|
||||||
|
|
||||||
|
window._beathaven = new BeatHaven()
|
||||||
|
window._beathaven.init()
|
||||||
|
|
||||||
class window.BeatHaven
|
class window.BeatHaven
|
||||||
|
|
||||||
last_height: false
|
last_height: false
|
||||||
lang: 'ru'
|
lang: 'ru'
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
window._vkontakte = new Vkontakte(2335068)
|
window._vkontakte = new Vkontakte(2335068)
|
||||||
window._vkontakte.init()
|
window._vkontakte.init()
|
||||||
window._vk_music = new VkontakteMusic
|
window._vk_music = new VkontakteMusic
|
||||||
|
|
||||||
window._ajax = new Ajax()
|
window._ajax = new Ajax()
|
||||||
|
|
||||||
window._player = new Player()
|
window._player = new Player()
|
||||||
window._player.initJplayer()
|
window._player.initJplayer()
|
||||||
|
|
||||||
window._search = new Search()
|
window._search = new Search()
|
||||||
|
|
||||||
window._page = new Page()
|
window._page = new Page()
|
||||||
|
|
||||||
window._settings = new Settings()
|
window._settings = new Settings()
|
||||||
|
|
||||||
this.setupAutocomplete()
|
this.setupAutocomplete()
|
||||||
|
|
||||||
false
|
false
|
||||||
|
|
||||||
setupAutocomplete: ->
|
setupAutocomplete: ->
|
||||||
$('#search').first().bh_autocomplete
|
$('#search').first().bh_autocomplete
|
||||||
serviceUrl: '/artist/autocomplete' # Страница для обработки запросов автозаполнения
|
serviceUrl: '/artist/autocomplete' # Страница для обработки запросов автозаполнения
|
||||||
minChars: 3 # Минимальная длина запроса для срабатывания автозаполнения
|
minChars: 3 # Минимальная длина запроса для срабатывания автозаполнения
|
||||||
delimiter: /(,|;)\s*/ # Разделитель для нескольких запросов, символ или регулярное выражение
|
delimiter: /(,|;)\s*/ # Разделитель для нескольких запросов, символ или регулярное выражение
|
||||||
maxHeight: 400 # Максимальная высота списка подсказок, в пикселях
|
maxHeight: 400 # Максимальная высота списка подсказок, в пикселях
|
||||||
width: 415 # Ширина списка
|
width: 415 # Ширина списка
|
||||||
zIndex: 9999 # z-index списка
|
zIndex: 9999 # z-index списка
|
||||||
deferRequestBy: 500 # Задержка запроса (мсек)
|
deferRequestBy: 500 # Задержка запроса (мсек)
|
||||||
containerId: 'autocomplete-container'
|
containerId: 'autocomplete-container'
|
||||||
containerItemsId: 'autocomplete-items'
|
containerItemsId: 'autocomplete-items'
|
||||||
onSelect: ->
|
onSelect: ->
|
||||||
_search.loadArtistData $('#search').val()
|
_search.loadArtistData $('#search').val()
|
||||||
|
|
||||||
localizeHTML: (obj, lang) ->
|
localizeHTML: (obj, lang) ->
|
||||||
unless obj?
|
unless obj?
|
||||||
obj = $('body')
|
obj = $('body')
|
||||||
unless lang?
|
unless lang?
|
||||||
lang = _beathaven.lang
|
lang = _beathaven.lang
|
||||||
$(obj).find('[data-ls]').each ->
|
$(obj).find('[data-ls]').each ->
|
||||||
if _locale[$(this).attr 'data-ls']? and _locale[$(this).attr 'data-ls'][lang]?
|
if _locale[$(this).attr 'data-ls']? and _locale[$(this).attr 'data-ls'][lang]?
|
||||||
if this.nodeName is 'INPUT'
|
if this.nodeName is 'INPUT'
|
||||||
$(this).val _locale[$(this).attr 'data-ls'][lang]
|
$(this).val _locale[$(this).attr 'data-ls'][lang]
|
||||||
else
|
else
|
||||||
$(this).text _locale[$(this).attr 'data-ls'][lang]
|
$(this).text _locale[$(this).attr 'data-ls'][lang]
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
ls: (id, lang) ->
|
ls: (id, lang) ->
|
||||||
unless lang?
|
unless lang?
|
||||||
lang = _beathaven.lang
|
lang = _beathaven.lang
|
||||||
if _locale[id]? and _locale[id][lang]?
|
if _locale[id]? and _locale[id][lang]?
|
||||||
_locale[id][lang]
|
_locale[id][lang]
|
||||||
else
|
else
|
||||||
id
|
id
|
||||||
|
|
||||||
String::htmlsafe = ->
|
String::htmlsafe = ->
|
||||||
replaces = [
|
replaces = [
|
||||||
["\\", "\\\\"]
|
["\\", "\\\\"]
|
||||||
["\"", """]
|
["\"", """]
|
||||||
["<", "<"]
|
["<", "<"]
|
||||||
[">", ">"]
|
[">", ">"]
|
||||||
]
|
]
|
||||||
str = this
|
str = this
|
||||||
for item in replaces
|
for item in replaces
|
||||||
str = str.replace item[0], item[1]
|
str = str.replace item[0], item[1]
|
||||||
str
|
str
|
||||||
|
|
||||||
String::trim = ->
|
String::trim = ->
|
||||||
str = this
|
str = this
|
||||||
while str.indexOf(' ') != -1
|
while str.indexOf(' ') != -1
|
||||||
str = str.replace(' ', ' ')
|
str = str.replace(' ', ' ')
|
||||||
if str.charAt(0) == ' '
|
if str.charAt(0) == ' '
|
||||||
str = str.substring 1
|
str = str.substring 1
|
||||||
if str.charAt(str.length - 1) == ' '
|
if str.charAt(str.length - 1) == ' '
|
||||||
str = str.substring(0, str.length - 1)
|
str = str.substring(0, str.length - 1)
|
||||||
str
|
str
|
||||||
|
@ -13,8 +13,6 @@ class window.Session
|
|||||||
|
|
||||||
setUser: (user) ->
|
setUser: (user) ->
|
||||||
@user = user
|
@user = user
|
||||||
_beathaven.lang = @user.lang || 'ru'
|
|
||||||
_beathaven.localizeHTML()
|
|
||||||
false
|
false
|
||||||
|
|
||||||
getUser: ->
|
getUser: ->
|
||||||
@ -22,6 +20,7 @@ class window.Session
|
|||||||
|
|
||||||
query: (url, params, callback) ->
|
query: (url, params, callback) ->
|
||||||
q_params = $.extend {}, @vk_params, params
|
q_params = $.extend {}, @vk_params, params
|
||||||
|
q_params.authenticity_token = $('meta[name="csrf-token"]').attr('content')
|
||||||
$.post url, q_params, callback
|
$.post url, q_params, callback
|
||||||
false
|
false
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ class window.Vkontakte
|
|||||||
@api_id
|
@api_id
|
||||||
|
|
||||||
init: ->
|
init: ->
|
||||||
|
|
||||||
window.vkAsyncInit = ->
|
window.vkAsyncInit = ->
|
||||||
VK.init apiId: _vkontakte.getApiId()
|
VK.init apiId: _vkontakte.getApiId()
|
||||||
VK.Auth.getLoginStatus (response) ->
|
VK.Auth.getLoginStatus (response) ->
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
%head
|
%head
|
||||||
%title BeatHaven
|
%title BeatHaven
|
||||||
%meta{ :charset => "utf-8" }
|
%meta{ :charset => "utf-8" }
|
||||||
|
%meta{ :name => 'csrf-token', :content => form_authenticity_token }
|
||||||
%link{ :rel => "shortcut icon", :href => "/favicon.ico" }
|
%link{ :rel => "shortcut icon", :href => "/favicon.ico" }
|
||||||
= stylesheet_link_tag "application"
|
= stylesheet_link_tag "application"
|
||||||
= javascript_include_tag "application"
|
= javascript_include_tag "application"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user