diff --git a/Gemfile.lock b/Gemfile.lock index e0bd1fbf..6f52bf1c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ GEM remote: https://rubygems.org/ specs: RedCloth (4.2.9) - aasm (3.0.5) + aasm (3.0.6) activerecord actionmailer (3.2.3) actionpack (= 3.2.3) @@ -32,7 +32,7 @@ GEM i18n (~> 0.6) multi_json (~> 1.0) acts_as_list (0.1.6) - addressable (2.2.7) + addressable (2.2.8) arel (3.0.2) aruba (0.4.11) childprocess (>= 0.2.3) @@ -57,13 +57,12 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.3.1) - cucumber (1.1.9) + coffee-script-source (1.3.3) + cucumber (1.2.0) builder (>= 2.1.2) - diff-lcs (>= 1.1.2) - gherkin (~> 2.9.0) + diff-lcs (>= 1.1.3) + gherkin (~> 2.10.0) json (>= 1.4.6) - term-ansicolor (>= 1.0.6) cucumber-rails (1.3.0) capybara (>= 1.1.2) cucumber (>= 1.1.8) @@ -72,12 +71,12 @@ GEM database_cleaner (0.7.2) diff-lcs (1.1.3) erubis (2.7.0) - execjs (1.3.1) + execjs (1.3.2) multi_json (~> 1.0) - factory_girl (3.2.0) + factory_girl (3.3.0) activesupport (>= 3.0.0) - factory_girl_rails (3.2.0) - factory_girl (~> 3.2.0) + factory_girl_rails (3.3.0) + factory_girl (~> 3.3.0) railties (>= 3.0.0) ffi (1.0.11) formatize (1.1.0) @@ -85,7 +84,7 @@ GEM actionpack (~> 3.0) bluecloth (~> 2.2) gem_plugin (0.2.3) - gherkin (2.9.3) + gherkin (2.10.0) json (>= 1.4.6) hike (1.2.1) htmlentities (4.3.1) @@ -94,7 +93,7 @@ GEM jquery-rails (2.0.2) railties (>= 3.2.0, < 5.0) thor (~> 0.14) - json (1.6.6) + json (1.7.3) libwebsocket (0.1.3) addressable mail (2.4.4) @@ -105,7 +104,7 @@ GEM mongrel (1.2.0.pre2) daemons (~> 1.0.10) gem_plugin (~> 0.2.3) - multi_json (1.3.2) + multi_json (1.3.5) mysql2 (0.3.11) nokogiri (1.5.2) polyglot (0.3.3) @@ -124,7 +123,7 @@ GEM activesupport (= 3.2.3) bundler (~> 1.0) railties (= 3.2.3) - rails_autolink (1.0.6) + rails_autolink (1.0.7) rails (~> 3.1) railties (3.2.3) actionpack (= 3.2.3) @@ -136,18 +135,18 @@ GEM rake (0.9.2.2) rdoc (3.12) json (~> 1.4) - rspec (2.9.0) - rspec-core (~> 2.9.0) - rspec-expectations (~> 2.9.0) - rspec-mocks (~> 2.9.0) - rspec-core (2.9.0) - rspec-expectations (2.9.1) + rspec (2.10.0) + rspec-core (~> 2.10.0) + rspec-expectations (~> 2.10.0) + rspec-mocks (~> 2.10.0) + rspec-core (2.10.0) + rspec-expectations (2.10.0) diff-lcs (~> 1.1.3) - rspec-mocks (2.9.0) + rspec-mocks (2.10.1) rubyzip (0.9.8) sanitize (2.0.3) nokogiri (>= 1.4.4, < 1.6) - sass (3.1.16) + sass (3.1.18) sass-rails (3.2.5) railties (~> 3.2.0) sass (>= 3.1.10) @@ -166,7 +165,6 @@ GEM swf_fu (2.0.2) coffee-script rails (>= 3.1) - term-ansicolor (1.0.7) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) @@ -179,7 +177,7 @@ GEM will_paginate (3.0.3) xpath (0.1.4) nokogiri (~> 1.3) - yard (0.7.5) + yard (0.8.1) PLATFORMS ruby diff --git a/app/controllers/contexts_controller.rb b/app/controllers/contexts_controller.rb index b9c1aa47..2aabfc84 100644 --- a/app/controllers/contexts_controller.rb +++ b/app/controllers/contexts_controller.rb @@ -31,6 +31,8 @@ class ContextsController < ApplicationController @feed_description = "Lists all the contexts for #{current_user.display_name}" end format.text do + # somehow passing Mime::TEXT using content_type to render does not work + headers['Content-Type']=Mime::TEXT.to_s render :action => 'index', :layout => false, :content_type => Mime::TEXT end format.autocomplete &render_autocomplete diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index af183104..5605fc5c 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -21,10 +21,24 @@ class ProjectsController < ApplicationController @projects = current_user.projects.all end @new_project = current_user.projects.build + @active_projects = current_user.projects.active + @hidden_projects = current_user.projects.hidden respond_to do |format| - format.html &render_projects_html - format.m &render_projects_mobile - format.xml { render :xml => @projects.to_xml( :except => :user_id ) } + format.html do + @page_title = t('projects.list_projects') + @count = current_user.projects.count + @completed_projects = current_user.projects.completed.limit(10) + @completed_count = current_user.projects.completed.count + @no_projects = current_user.projects.empty? + current_user.projects.cache_note_counts + @new_project = current_user.projects.build + end + format.m do + @completed_projects = current_user.projects.completed + @down_count = @active_projects.size + @hidden_projects.size + @completed_projects.size + cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']} + end + format.xml { render :xml => @projects.all.to_xml( :except => :user_id ) } format.rss do @feed_title = I18n.t('models.project.feed_title') @feed_description = I18n.t('models.project.feed_description', :username => current_user.display_name) @@ -33,8 +47,14 @@ class ProjectsController < ApplicationController @feed_title = I18n.t('models.project.feed_title') @feed_description = I18n.t('models.project.feed_description', :username => current_user.display_name) end - format.text - format.autocomplete &render_autocomplete + format.text do + # somehow passing Mime::TEXT using content_type to render does not work + headers['Content-Type']=Mime::TEXT.to_s + end + format.autocomplete do + projects = current_user.projects.active + current_user.projects.hidden + render :text => for_autocomplete(projects, params[:term]) + end end end end @@ -97,6 +117,8 @@ class ProjectsController < ApplicationController @projects = current_user.projects.active respond_to do |format| format.text { + # somehow passing Mime::TEXT using content_type to render does not work + headers['Content-Type']=Mime::TEXT.to_s render :action => 'index_text_projects_and_actions', :layout => false, :content_type => Mime::TEXT } end @@ -127,15 +149,23 @@ class ProjectsController < ApplicationController @contexts = current_user.contexts respond_to do |format| format.html - format.m &render_project_mobile - format.xml { + format.m do + if @project.default_context.nil? + @project_default_context = t('projects.no_default_context') + else + @project_default_context = t('projects.default_context', :context => @project.default_context.name) + end + cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']} + @mobile_from_project = @project.id + end + format.xml do render :xml => @project.to_xml(:except => :user_id) { |xml| xml.not_done { @not_done.each { |child| child.to_xml(:builder => xml, :skip_instruct => true) } } xml.deferred { @deferred.each { |child| child.to_xml(:builder => xml, :skip_instruct => true) } } xml.pending { @pending.each { |child| child.to_xml(:builder => xml, :skip_instruct => true) } } xml.done { @done.each { |child| child.to_xml(:builder => xml, :skip_instruct => true) } } } - } + end end end @@ -302,53 +332,7 @@ class ProjectsController < ApplicationController @show_hidden_projects = @hidden_projects_count > 0 @show_completed_projects = @completed_projects_count > 0 end - - def render_projects_html - lambda do - @page_title = t('projects.list_projects') - @count = current_user.projects.count - @active_projects = current_user.projects.active - @hidden_projects = current_user.projects.hidden - @completed_projects = current_user.projects.completed.limit(10) - @completed_count = current_user.projects.completed.count - @no_projects = current_user.projects.empty? - current_user.projects.cache_note_counts - @new_project = current_user.projects.build - render - end - end - - def render_projects_mobile - lambda do - @active_projects = current_user.projects.active - @hidden_projects = current_user.projects.hidden - @completed_projects = current_user.projects.completed - @down_count = @active_projects.size + @hidden_projects.size + @completed_projects.size - cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']} - render - end - end - - def render_project_mobile - lambda do - if @project.default_context.nil? - @project_default_context = t('projects.no_default_context') - else - @project_default_context = t('projects.default_context', :context => @project.default_context.name) - end - cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']} - @mobile_from_project = @project.id - render - end - end - def render_autocomplete - lambda do - projects = current_user.projects.active + current_user.projects.hidden - render :text => for_autocomplete(projects, params[:term]) - end - end - def set_project_from_params @project = current_user.projects.find_by_params(params) end diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index c19b56d1..8660eae8 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -11,55 +11,6 @@ class TodosController < ApplicationController protect_from_forgery :except => :check_deferred - def with_feed_query_scope(&block) - unless TodosController.is_feed_request(request) - Todo.send(:where, ['todos.state = ?', 'active']) do - yield - return - end - end - condition_builder = FindConditionBuilder.new - - if params.key?('done') - condition_builder.add 'todos.state = ?', 'completed' - else - condition_builder.add 'todos.state = ?', 'active' - end - - @title = t('todos.next_actions_title') - @description = t('todos.next_actions_description') - - if params.key?('due') - due_within = params['due'].to_i - due_within_when = Time.zone.now + due_within.days - condition_builder.add('todos.due <= ?', due_within_when) - due_within_date_s = due_within_when.strftime("%Y-%m-%d") - @title << t('todos.next_actions_title_additions.due_today') if (due_within == 0) - @title << t('todos.next_actions_title_additions.due_within_a_week') if (due_within == 6) - @description << t('todos.next_actions_description_additions.due_date', :due_date => due_within_date_s) - end - - if params.key?('done') - done_in_last = params['done'].to_i - condition_builder.add('todos.completed_at >= ?', Time.zone.now - done_in_last.days) - @title << t('todos.next_actions_title_additions.completed') - @description << t('todos.next_actions_description_additions.completed', :count => done_in_last.to_s) - end - - if params.key?('tag') - tag = Tag.find_by_name(params['tag']) - if tag.nil? - tag = Tag.new(:name => params['tag']) - end - condition_builder.add('taggings.tag_id = ?', tag.id) - end - - Todo.send :where, condition_builder.to_conditions do - yield - end - - end - def with_parent_resource_scope(&block) @feed_title = t('common.actions') if (params[:context_id]) @@ -79,38 +30,43 @@ class TodosController < ApplicationController yield end end - - def with_limit_scope(&block) - if params.key?('limit') - Todo.send :with_scope, :find => { :limit => params['limit'] } do - yield - end - if TodosController.is_feed_request(request) && @description - if params.key?('limit') - @description << t('todos.list_incomplete_next_actions_with_limit', :count => params['limit']) - else - @description << t('todos.list_incomplete_next_actions') - end - end - else - yield - end - end def index @source_view = params['_source_view'] || 'todo' init_data_for_sidebar unless mobile? - if mobile? - @not_done_todos = current_user.todos. - where('todos.state = ? AND contexts.hide = ? AND (projects.state = ? OR todos.project_id IS NULL)', 'active', false, 'active'). - reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC"). - includes(:project, :context, :tags) + @todos = current_user.todos.includes(Todo::DEFAULT_INCLUDES) + + # TODO: refactor text feed for done todos to todos/done.text, not /todos.text?done=true + if params[:done] + @not_done_todos = current_user.todos.completed.completed_after(Time.zone.now - params[:done].to_i.days) else - @todos = current_user.todos.includes(Todo::DEFAULT_INCLUDES) - @not_done_todos = current_user.todos.active.not_hidden. - reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC"). - includes(Todo::DEFAULT_INCLUDES) + @not_done_todos = current_user.todos.active.not_hidden + end + + @not_done_todos = @not_done_todos. + reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC"). + includes(Todo::DEFAULT_INCLUDES) + @not_done_todos = @not_done_todos.limit(sanitize(params[:limit])) if params[:limit] + + if params[:due] + due_within_when = Time.zone.now + params['due'].to_i.days + @not_done_todos = @not_done_todos.where('todos.due <= ?', due_within_when) + end + + if params[:tag] + tag = Tag.find_by_name(params['tag']) + @not_done_todos = @not_done_todos.where('taggings.tag_id = ?', tag.id) + end + + if params[:context_id] + context = current_user.contexts.find(params[:context_id]) + @not_done_todos = @not_done_todos.where('context_id' => context.id) + end + + if params[:project_id] + project = current_user.projects.find(params[:project_id]) + @not_done_todos = @not_done_todos.where('project_id' => project) end @projects = current_user.projects.includes(:default_context) @@ -137,10 +93,14 @@ class TodosController < ApplicationController render :action => 'index' end + format.text do + # somehow passing Mime::TEXT using content_type to render does not work + headers['Content-Type']=Mime::TEXT.to_s + render :content_type => Mime::TEXT + end format.xml { render :xml => @todos.to_xml( *to_xml_params ) } format.rss { @feed_title, @feed_description = 'Tracks Actions', "Actions for #{current_user.display_name}" } format.atom { @feed_title, @feed_description = 'Tracks Actions', "Actions for #{current_user.display_name}" } - format.text format.ics end end diff --git a/app/helpers/feedlist_helper.rb b/app/helpers/feedlist_helper.rb index 35dbe97e..d6b086f4 100644 --- a/app/helpers/feedlist_helper.rb +++ b/app/helpers/feedlist_helper.rb @@ -8,12 +8,12 @@ module FeedlistHelper def text_formatted_link(options = {}) linkoptions = merge_hashes( {:format => 'txt'}, user_token_hash, options) - link_to(content_tag(:span, 'TXT', {:class => 'feed', :title => "Plain text feed"}, linkoptions)) + link_to(content_tag(:span, 'TXT', {:class => 'feed', :title => "Plain text feed"}), linkoptions) end def ical_formatted_link(options = {}) linkoptions = merge_hashes( {:format => 'ics'}, user_token_hash, options) - link_to(content_tag(:span, 'iCal', {:class=>"feed", :title => "iCal feed"}, linkoptions)) + link_to(content_tag(:span, 'iCal', {:class=>"feed", :title => "iCal feed"}), linkoptions) end def feed_links(feeds, link_options, title) diff --git a/app/views/projects/index_text_projects_and_actions.rhtml b/app/views/projects/index_text_projects_and_actions.rhtml deleted file mode 100644 index 877b5207..00000000 --- a/app/views/projects/index_text_projects_and_actions.rhtml +++ /dev/null @@ -1,5 +0,0 @@ -<% @projects.each do |p| -%> -<%= p.name.upcase -%> -<% actions = p.todos.select { |t| t.active? } -%> -<%= render :partial => "todos/text_todo", :collection => actions -%> -<% end -%> \ No newline at end of file diff --git a/app/views/projects/index_text_projects_and_actions.text.erb b/app/views/projects/index_text_projects_and_actions.text.erb new file mode 100644 index 00000000..f88b9367 --- /dev/null +++ b/app/views/projects/index_text_projects_and_actions.text.erb @@ -0,0 +1,5 @@ +<% @projects.each do |p| -%> +<%= p.name.upcase -%> +<% actions = p.todos.select { |t| t.active? } -%> +<%= render :partial => actions -%> +<% end -%> \ No newline at end of file diff --git a/config/initializers/tracks.rb b/config/initializers/tracks.rb index 9d139286..ad977886 100644 --- a/config/initializers/tracks.rb +++ b/config/initializers/tracks.rb @@ -1,38 +1,3 @@ -#require 'name_part_finder' -#require 'tracks/todo_list' -#require 'tracks/config' -#require 'tagging_extensions' # Needed for tagging-specific extensions -# require 'digest/sha1' #Needed to support 'rake db:fixtures:load' on some ruby installs: http://dev.rousette.org.uk/ticket/557 - -# TODO: move to devise for authentication which handles ldap, cas and openid -if ( SITE_CONFIG['authentication_schemes'].include? 'ldap') - require 'net/ldap' #requires ruby-net-ldap gem be installed - require 'simple_ldap_authenticator' - ldap = SITE_CONFIG['ldap'] - SimpleLdapAuthenticator.ldap_library = ldap['library'] - SimpleLdapAuthenticator.servers = ldap['servers'] - SimpleLdapAuthenticator.use_ssl = ldap['ssl'] - SimpleLdapAuthenticator.login_format = ldap['login_format'] -end - -# OpenID is not supported currently! -# -# if ( SITE_CONFIG['authentication_schemes'].include? 'open_id') -# #requires ruby-openid gem to be installed -# OpenID::Util.logger = RAILS_DEFAULT_LOGGER -# end - -if ( SITE_CONFIG['authentication_schemes'].include? 'cas') - #requires rubycas-client gem to be installed - if defined? CASClient - require 'casclient/frameworks/rails/filter' - CASClient::Frameworks::Rails::Filter.configure( - :cas_base_url => SITE_CONFIG['cas_server'] , - :cas_server_logout => SITE_CONFIG['cas_server_logout'] - ) - end -end - # changed in development.rb to show under_construction bar NOTIFY_BAR = "" unless defined?(NOTIFY_BAR)