diff --git a/tracks/app/controllers/application.rb b/tracks/app/controllers/application.rb index 4335ee77..8bc45e4a 100644 --- a/tracks/app/controllers/application.rb +++ b/tracks/app/controllers/application.rb @@ -7,10 +7,12 @@ require "redcloth" require 'date' require 'time' -#Tag # We need this in development mode, or you get 'method missing' errors +Tag # We need this in development mode, or you get 'method missing' errors class ApplicationController < ActionController::Base + protect_from_forgery :secret => SALT + helper :application include LoginSystem helper_method :current_user, :prefs @@ -26,6 +28,7 @@ class ApplicationController < ActionController::Base include ActionView::Helpers::TextHelper + include ActionView::Helpers::SanitizeHelper helper_method :format_date, :markdown # By default, sets the charset to UTF-8 if it isn't already set @@ -58,17 +61,17 @@ class ApplicationController < ActionController::Base render :text => message, :status => status end - def rescue_action(exception) - log_error(exception) if logger - respond_to do |format| - format.html do - notify :warning, "An error occurred on the server." - render :action => "index" - end - format.js { render :action => 'error' } - format.xml { render :text => 'An error occurred on the server.' + $! } - end - end + # def rescue_action(exception) + # log_error(exception) if logger + # respond_to do |format| + # format.html do + # notify :warning, "An error occurred on the server." + # render :action => "index" + # end + # format.js { render :action => 'error' } + # format.xml { render :text => 'An error occurred on the server.' + $! } + # end + # end # Returns a count of next actions in the given context or project # The result is count and a string descriptor, correctly pluralised if there are no diff --git a/tracks/app/controllers/contexts_controller.rb b/tracks/app/controllers/contexts_controller.rb index 912de11e..bd14ef4b 100644 --- a/tracks/app/controllers/contexts_controller.rb +++ b/tracks/app/controllers/contexts_controller.rb @@ -18,7 +18,7 @@ class ContextsController < ApplicationController format.xml { render :xml => @contexts.to_xml( :except => :user_id ) } format.rss &render_contexts_rss_feed format.atom &render_contexts_atom_feed - format.text { render :action => 'index_text', :layout => false, :content_type => Mime::TEXT } + format.text { render :action => 'index', :layout => false, :content_type => Mime::TEXT } end end @@ -84,7 +84,9 @@ class ContextsController < ApplicationController @context.attributes = params["context"] if @context.save if params['wants_render'] - render + respond_to do |format| + format.js + end else render :text => success_text || 'Success' end @@ -179,7 +181,7 @@ class ContextsController < ApplicationController def init_todos set_context_from_params unless @context.nil? - @context.todos.with_scope :find => { :include => [:project, :tags] } do + @context.todos.send :with_scope, :find => { :include => [:project, :tags] } do @done = @context.done_todos end diff --git a/tracks/app/controllers/login_controller.rb b/tracks/app/controllers/login_controller.rb index 2dc9e31f..004311ff 100644 --- a/tracks/app/controllers/login_controller.rb +++ b/tracks/app/controllers/login_controller.rb @@ -139,6 +139,9 @@ class LoginController < ApplicationController end end end + respond_to do |format| + format.js + end end private diff --git a/tracks/app/controllers/projects_controller.rb b/tracks/app/controllers/projects_controller.rb index d63aaba6..5508882c 100644 --- a/tracks/app/controllers/projects_controller.rb +++ b/tracks/app/controllers/projects_controller.rb @@ -28,7 +28,7 @@ class ProjectsController < ApplicationController end end end - + def projects_and_actions @projects = @projects.select { |p| p.active? } respond_to do |format| @@ -42,7 +42,7 @@ class ProjectsController < ApplicationController init_data_for_sidebar unless mobile? @projects = current_user.projects @page_title = "TRACKS::Project: #{@project.name}" - @project.todos.with_scope :find => { :include => [:context, :tags] } do + @project.todos.send :with_scope, :find => { :include => [:context, :tags] } do @not_done = @project.not_done_todos(:include_project_hidden_todos => true) @deferred = @project.deferred_todos.sort_by { |todo| todo.show_from } @done = @project.done_todos @@ -126,19 +126,25 @@ class ProjectsController < ApplicationController @active_projects_count = current_user.projects.count(:conditions => "state = 'active'") @hidden_projects_count = current_user.projects.count(:conditions => "state = 'hidden'") @completed_projects_count = current_user.projects.count(:conditions => "state = 'completed'") - render + render :template => 'projects/update.js.rjs' + return elsif boolean_param('update_status') - render :action => 'update_status' + render :template => 'projects/update_status.js.rjs' + return elsif boolean_param('update_default_context') @initial_context_name = @project.default_context.name - render :action => 'update_default_context' + render :template => 'projects/update_default_context.js.rjs' + return else render :text => success_text || 'Success' + return end else notify :warning, "Couldn't update project" render :text => '' + return end + render :template => 'projects/update.js.rjs' end def edit @@ -215,7 +221,7 @@ class ProjectsController < ApplicationController render :action => 'project_mobile' end end - + def render_rss_feed lambda do render_rss_feed_for @projects, :feed => feed_options, @@ -239,7 +245,7 @@ class ProjectsController < ApplicationController def render_text_feed lambda do init_project_hidden_todo_counts(['project']) - render :action => 'index_text', :layout => false, :content_type => Mime::TEXT + render :action => 'index', :layout => false, :content_type => Mime::TEXT end end diff --git a/tracks/app/controllers/todos_controller.rb b/tracks/app/controllers/todos_controller.rb index 721675ed..ffb03d5d 100644 --- a/tracks/app/controllers/todos_controller.rb +++ b/tracks/app/controllers/todos_controller.rb @@ -30,15 +30,16 @@ class TodosController < ApplicationController @projects = current_user.projects.select { |p| p.active? } @contexts = current_user.contexts.find(:all) respond_to do |format| - format.m { + format.m { @new_mobile = true @return_path=cookies[:mobile_url] - render :action => "new_mobile" + render :action => "new" } end end def create + @source_view = params['_source_view'] || 'todo' p = TodoCreateParamsHelper.new(params, prefs) p.parse_dates() unless mobile? @@ -71,7 +72,7 @@ class TodosController < ApplicationController else @projects = current_user.projects.find(:all) @contexts = current_user.contexts.find(:all) - render :action => "new_mobile" + render :action => "new" end end format.js do @@ -95,6 +96,9 @@ class TodosController < ApplicationController @projects = current_user.projects.find(:all) @contexts = current_user.contexts.find(:all) @source_view = params['_source_view'] || 'todo' + respond_to do |format| + format.js + end end def show @@ -104,7 +108,7 @@ class TodosController < ApplicationController @contexts = current_user.contexts.find(:all) @edit_mobile = true @return_path=cookies[:mobile_url] - render :action => 'show_mobile' + render :action => 'show' end format.xml { render :xml => @todo.to_xml( :root => 'todo', :except => :user_id ) } end @@ -211,6 +215,7 @@ class TodosController < ApplicationController format.m do if @saved if cookies[:mobile_url] + cookies[:mobile_url] = nil redirect_to cookies[:mobile_url] else redirect_to formatted_todos_path(:m) @@ -365,7 +370,7 @@ class TodosController < ApplicationController def with_feed_query_scope(&block) unless TodosController.is_feed_request(request) - Todo.with_scope :find => {:conditions => ['todos.state = ?', 'active']} do + Todo.send(:with_scope, :find => {:conditions => ['todos.state = ?', 'active']}) do yield return end @@ -398,7 +403,7 @@ class TodosController < ApplicationController @description << " in the last #{done_in_last.to_s} days" end - Todo.with_scope :find => {:conditions => condition_builder.to_conditions} do + Todo.send :with_scope, :find => {:conditions => condition_builder.to_conditions} do yield end @@ -407,12 +412,12 @@ class TodosController < ApplicationController def with_parent_resource_scope(&block) if (params[:context_id]) @context = current_user.contexts.find_by_params(params) - Todo.with_scope :find => {:conditions => ['todos.context_id = ?', @context.id]} do + Todo.send :with_scope, :find => {:conditions => ['todos.context_id = ?', @context.id]} do yield end elsif (params[:project_id]) @project = current_user.projects.find_by_params(params) - Todo.with_scope :find => {:conditions => ['todos.project_id = ?', @project.id]} do + Todo.send :with_scope, :find => {:conditions => ['todos.project_id = ?', @project.id]} do yield end else @@ -422,7 +427,7 @@ class TodosController < ApplicationController def with_limit_scope(&block) if params.key?('limit') - Todo.with_scope :find => { :limit => params['limit'] } do + Todo.send :with_scope, :find => { :limit => params['limit'] } do yield end if TodosController.is_feed_request(request) && @description @@ -464,7 +469,7 @@ class TodosController < ApplicationController def init_todos_for_mobile_view # Note: these next two finds were previously using current_users.todos.find # but that broke with_scope for :limit - + # Exclude hidden projects from the home page @not_done_todos = Todo.find(:all, :conditions => ['todos.user_id = ? AND todos.state = ? AND contexts.hide = ?', @@ -568,7 +573,7 @@ class TodosController < ApplicationController cookies[:mobile_url]=request.request_uri determine_down_count - render :action => 'index_mobile' + render :action => 'index' end end @@ -617,13 +622,13 @@ class TodosController < ApplicationController def render_text_feed lambda do - render :action => 'index_text', :layout => false, :content_type => Mime::TEXT + render :action => 'index', :layout => false, :content_type => Mime::TEXT end end def render_ical_feed lambda do - render :action => 'index_ical', :layout => false, :content_type => Mime::ICS + render :action => 'index', :layout => false, :content_type => Mime::ICS end end diff --git a/tracks/app/views/contexts/create.rjs b/tracks/app/views/contexts/create.js.rjs similarity index 100% rename from tracks/app/views/contexts/create.rjs rename to tracks/app/views/contexts/create.js.rjs diff --git a/tracks/app/views/contexts/destroy.rjs b/tracks/app/views/contexts/destroy.js.rjs similarity index 100% rename from tracks/app/views/contexts/destroy.rjs rename to tracks/app/views/contexts/destroy.js.rjs diff --git a/tracks/app/views/contexts/error.rjs b/tracks/app/views/contexts/error.js.rjs similarity index 100% rename from tracks/app/views/contexts/error.rjs rename to tracks/app/views/contexts/error.js.rjs diff --git a/tracks/app/views/contexts/index.rhtml b/tracks/app/views/contexts/index.html.erb similarity index 100% rename from tracks/app/views/contexts/index.rhtml rename to tracks/app/views/contexts/index.html.erb diff --git a/tracks/app/views/contexts/index_text.rhtml b/tracks/app/views/contexts/index.text.erb similarity index 100% rename from tracks/app/views/contexts/index_text.rhtml rename to tracks/app/views/contexts/index.text.erb diff --git a/tracks/app/views/contexts/show.rhtml b/tracks/app/views/contexts/show.html.erb similarity index 100% rename from tracks/app/views/contexts/show.rhtml rename to tracks/app/views/contexts/show.html.erb diff --git a/tracks/app/views/contexts/update.rjs b/tracks/app/views/contexts/update.js.rjs similarity index 100% rename from tracks/app/views/contexts/update.rjs rename to tracks/app/views/contexts/update.js.rjs diff --git a/tracks/app/views/data/index.rhtml b/tracks/app/views/data/index.html.erb similarity index 100% rename from tracks/app/views/data/index.rhtml rename to tracks/app/views/data/index.html.erb diff --git a/tracks/app/views/data/yaml_export.rhtml b/tracks/app/views/data/yaml_export.html.erb similarity index 100% rename from tracks/app/views/data/yaml_export.rhtml rename to tracks/app/views/data/yaml_export.html.erb diff --git a/tracks/app/views/data/yaml_form.rhtml b/tracks/app/views/data/yaml_form.html.erb similarity index 100% rename from tracks/app/views/data/yaml_form.rhtml rename to tracks/app/views/data/yaml_form.html.erb diff --git a/tracks/app/views/data/yaml_import.rhtml b/tracks/app/views/data/yaml_import.html.erb similarity index 100% rename from tracks/app/views/data/yaml_import.rhtml rename to tracks/app/views/data/yaml_import.html.erb diff --git a/tracks/app/views/feedlist/index.rhtml b/tracks/app/views/feedlist/index.html.erb similarity index 94% rename from tracks/app/views/feedlist/index.rhtml rename to tracks/app/views/feedlist/index.html.erb index 26df25dd..0b37ea82 100644 --- a/tracks/app/views/feedlist/index.rhtml +++ b/tracks/app/views/feedlist/index.html.erb @@ -54,10 +54,6 @@ <%= text_formatted_link({:controller => 'projects', :action => 'index', :only_active_with_no_next_actions => true}) %> Active projects with no next actions -
  • - <%= text_formatted_link({:controller => 'projects', :action => 'index', :projects_and_actions => true}) %> - Active projects with their actions -
  • Feeds for incomplete actions in a specific context: