diff --git a/.gitignore b/.gitignore index bd1d8742..433e85a0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ nbproject vendor/plugins/query_trace/ db/schema.rb .dotest +public/javascripts/cache +public/stylesheets/cache \ No newline at end of file diff --git a/app/controllers/application.rb b/app/controllers/application.rb index b24dfd54..0d54b75f 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -32,13 +32,13 @@ class ApplicationController < ActionController::Base before_filter :set_time_zone prepend_before_filter :login_required prepend_before_filter :enable_mobile_content_negotiation - after_filter :restore_content_type_for_mobile after_filter :set_charset include ActionView::Helpers::TextHelper include ActionView::Helpers::SanitizeHelper + extend ActionView::Helpers::SanitizeHelper::ClassMethods helper_method :format_date, :markdown # By default, sets the charset to UTF-8 if it isn't already set @@ -148,21 +148,15 @@ class ApplicationController < ActionController::Base # during the processing and then setting it to 'text/html' in an # 'after_filter' -LKM 2007-04-01 def mobile? - return params[:format] == 'm' || response.content_type == MOBILE_CONTENT_TYPE + return params[:format] == 'm' end def enable_mobile_content_negotiation if mobile? - request.accepts.unshift(Mime::Type::lookup(MOBILE_CONTENT_TYPE)) + request.format = :m end end - def restore_content_type_for_mobile - if mobile? - response.content_type = 'text/html' - end - end - def create_todo_from_recurring_todo(rt, date=nil) # create todo and initialize with data from recurring_todo rt todo = current_user.todos.build( { :description => rt.description, :notes => rt.notes, :project_id => rt.project_id, :context_id => rt.context_id}) @@ -234,8 +228,13 @@ class ApplicationController < ActionController::Base end def init_data_for_sidebar - @projects = @projects || current_user.projects.find(:all, :include => [:default_context ]) - @contexts = @contexts || current_user.contexts + @completed_projects = current_user.projects.completed + @hidden_projects = current_user.projects.hidden + @active_projects = current_user.projects.active + + @active_contexts = current_user.contexts.active + @hidden_contexts = current_user.contexts.hidden + init_not_done_counts if prefs.show_hidden_projects_in_sidebar init_project_hidden_todo_counts(['project']) @@ -244,13 +243,13 @@ class ApplicationController < ActionController::Base def init_not_done_counts(parents = ['project','context']) parents.each do |parent| - eval("@#{parent}_not_done_counts = @#{parent}_not_done_counts || Todo.count(:conditions => ['user_id = ? and state = ?', current_user.id, 'active'], :group => :#{parent}_id)") + eval("@#{parent}_not_done_counts = @#{parent}_not_done_counts || current_user.todos.active.count(:group => :#{parent}_id)") end end def init_project_hidden_todo_counts(parents = ['project','context']) parents.each do |parent| - eval("@#{parent}_project_hidden_todo_counts = @#{parent}_project_hidden_todo_counts || Todo.count(:conditions => ['user_id = ? and (state = ? or state = ?)', current_user.id, 'project_hidden', 'active'], :group => :#{parent}_id)") + eval("@#{parent}_project_hidden_todo_counts = @#{parent}_project_hidden_todo_counts || current_user.todos.count(:conditions => ['state = ? or state = ?', 'project_hidden', 'active'], :group => :#{parent}_id)") end end diff --git a/app/controllers/contexts_controller.rb b/app/controllers/contexts_controller.rb index d09883a4..348151aa 100644 --- a/app/controllers/contexts_controller.rb +++ b/app/controllers/contexts_controller.rb @@ -201,6 +201,9 @@ class ContextsController < ApplicationController :conditions => ['todos.state = ? AND (todos.project_id IS ? OR projects.state = ?)', 'active', nil, 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [:project, :tags]) + + @projects = current_user.projects + @count = @not_done_todos.size @default_project_context_name_map = build_default_project_context_name_map(@projects).to_json end diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 6038f3f3..8ccf710a 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -76,7 +76,7 @@ class TodosController < ApplicationController format.m do @return_path=cookies[:mobile_url] # todo: use function for this fixed path - @return_path='/mobile' if @return_path.nil? + @return_path='/m' if @return_path.nil? if @saved redirect_to @return_path else @@ -399,8 +399,9 @@ class TodosController < ApplicationController :limit => max_completed, :conditions => ['taggings.user_id = ? and state = ?', current_user.id, 'completed'], :order => 'todos.completed_at DESC') - - @contexts = current_user.contexts.find(:all) + + @projects = current_user.projects + @contexts = current_user.contexts @contexts_to_show = @contexts.reject {|x| x.hide? } # Set count badge to number of items with this tag diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 42ebe65e..170c6aca 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -1,5 +1,5 @@ module NotesHelper def truncated_note(note, characters = 50) - sanitize(textilize_without_paragraph(truncate(note.body, characters, "..."))) + sanitize(textilize_without_paragraph(truncate(note.body, :length => characters, :omission => "..."))) end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index ce2c0364..c0a6640d 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -20,12 +20,12 @@ module ProjectsHelper def project_next_prev html = '' unless @previous_project.nil? - project_name = truncate(@previous_project.name, 40, "...") + project_name = truncate(@previous_project.name, :length => 40, :omission => "...") html << link_to_project(@previous_project, "« #{project_name}") end html << ' | ' if @previous_project && @next_project unless @next_project.nil? - project_name = truncate(@next_project.name, 40, "...") + project_name = truncate(@next_project.name, :length => 40, :omission => "...") html << link_to_project(@next_project, "#{project_name} »") end html @@ -34,12 +34,12 @@ module ProjectsHelper def project_next_prev_mobile html = '' unless @previous_project.nil? - project_name = truncate(@previous_project.name, 40, "...") + project_name = truncate(@previous_project.name, :length => 40, :omission => "...") html << link_to_project_mobile(@previous_project, "5", "« 5-#{project_name}") end html << ' | ' if @previous_project && @next_project unless @next_project.nil? - project_name = truncate(@next_project.name, 40, "...") + project_name = truncate(@next_project.name, :length => 40, :omission => "...") html << link_to_project_mobile(@next_project, "6", "6-#{project_name} »") end html diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index aee59c90..06671b26 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -117,7 +117,7 @@ module TodosHelper "" + link_to(t.name, {:action => "tag", :controller => "todos", :id => t.name+".m"}) + ""}.join('') - "#{tag_list}" + if not tag_list.empty? then "#{tag_list}" end end def deferred_due_date @@ -242,13 +242,13 @@ module TodosHelper end def project_names_for_autocomplete - array_or_string_for_javascript( ['None'] + @projects.select{ |p| p.active? }.collect{|p| escape_javascript(p.name) } ) + array_or_string_for_javascript( ['None'] + current_user.projects.active.collect{|p| escape_javascript(p.name) } ) end def context_names_for_autocomplete # #return array_or_string_for_javascript(['Create a new context']) if # @contexts.empty? - array_or_string_for_javascript( @contexts.collect{|c| escape_javascript(c.name) } ) + array_or_string_for_javascript( current_user.contexts.collect{|c| escape_javascript(c.name) } ) end def format_ical_notes(notes) diff --git a/app/models/message_gateway.rb b/app/models/message_gateway.rb index 8fcb78d3..501650e0 100644 --- a/app/models/message_gateway.rb +++ b/app/models/message_gateway.rb @@ -1,5 +1,7 @@ class MessageGateway < ActionMailer::Base include ActionView::Helpers::SanitizeHelper + extend ActionView::Helpers::SanitizeHelper::ClassMethods + def receive(email) user = User.find(:first, :include => [:preference], :conditions => ["preferences.sms_email = ?", email.from[0].strip]) if user.nil? diff --git a/app/models/user.rb b/app/models/user.rb index 8a85b64b..fd649b10 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -188,7 +188,7 @@ class User < ActiveRecord::Base end def at_midnight(date) - return TimeZone[prefs.time_zone].local(date.year, date.month, date.day, 0, 0, 0) + return ActiveSupport::TimeZone[prefs.time_zone].local(date.year, date.month, date.day, 0, 0, 0) end def generate_token diff --git a/app/views/contexts/_mobile_context.rhtml b/app/views/contexts/_mobile_context.rhtml index 6510aeb4..71c3945d 100644 --- a/app/views/contexts/_mobile_context.rhtml +++ b/app/views/contexts/_mobile_context.rhtml @@ -6,9 +6,9 @@ if not @not_done.empty? # only show a context when there are actions in it -%>

