Locale switch, greetings page
This commit is contained in:
parent
95c0b9fc12
commit
67e79acf23
|
@ -7,6 +7,10 @@ class window.Ajax
|
||||||
$('.data-container .inner').html data
|
$('.data-container .inner').html data
|
||||||
false
|
false
|
||||||
|
|
||||||
|
loadIndexPage: ->
|
||||||
|
$('#content').load '/greetings/'
|
||||||
|
false
|
||||||
|
|
||||||
loadAboutPage: ->
|
loadAboutPage: ->
|
||||||
$.get '/templates/about.html', (data) ->
|
$.get '/templates/about.html', (data) ->
|
||||||
_page.renderTextpage data
|
_page.renderTextpage data
|
||||||
|
@ -30,8 +34,8 @@ class window.Ajax
|
||||||
detectPage: () ->
|
detectPage: () ->
|
||||||
if m = _ajax.getAnchor().match /\/artist\/(.+)\//
|
if m = _ajax.getAnchor().match /\/artist\/(.+)\//
|
||||||
_search.loadArtistData m[1]
|
_search.loadArtistData m[1]
|
||||||
else if _ajax.getAnchor() == '' or _ajax.getAnchor().match /\/search\//
|
else if _ajax.getAnchor() == ''
|
||||||
#_ajax.loadSearchPage();
|
_ajax.loadIndexPage();
|
||||||
else if _ajax.getAnchor().match /\/settings\//
|
else if _ajax.getAnchor().match /\/settings\//
|
||||||
_settings.loadSettingsPage()
|
_settings.loadSettingsPage()
|
||||||
else if _ajax.getAnchor().match /\/about\//
|
else if _ajax.getAnchor().match /\/about\//
|
||||||
|
|
|
@ -25,6 +25,9 @@ class window.Vkontakte
|
||||||
if typeof response isnt 'undefined' and response.session
|
if typeof response isnt 'undefined' and response.session
|
||||||
_session = new Session(response.session)
|
_session = new Session(response.session)
|
||||||
_session.query '/user/auth', {}, (ar) ->
|
_session.query '/user/auth', {}, (ar) ->
|
||||||
|
if ar.ok_reload
|
||||||
|
window.location.reload()
|
||||||
|
false
|
||||||
if ar.newbie
|
if ar.newbie
|
||||||
VK.Api.call 'getVariable', key: 1281, (r) ->
|
VK.Api.call 'getVariable', key: 1281, (r) ->
|
||||||
_session.query '/user/update', name: r.response, (ar2) ->
|
_session.query '/user/update', name: r.response, (ar2) ->
|
||||||
|
|
|
@ -2,6 +2,7 @@ require 'digest'
|
||||||
|
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
before_filter :set_locale
|
||||||
|
|
||||||
def authorized?
|
def authorized?
|
||||||
# secret_key = request.host == 'beathaven.org' ? 'sdgwSbl3nNE4ZxafuPrp' : 's5zyjb693z6uV4rbhEyc'
|
# secret_key = request.host == 'beathaven.org' ? 'sdgwSbl3nNE4ZxafuPrp' : 's5zyjb693z6uV4rbhEyc'
|
||||||
|
@ -24,8 +25,19 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_locale
|
||||||
|
session = Session.find_by_key(request.cookies['_beathaven_session'][0..31])
|
||||||
|
unless session.nil?
|
||||||
|
I18n.locale = session.user.lang
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def greetings
|
||||||
|
render :partial => 'greetings'
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,9 +12,15 @@ class UserController < ApplicationController
|
||||||
user.save
|
user.save
|
||||||
@res[:newbie] = true
|
@res[:newbie] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
cookie_key = request.cookies['_beathaven_session'][0..31]
|
||||||
session = Session.find_or_create_by_user_id(user.id)
|
session = Session.find_or_create_by_user_id(user.id)
|
||||||
session.key = Digest::SHA256.hexdigest(rand(99999999).to_s + user.id.to_s + rand(99999999).to_s)
|
if session.key != cookie_key
|
||||||
session.save
|
session.key = cookie_key
|
||||||
|
session.save
|
||||||
|
render :json => { 'ok_reload' => true }
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
@res[:user] = {
|
@res[:user] = {
|
||||||
:id => user.id,
|
:id => user.id,
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
%h1 Привет!
|
|
@ -57,6 +57,7 @@ Beathaven::Application.routes.draw do
|
||||||
# match ':controller(/:action(/:id(.:format)))'
|
# match ':controller(/:action(/:id(.:format)))'
|
||||||
|
|
||||||
match '/' => 'application#index'
|
match '/' => 'application#index'
|
||||||
|
match '/greetings/' => 'application#greetings'
|
||||||
|
|
||||||
match 'user/auth' => 'user#auth'
|
match 'user/auth' => 'user#auth'
|
||||||
match 'user/update' => 'user#update'
|
match 'user/update' => 'user#update'
|
||||||
|
|
Loading…
Reference in New Issue