From d0a542f6259812d04fe604d66c56d986a894bf37 Mon Sep 17 00:00:00 2001 From: bsag Date: Sun, 8 Jan 2006 13:21:24 +0000 Subject: [PATCH] Main changes are to login and session management: * Added Luke Melia's patch to warn the user when the session has timed out when the user has added or checked off a next action without refreshing the page first. If they check off an item, they are redirected to the login page, then when they return, they are informed that the action has been checked off. If they add an item, they are informed after returning from the login page that the next action hasn't been added. Fixes #163. * Made some stylistic changes to login and signup pages to make them tidier, and to fit with the main theme better * Fixed bug with deleting items: the sheet which appeared was an alert (with only an 'OK' box, rather than a confirmation (with both an 'OK' and 'Cancel' box). Fixes #189. * Added a new feed icon to comply with the new de-facto standard: from [http://www.feedicons.com/ Feed Icons]. git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@172 a4c988fc-2ded-0310-b66e-134b36920a42 --- tracks/app/controllers/application.rb | 19 +------ tracks/app/controllers/context_controller.rb | 11 ++-- tracks/app/controllers/feed_controller.rb | 1 + tracks/app/controllers/login_controller.rb | 4 +- tracks/app/controllers/project_controller.rb | 11 ++-- tracks/app/controllers/todo_controller.rb | 14 +++-- tracks/app/helpers/todo_helper.rb | 8 ++- tracks/app/views/context/destroy_action.rjs | 4 +- tracks/app/views/context/show.rhtml | 13 ++--- tracks/app/views/layouts/login.rhtml | 5 -- tracks/app/views/layouts/standard.rhtml | 2 +- tracks/app/views/login/_redirect_to_login.rjs | 1 + tracks/app/views/login/login.rhtml | 26 ++++++---- tracks/app/views/login/logout.rhtml | 10 ---- tracks/app/views/login/signup.rhtml | 39 +++++++++----- tracks/app/views/project/destroy_action.rjs | 4 +- tracks/app/views/project/show.rhtml | 10 ++-- tracks/app/views/todo/destroy_action.rjs | 4 +- tracks/app/views/todo/list.rhtml | 13 ++--- tracks/config/environment.rb | 3 +- tracks/db/schema.rb | 49 ++++++++++++++++++ tracks/lib/login_system.rb | 6 ++- tracks/public/images/feed-icon.png | Bin 0 -> 764 bytes tracks/public/javascripts/todo-items.js | 22 ++++---- tracks/public/stylesheets/scaffold.css | 41 ++++++++++++--- tracks/public/stylesheets/standard.css | 38 ++++++-------- 26 files changed, 212 insertions(+), 146 deletions(-) create mode 100644 tracks/app/views/login/_redirect_to_login.rjs delete mode 100644 tracks/app/views/login/logout.rhtml create mode 100644 tracks/db/schema.rb create mode 100755 tracks/public/images/feed-icon.png diff --git a/tracks/app/controllers/application.rb b/tracks/app/controllers/application.rb index b5938baa..6ca43477 100644 --- a/tracks/app/controllers/application.rb +++ b/tracks/app/controllers/application.rb @@ -29,7 +29,7 @@ class ApplicationController < ActionController::Base end total = Todo.find_all("done=0").length - sub end - + # Reverses the urlize() method by substituting underscores for spaces # def deurlize(name) @@ -53,21 +53,4 @@ class ApplicationController < ActionController::Base end end - # Renders the given hash as xml. Primarily used to send multiple - # partials back to an ajax request - # - # * +renders+ is a Hash where the keys are string identifiers, - # and the values are partials rendered as a strings (see - # render_to_string). - def renders_to_xml(renders) - xml = '' - renders.each_key do |key| - xml += "<" + key.to_s + - ">" - end - xml += '' - render(:text => xml) - end - end diff --git a/tracks/app/controllers/context_controller.rb b/tracks/app/controllers/context_controller.rb index a4a56d66..1f862256 100644 --- a/tracks/app/controllers/context_controller.rb +++ b/tracks/app/controllers/context_controller.rb @@ -65,10 +65,11 @@ class ContextController < ApplicationController # fallback for standard requests if @saved - flash["warning"] = 'Added new next action' - redirect_to :action => 'show', :id => @item + flash["notice"] = 'Added new next action.' + redirect_to :controller => 'todo', :action => 'list' else - #render :action => 'new' + flash["warning"] = 'The next action was not added. Please try again.' + redirect_to :controller => 'todo', :action => 'list' end rescue @@ -76,7 +77,7 @@ class ContextController < ApplicationController render :action => 'error' else flash["warning"] = 'An error occurred on the server.' - #render :action => 'new' + redirect_to :controller => 'todo', :action => 'list' end end @@ -93,7 +94,7 @@ class ContextController < ApplicationController # fallback for standard requests if @saved - flash["warning"] = 'Successfully deleted next action' + flash["notice"] = 'Successfully deleted next action' redirect_to :controller => 'todo', :action => 'list' else render :controller => 'todo', :action => 'list' diff --git a/tracks/app/controllers/feed_controller.rb b/tracks/app/controllers/feed_controller.rb index d464eeb1..1f6bec1d 100644 --- a/tracks/app/controllers/feed_controller.rb +++ b/tracks/app/controllers/feed_controller.rb @@ -4,6 +4,7 @@ class FeedController < ApplicationController helper :feed model :todo, :context, :project + session :disabled => true # Prevents session control from interfering with feed before_filter :check_token_against_user_word diff --git a/tracks/app/controllers/login_controller.rb b/tracks/app/controllers/login_controller.rb index e99a2971..bc66f287 100644 --- a/tracks/app/controllers/login_controller.rb +++ b/tracks/app/controllers/login_controller.rb @@ -1,6 +1,6 @@ class LoginController < ApplicationController model :user - layout 'scaffold' + layout 'login' def login @page_title = "Login" @@ -61,6 +61,8 @@ class LoginController < ApplicationController def logout @session['user'] = nil reset_session + flash['notice'] = "You have been logged out of Tracks." + redirect_to :controller => "login", :action => "login" end def welcome diff --git a/tracks/app/controllers/project_controller.rb b/tracks/app/controllers/project_controller.rb index 1991c9ad..80a031c5 100644 --- a/tracks/app/controllers/project_controller.rb +++ b/tracks/app/controllers/project_controller.rb @@ -84,10 +84,11 @@ class ProjectController < ApplicationController # fallback for standard requests if @saved - flash["warning"] = 'Added new next action' - redirect_to :action => 'show', :name => urlize(@item.project.name) + flash["notice"] = 'Added new next action.' + redirect_to :controller => 'todo', :action => 'list' else - #render :action => 'new' + flash["warning"] = 'The next action was not added. Please try again.' + redirect_to :controller => 'todo', :action => 'list' end rescue @@ -95,7 +96,7 @@ class ProjectController < ApplicationController render :action => 'error' else flash["warning"] = 'An error occurred on the server.' - #render :action => 'new' + redirect_to :controller => 'todo', :action => 'list' end end @@ -112,7 +113,7 @@ class ProjectController < ApplicationController # fallback for standard requests if @saved - flash["warning"] = 'Successfully deleted next action' + flash["notice"] = 'Successfully deleted next action' redirect_to :controller => 'todo', :action => 'list' else render :controller => 'todo', :action => 'list' diff --git a/tracks/app/controllers/todo_controller.rb b/tracks/app/controllers/todo_controller.rb index 15828955..67b943ef 100644 --- a/tracks/app/controllers/todo_controller.rb +++ b/tracks/app/controllers/todo_controller.rb @@ -57,10 +57,11 @@ class TodoController < ApplicationController # fallback for standard requests if @saved - flash["warning"] = 'Added new next action' + flash["notice"] = 'Added new next action.' redirect_to :action => 'list' else - render :action => 'list' + flash["warning"] = 'The next action was not added. Please try again.' + redirect_to :action => 'list' end rescue @@ -88,7 +89,12 @@ class TodoController < ApplicationController item.toggle!('done') item.completed = Time.now() # For some reason, the before_save in todo.rb stopped working if item.save - render :partial => 'item', :object => item + if request.xhr? + render :partial => 'item', :object => item + else + flash['notice'] = "The item '#{item.description}' was marked as #{item.done? ? 'complete' : 'incomplete' }" + redirect_to :action => "list" + end end end @@ -129,7 +135,7 @@ class TodoController < ApplicationController # fallback for standard requests if @saved - flash["warning"] = 'Successfully deleted next action' + flash["notice"] = 'Successfully deleted next action' redirect_to :action => 'list' else render :action => 'list' diff --git a/tracks/app/helpers/todo_helper.rb b/tracks/app/helpers/todo_helper.rb index 3ead05e9..011a7680 100644 --- a/tracks/app/helpers/todo_helper.rb +++ b/tracks/app/helpers/todo_helper.rb @@ -7,15 +7,12 @@ module TodoHelper end def form_remote_tag_toggle_todo( item ) - target_div = item.done? ? "new_actions" : "completed" + target_div = item.done? ? "c#{item.context_id}" : "completed" target_position = item.done? ? "bottom" : "top" form_id = "checkbox-#{item.id}-form" item_container_id = "item-#{item.id}-container" loading_javascript = "Form.disable('#{form_id}');" - if item.done? - loading_javascript << visual_effect(:appear, "new_actions", :duration => 0.4) - end success_javascript = " $('#{item_container_id}').setAttribute('id','#{item_container_id}-fading');" success_javascript << visual_effect( :fade, "#{item_container_id}-fading", @@ -43,7 +40,8 @@ module TodoHelper def link_to_remote_todo( item, handled_by) str = link_to_remote( image_tag("blank", :title =>"Delete action", :class=>"delete_item"), - {:url => { :controller => handled_by, :action => "destroy_action", :id => item.id }}, + {:url => { :controller => handled_by, :action => "destroy_action", :id => item.id }, + :confirm => "Are you sure that you want to delete the action, \'#{item.description}\'?"}, {:class => "icon"}) + "\n" if !item.done? str << link_to_remote( image_tag("blank", :title =>"Edit action", :class=>"edit_item", :id=>"action-#{item.id}-edit-icon"), diff --git a/tracks/app/views/context/destroy_action.rjs b/tracks/app/views/context/destroy_action.rjs index fb3f340e..28335b4e 100644 --- a/tracks/app/views/context/destroy_action.rjs +++ b/tracks/app/views/context/destroy_action.rjs @@ -1,7 +1,5 @@ if @saved - page.alert "Are you sure that you want to delete the next action: \'#{@item.description}\'?" - page.visual_effect :fade, "item-#{@item.id}-container", :duration => 2.0 - page.remove "item-#{@item.id}-container" + page.visual_effect :fade, "item-#{@item.id}-container", :duration => 0.4 page.replace_html "badge_count", @down_count if @down_count == "0" page.show 'empty-nd' diff --git a/tracks/app/views/context/show.rhtml b/tracks/app/views/context/show.rhtml index 687d9e07..6ac70fd2 100644 --- a/tracks/app/views/context/show.rhtml +++ b/tracks/app/views/context/show.rhtml @@ -1,5 +1,10 @@
- + <% if @flash["notice"] %> +
<%= @flash["notice"] %>
+ <% end %> + <% if @flash["warning"] -%> +
<%= @flash["warning"] %>
+ <% end -%> <%= render :partial => "context/context", :locals => { :context => @context, :collapsible => false } %> <%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this context" } %> @@ -9,8 +14,4 @@ <%= render :partial => "shared/add_new_item_form", :locals => {:hide_link => false, :msg => ""} %> <%= render "shared/sidebar" %> -
- -<% if @flash["warning"] %> -
<%= @flash["warning"] %>
-<% end %> + \ No newline at end of file diff --git a/tracks/app/views/layouts/login.rhtml b/tracks/app/views/layouts/login.rhtml index 92dfce14..93ab60e8 100644 --- a/tracks/app/views/layouts/login.rhtml +++ b/tracks/app/views/layouts/login.rhtml @@ -7,11 +7,6 @@ - <%= @content_for_layout %> diff --git a/tracks/app/views/layouts/standard.rhtml b/tracks/app/views/layouts/standard.rhtml index d2c59d0b..58b93200 100644 --- a/tracks/app/views/layouts/standard.rhtml +++ b/tracks/app/views/layouts/standard.rhtml @@ -34,7 +34,7 @@
  • <%= link_to( "Notes", {:controller => "note", :action => "index"}, :title => "Show all notes" ) %>
  • Show
  • Hide
  • -
  • <%= link_to("RSS", {:controller => "feed", :action => "na_feed", :name => "#{@session['user']['login']}", :token => "#{@session['user']['word']}"}, :title => "Subscribe to an RSS feed of your next actions" ) %>
  • +
  • <%= link_to(image_tag("feed-icon", :size => "16X16", :border => 0), {:controller => "feed", :action => "na_feed", :name => "#{@session['user']['login']}", :token => "#{@session['user']['word']}"}, :title => "Subscribe to an RSS feed of your next actions" ) %>
  • <%= link_to("TXT", {:controller => "feed", :action => "na_text", :name => "#{@session['user']['login']}", :token => "#{@session['user']['word']}"}, :title => "View a plain text feed of your next actions" ) %>
  • <%= link_to "Logout (#{@session['user']['login']}) »", :controller => "login", :action=>"logout"%>
  • diff --git a/tracks/app/views/login/_redirect_to_login.rjs b/tracks/app/views/login/_redirect_to_login.rjs new file mode 100644 index 00000000..ccb2e26a --- /dev/null +++ b/tracks/app/views/login/_redirect_to_login.rjs @@ -0,0 +1 @@ +page.redirect_to :controller => 'login', :action => 'login' \ No newline at end of file diff --git a/tracks/app/views/login/login.rhtml b/tracks/app/views/login/login.rhtml index 0fa14340..f972919a 100644 --- a/tracks/app/views/login/login.rhtml +++ b/tracks/app/views/login/login.rhtml @@ -1,21 +1,29 @@ <%= start_form_tag :action=> "login" %>
    + + <% if @flash["notice"] %>
    <%= @flash["notice"] %>
    <% end %> +

    Please log in to use Tracks:

    <% if @message %>
    <%= @message %>
    <% end %> - -
    - - - - -
    - - + + + + + + + + + + + + + +
    <%= end_form_tag %> diff --git a/tracks/app/views/login/logout.rhtml b/tracks/app/views/login/logout.rhtml deleted file mode 100644 index 6a3d22c2..00000000 --- a/tracks/app/views/login/logout.rhtml +++ /dev/null @@ -1,10 +0,0 @@ - -
    -

    Logoff

    - -

    You are now logged out of the system...

    - - <%= link_to "« login", :action=>"login"%> - -
    - diff --git a/tracks/app/views/login/signup.rhtml b/tracks/app/views/login/signup.rhtml index aa35d32c..f91c1dfc 100644 --- a/tracks/app/views/login/signup.rhtml +++ b/tracks/app/views/login/signup.rhtml @@ -3,22 +3,33 @@ <%= error_messages_for 'user' %>
    + <% if @flash["notice"] %>
    <%= @flash["notice"] %>
    <% end %> +

    <%= @page_title -%>

    -
    - <%= text_field "user", "login", :size => 20 %>
    - -
    - <%= password_field "user", "password", :size => 20 %>
    - -
    - <%= password_field "user", "password_confirmation", :size => 20 %>
    - -
    - <%= password_field "user", "word", :size => 20 %>
    - - - + + + + + + + + + + + + + + + + + + + + + +
    <%= text_field "user", "login", :size => 20 %>
    <%= password_field "user", "password", :size => 20 %>
    <%= password_field "user", "password_confirmation", :size => 20 %>
    <%= password_field "user", "word", :size => 20 %>
    * different to password
    + <%= end_form_tag %> diff --git a/tracks/app/views/project/destroy_action.rjs b/tracks/app/views/project/destroy_action.rjs index fb3f340e..28335b4e 100644 --- a/tracks/app/views/project/destroy_action.rjs +++ b/tracks/app/views/project/destroy_action.rjs @@ -1,7 +1,5 @@ if @saved - page.alert "Are you sure that you want to delete the next action: \'#{@item.description}\'?" - page.visual_effect :fade, "item-#{@item.id}-container", :duration => 2.0 - page.remove "item-#{@item.id}-container" + page.visual_effect :fade, "item-#{@item.id}-container", :duration => 0.4 page.replace_html "badge_count", @down_count if @down_count == "0" page.show 'empty-nd' diff --git a/tracks/app/views/project/show.rhtml b/tracks/app/views/project/show.rhtml index bc3501d2..3ff68a43 100644 --- a/tracks/app/views/project/show.rhtml +++ b/tracks/app/views/project/show.rhtml @@ -1,5 +1,10 @@
    - + <% if @flash["notice"] %> +
    <%= @flash["notice"] %>
    + <% end %> + <% if @flash["warning"] -%> +
    <%= @flash["warning"] %>
    + <% end -%> <%= render :partial => "project/project", :locals => { :project => @project, :collapsible => false } %> <%= render :partial => "todo/completed", :locals => { :done => @done, :collapsible => false, :append_descriptor => "in this project" } %> @@ -42,6 +47,3 @@ <%= render "shared/_add_new_item_form" %> <%= render "shared/sidebar" %>
    - -<% if @flash["confirmation"] %>
    <%= @flash["confirmation"] %>
    <% end %> -<% if @flash["warning"] %>
    <%= @flash["warning"] %>
    <% end %> diff --git a/tracks/app/views/todo/destroy_action.rjs b/tracks/app/views/todo/destroy_action.rjs index 4dd2b03a..4e4d5c6f 100644 --- a/tracks/app/views/todo/destroy_action.rjs +++ b/tracks/app/views/todo/destroy_action.rjs @@ -1,7 +1,5 @@ if @saved - page.alert "Are you sure that you want to delete the next action: \'#{@item.description}\'?" - page.visual_effect :fade, "item-#{@item.id}-container", :duration => 2.0 - page.remove "item-#{@item.id}-container" + page.visual_effect :fade, "item-#{@item.id}-container", :duration => 0.4 page.replace_html "badge_count", @down_count else page.replace_html "status", content_tag("div", content_tag("h2", "#{pluralize(@item.errors.count, "error")} prohibited this record from being saved") + content_tag("p", "There were problems with the following fields:") + content_tag("ul", @item.errors.each_full { |msg| content_tag("li", msg) }), "id" => "ErrorExplanation", "class" => "ErrorExplanation") diff --git a/tracks/app/views/todo/list.rhtml b/tracks/app/views/todo/list.rhtml index 70f56e6e..987847e0 100644 --- a/tracks/app/views/todo/list.rhtml +++ b/tracks/app/views/todo/list.rhtml @@ -1,4 +1,10 @@
    + <% if @flash["notice"] %> +
    <%= @flash["notice"] %>
    + <% end %> + <% if @flash["warning"] -%> +
    <%= @flash["warning"] %>
    + <% end -%> <%= render :partial => "context/context", :collection => @contexts_to_show, :locals => { :collapsible => true } %> <%= render :partial => "todo/completed", @@ -8,9 +14,4 @@
    <%= render :partial => "shared/add_new_item_form", :locals => {:hide_link => false, :msg => ""} %> <%= render "shared/sidebar" %> -
    - -
    -<% if @flash["warning"] -%> -
    <%= @flash["warning"] %>
    -<% end -%> +
    \ No newline at end of file diff --git a/tracks/config/environment.rb b/tracks/config/environment.rb index 620155e5..292916d5 100644 --- a/tracks/config/environment.rb +++ b/tracks/config/environment.rb @@ -50,5 +50,6 @@ end # Include your application configuration below def app_configurations - YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml")) + @app_cfg = nil if ENV['RAILS_ENV'] == 'development' + @app_cfg ||= YAML::load(File.open("#{RAILS_ROOT}/config/settings.yml")) end \ No newline at end of file diff --git a/tracks/db/schema.rb b/tracks/db/schema.rb new file mode 100644 index 00000000..16b4f2c8 --- /dev/null +++ b/tracks/db/schema.rb @@ -0,0 +1,49 @@ +# This file is autogenerated. Instead of editing this file, please use the +# migrations feature of ActiveRecord to incrementally modify your database, and +# then regenerate this schema definition. + +ActiveRecord::Schema.define(:version => 5) do + + create_table "contexts", :force => true do |t| + t.column "name", :string, :default => "", :null => false + t.column "position", :integer, :default => 0, :null => false + t.column "hide", :boolean, :default => false + t.column "user_id", :integer, :default => 0, :null => false + end + + create_table "notes", :force => true do |t| + t.column "user_id", :integer, :default => 0, :null => false + t.column "project_id", :integer, :default => 0, :null => false + t.column "body", :text + t.column "created_at", :datetime + t.column "updated_at", :datetime + end + + create_table "projects", :force => true do |t| + t.column "name", :string, :default => "", :null => false + t.column "position", :integer, :default => 0, :null => false + t.column "done", :boolean, :default => false + t.column "user_id", :integer, :default => 0, :null => false + t.column "description", :text + end + + create_table "todos", :force => true do |t| + t.column "context_id", :integer, :default => 0, :null => false + t.column "project_id", :integer + t.column "description", :string, :default => "", :null => false + t.column "notes", :text + t.column "done", :boolean, :default => false, :null => false + t.column "created_at", :datetime + t.column "due", :date + t.column "completed", :datetime + t.column "user_id", :integer, :default => 0, :null => false + end + + create_table "users", :force => true do |t| + t.column "login", :string, :limit => 80, :default => "", :null => false + t.column "password", :string, :limit => 40, :default => "", :null => false + t.column "word", :string + t.column "is_admin", :boolean, :default => false, :null => false + end + +end diff --git a/tracks/lib/login_system.rb b/tracks/lib/login_system.rb index b02c8f77..c6e21c1a 100644 --- a/tracks/lib/login_system.rb +++ b/tracks/lib/login_system.rb @@ -65,7 +65,11 @@ module LoginSystem # example use : # a popup window might just close itself for instance def access_denied - redirect_to :controller=>"login", :action =>"login" + if request.xhr? + render :partial => 'login/redirect_to_login' + else + redirect_to :controller=>"login", :action =>"login" + end end # store current uri in the session. diff --git a/tracks/public/images/feed-icon.png b/tracks/public/images/feed-icon.png new file mode 100755 index 0000000000000000000000000000000000000000..1679ab05b016ab3eb7556d6eaa869795bf457aa0 GIT binary patch literal 764 zcmVycK`yFAWD;1ET2aX4PeS5VXXgH#(|69jGm_GU@1D8vz3+LxpJ8L?l8MS>?e&-y z%WwuTdNIE7EdHio488!C7VH80_u>sxi4*Ze##>tjHyI4h^~p_yXBY;V7~x4qiDX^o z$0suUd9_8Fo{vZ}h4R*ulmz%Q;}E~b|0~uMp2X6k2UB6Iq)2TF6^AaO_{f3{_rnnU zi6Jm=Ws}%12#^$9)n`OF)-{H^$f#o?Aj#uD5NjJvVCb8 z-B>S$xnn=9j>}+Mn>CUD>NdR3&q`w7k;qeM0wu6^wW8|MOO&6!4=ddb{F#RP_&mh) zh&C`ft^uj`lGt|w0g0yETI}Y>sAY^qD3eRt@_a%KM5W6LU^-*DM4)W^=yeGW@x-vP^51&;a z_u{UmC~NE1Vr3#lv4n8W*3mnNoEQXe=!ExXK$Ebldhnf{$W4qw=54T8C6%^EPa`Y= zTC8eULRQ}bw)+@7dl}CANBY)CbCDGr>2aaR?%ik}jX`KOnc%8hS}Ytd3$EobO|$Q5mVUPR@OK7nDP0&O#Q>d=_Sn z1vYtQ@4be7bs6d9|5=jKsKSQnnh9Iz+9hH&apbr?VDvVzx4Bgj1I#v;5_PC`r3U$u usA%IQS3%99X~E(!%1spbn*KZg6<`2SHB&n2#K$=R0000