<%=mobile_context.name%>

- +
<%= render :partial => "todos/mobile_todo", :collection => @not_done, :locals => { :parent_container_type => "context" }-%>
-<% end -%> \ No newline at end of file +<% end -%> diff --git a/app/views/contexts/show.html.erb b/app/views/contexts/show.html.erb index eded894d..a22e4728 100644 --- a/app/views/contexts/show.html.erb +++ b/app/views/contexts/show.html.erb @@ -8,5 +8,5 @@
<%= render :partial => "shared/add_new_item_form" %> -<%= render "sidebar/sidebar" %> + <%= render :template => "sidebar/sidebar" %>
\ No newline at end of file diff --git a/app/views/feedlist/index.html.erb b/app/views/feedlist/index.html.erb index 7acc405c..5c855e16 100644 --- a/app/views/feedlist/index.html.erb +++ b/app/views/feedlist/index.html.erb @@ -123,7 +123,7 @@
- <%= render "sidebar/sidebar" %> + <%= render :template => "sidebar/sidebar" %>
\ No newline at end of file diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index 0c7781e3..696cd0cf 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -74,5 +74,5 @@
<%= render :partial => "shared/add_new_item_form" %> - <%= render "sidebar/sidebar" %> + <%= render :template => "sidebar/sidebar" %>
diff --git a/app/views/recurring_todos/create.js.rjs b/app/views/recurring_todos/create.js.rjs index 32602607..1704cf02 100644 --- a/app/views/recurring_todos/create.js.rjs +++ b/app/views/recurring_todos/create.js.rjs @@ -13,7 +13,7 @@ if @recurring_saved page.hide 'recurring-todos-empty-nd' page.insert_html :bottom, 'recurring_todos_container', - :partial => 'recurring_todos/recurring_todo' + :partial => 'recurring_todos/recurring_todo', :locals => { :recurring_todo => @recurring_todo} page.visual_effect :highlight, dom_id(@recurring_todo), :duration => 3 # update badge count page['badge_count'].replace_html @count diff --git a/app/views/recurring_todos/toggle_check.js.rjs b/app/views/recurring_todos/toggle_check.js.rjs index aa21b8c9..b0cde7ff 100644 --- a/app/views/recurring_todos/toggle_check.js.rjs +++ b/app/views/recurring_todos/toggle_check.js.rjs @@ -4,7 +4,7 @@ if @saved if @recurring_todo.completed? # show completed recurring todo - page.insert_html :top, "completed_recurring_todos_container", :partial => 'recurring_todos/recurring_todo' + page.insert_html :top, "completed_recurring_todos_container", :partial => 'recurring_todos/recurring_todo', :locals => { :recurring_todo => @recurring_todo } page.visual_effect :highlight, dom_id(@recurring_todo), :duration => 3 # set empty messages @@ -14,7 +14,7 @@ if @saved # recurring_todo is activated # show completed recurring todo - page.insert_html :top, "recurring_todos_container", :partial => 'recurring_todos/recurring_todo' + page.insert_html :top, "recurring_todos_container", :partial => 'recurring_todos/recurring_todo', :locals => { :recurring_todo => @recurring_todo } page.visual_effect :highlight, dom_id(@recurring_todo), :duration => 3 # inform user if a new todo has been created because of the activation diff --git a/app/views/recurring_todos/update.js.rjs b/app/views/recurring_todos/update.js.rjs index c8061a9c..ad35f1ef 100644 --- a/app/views/recurring_todos/update.js.rjs +++ b/app/views/recurring_todos/update.js.rjs @@ -13,7 +13,7 @@ if @saved page << "projectAutoCompleter.options.array = #{project_names_for_autocomplete}; projectAutoCompleter.changed = true" if @new_project_created # replace old recurring todo with updated todo - page.replace dom_id(@recurring_todo), :partial => 'recurring_todos/recurring_todo' + page.replace dom_id(@recurring_todo), :partial => 'recurring_todos/recurring_todo', :locals => { :recurring_todo => @recurring_todo } page.visual_effect :highlight, dom_id(@recurring_todo), :duration => 3 else diff --git a/app/views/shared/_add_new_item_form.rhtml b/app/views/shared/_add_new_item_form.rhtml index 65316245..c84e0580 100644 --- a/app/views/shared/_add_new_item_form.rhtml +++ b/app/views/shared/_add_new_item_form.rhtml @@ -2,7 +2,7 @@ @todo = nil @initial_context_name = @context.name unless @context.nil? @initial_context_name ||= @project.default_context.name unless @project.nil? || @project.default_context.nil? - @initial_context_name ||= @contexts[0].name unless @contexts[0].nil? + @initial_context_name ||= current_user.contexts.first.name unless current_user.contexts.first.nil? @initial_project_name = @project.name unless @project.nil? %>
diff --git a/app/views/sidebar/sidebar.html.erb b/app/views/sidebar/sidebar.html.erb index bb5d8847..3de85ff3 100644 --- a/app/views/sidebar/sidebar.html.erb +++ b/app/views/sidebar/sidebar.html.erb @@ -1,30 +1,30 @@