app/controllers/application.rb in parlement-0.13 vs app/controllers/application.rb in parlement-0.14
- old
+ new
@@ -3,19 +3,19 @@
require 'login_engine'
require 'term/ansicolor'
class ApplicationController < ActionController::Base
- helper_method :filter
+ helper_method :filter
include LoginEngine
include Term::ANSIColor
- init_gettext "parlement"
+ init_gettext "parlement"
- before_filter :set_login_from_cookie
- after_filter :fix_unicode_for_safari
+ before_filter :set_login_from_cookie
+ #after_filter :fix_unicode_for_safari
after_filter OutputCompressionFilter
# automatically and transparently fixes utf-8 bug
# with Safari when using xmlhttp
def fix_unicode_for_safari
@@ -24,31 +24,32 @@
response.body = response.body.gsub(/([^\x00-\xa0])/u) { |s| "&#x%x;" % $1.unpack('U')[0] }
end
end
def set_login_from_cookie
- unless session[:person]
- if (person = Person.find_by_name(cookies[:person_name])) and \
+ unless session[:lastUpdatedView] or session[:person]
+ if (cookies[:person_name] and \
+ person = Person.find_by_name(cookies[:person_name])) and \
((!person.user and !cookies[:salted_password]) \
or (person.user \
and person.user.salted_password == cookies[:salted_password]))
logger.info yellow { bold { "#{person.name} is back" } }
session[:person] = person
session[:user] = person.user
- person.last_login = Time.now
- person.save
+ person.last_login = Time.now
+ person.save!
end
end
end
- def filter
- if request.cookies['filter'] && request.cookies['filter'][0]
- filter = request.cookies['filter'][0].to_i - 1
- filter = nil unless filter >= 0
- else
- filter = 0
- end
- filter
- end
+ def filter
+ if request.cookies['filter'] && request.cookies['filter'][0]
+ filter = request.cookies['filter'][0].to_i - 1
+ filter = nil unless filter >= 0
+ else
+ filter = 0
+ end
+ filter
+ end
end