From a56b4611c80986336a0e2585168ca6cc763caecf Mon Sep 17 00:00:00 2001 From: bsag Date: Sat, 14 Jan 2006 12:17:39 +0000 Subject: [PATCH] Some minor fixes and a change to the login system: * RSS now has correct link for the context (fixes #144) * Pass a local variable to the _completed.rhtml partial so that the empty box gets the appropriate '...in this project' or '...in this context' description. * Added a checkbox 'Stay logged in' to the login page. When checked it prevents the session timing out after one hour of inactivity. You will stay logged in (with that browser) until you manually logout. That's useful for people who are using Tracks on a private machine to which only they have access. Addresses #20. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@177 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/application.rb | 26 +++++++++++++--------- tracks/app/controllers/login_controller.rb | 13 +++++++++-- tracks/app/views/feed/na_feed.rxml | 4 ++-- tracks/app/views/login/login.rhtml | 18 +++++++++------ tracks/app/views/todo/_completed.rhtml | 2 +- 5 files changed, 40 insertions(+), 23 deletions(-) diff --git a/tracks/app/controllers/application.rb b/tracks/app/controllers/application.rb index 6ca43477..6d40b8f7 100644 --- a/tracks/app/controllers/application.rb +++ b/tracks/app/controllers/application.rb @@ -38,17 +38,21 @@ class ApplicationController < ActionController::Base def set_session_expiration # http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions - return if @controller_name == 'feed' - # If no session we don't care - if @session - # Get expiry time (allow ten seconds window for the case where we have none) - expiry_time = @session['expiry_time'] || Time.now + 10 - if expiry_time < Time.now - # Too late, matey... bang goes your session! - reset_session - else - # Okay, you get another hour - @session['expiry_time'] = Time.now + (60*60) + unless @session == nil + return if @controller_name == 'feed' or @session['noexpiry'] == "on" + # If the method is called by the feed controller (which we don't have under session control) + # or if we checked the box to keep logged in on login + # don't set the session expiry time. + if @session + # Get expiry time (allow ten seconds window for the case where we have none) + expiry_time = @session['expiry_time'] || Time.now + 10 + if expiry_time < Time.now + # Too late, matey... bang goes your session! + reset_session + else + # Okay, you get another hour + @session['expiry_time'] = Time.now + (60*60) + end end end end diff --git a/tracks/app/controllers/login_controller.rb b/tracks/app/controllers/login_controller.rb index bc66f287..394077e2 100644 --- a/tracks/app/controllers/login_controller.rb +++ b/tracks/app/controllers/login_controller.rb @@ -1,13 +1,22 @@ class LoginController < ApplicationController model :user layout 'login' + skip_before_filter :set_session_expiration def login - @page_title = "Login" + @page_title = "TRACKS::Login" case @request.method when :post if @session['user'] = User.authenticate(@params['user_login'], @params['user_password']) - flash['notice'] = "Login successful" + # If checkbox on login page checked, we don't expire the session after 1 hour + # of inactivity + @session['noexpiry']= @params['user_noexpiry'] + if @session['noexpiry'] == "on" + msg = "will not expire." + else + msg = "will expire after 1 hour of inactivity." + end + flash['notice'] = "Login successful: session #{msg}" redirect_back_or_default :controller => "todo", :action => "list" else @login = @params['user_login'] diff --git a/tracks/app/views/feed/na_feed.rxml b/tracks/app/views/feed/na_feed.rxml index 26d754e4..32852a95 100644 --- a/tracks/app/views/feed/na_feed.rxml +++ b/tracks/app/views/feed/na_feed.rxml @@ -2,11 +2,11 @@ xml.rss("version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/") do xml.channel do xml.title("Tracks - Next Actions") xml.link("http://#{@request.host}:#{@request.port}/todo/list") - xml.description("Lists the last 15 undone next actions") + xml.description("Lists the last 15 uncompleted next actions") @not_done.each { |i| xml.item do xml.title(i.description) - @link = url_for(:controller => 'context', :action => 'show', :id => "#{i.context_id}") + @link = url_for(:controller => 'context', :action => 'show', :name => "#{i.context.name}") xml.link("http://#{@request.host}:#{@request.port}#{@link}") xml.description(i.context['name']) end diff --git a/tracks/app/views/login/login.rhtml b/tracks/app/views/login/login.rhtml index f972919a..99878e51 100644 --- a/tracks/app/views/login/login.rhtml +++ b/tracks/app/views/login/login.rhtml @@ -12,15 +12,19 @@ - - + + - - - + + + - - + + + + + +
diff --git a/tracks/app/views/todo/_completed.rhtml b/tracks/app/views/todo/_completed.rhtml index 73244f38..56a92e1a 100644 --- a/tracks/app/views/todo/_completed.rhtml +++ b/tracks/app/views/todo/_completed.rhtml @@ -9,7 +9,7 @@
-

Currently there are no completed actions in this context

+

Currently there are no completed actions <%= append_descriptor %>

<%= render :partial => "todo/item", :collection => done %>