diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 56dc69f6..e94aac3a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -123,6 +123,12 @@ class ApplicationController < ActionController::Base formatted_date end + + def for_autocomplete(coll, substr) + filtered = coll.find_all{|item| item.name.downcase.include? substr.downcase} + return filtered.map {|item| "#{item.name}|#{item.id}"}.join("\n") + end + # Uses RedCloth to transform text using either Textile or Markdown Need to # require redcloth above RedCloth 3.0 or greater is needed to use Markdown, # otherwise it only handles Textile diff --git a/app/controllers/contexts_controller.rb b/app/controllers/contexts_controller.rb index 75f3d1c5..d6492211 100644 --- a/app/controllers/contexts_controller.rb +++ b/app/controllers/contexts_controller.rb @@ -22,6 +22,7 @@ class ContextsController < ApplicationController format.rss &render_contexts_rss_feed format.atom &render_contexts_atom_feed format.text { render :action => 'index', :layout => false, :content_type => Mime::TEXT } + format.autocomplete { render :text => for_autocomplete(@active_contexts + @hidden_contexts, params[:q])} end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a6604cb3..2baffa1a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -26,6 +26,7 @@ class ProjectsController < ApplicationController format.rss &render_rss_feed format.atom &render_atom_feed format.text &render_text_feed + format.autocomplete { render :text => for_autocomplete(@projects, params[:q]) } end end end diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb index 67b983f2..4ad8446e 100644 --- a/app/controllers/todos_controller.rb +++ b/app/controllers/todos_controller.rb @@ -526,6 +526,13 @@ class TodosController < ApplicationController } end end + + def tags + @tags = Tag.all + respond_to do |format| + format.autocomplete { render :text => for_autocomplete(@tags, params[:q]) } + end + end def defer @source_view = params['_source_view'] || 'todo' diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 645be1c4..76622c50 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -202,9 +202,11 @@ module ApplicationHelper end def format_note(note) + note.gsub!(//, '>') + note = markdown(note) note = auto_link_message(note) note = auto_link(note) - note = markdown(note) - note = sanitize(note) + return note end end diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 170c6aca..1c3d51c0 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -2,4 +2,8 @@ module NotesHelper def truncated_note(note, characters = 50) sanitize(textilize_without_paragraph(truncate(note.body, :length => characters, :omission => "..."))) end + + def rendered_note(note) + sanitize(textilize_without_paragraph(note.body)) + end end diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 8eafc567..6c8703c6 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -276,20 +276,6 @@ module TodosHelper return "c#{todo.context_id}empty-nd" end - def project_names_for_autocomplete - 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( current_user.contexts.collect{|c| escape_javascript(c.name) } ) - end - - def tag_names_for_autocomplete - array_or_string_for_javascript( Tag.all.collect{|c| escape_javascript(c.name) } ) - end - def default_contexts_for_autocomplete projects = current_user.projects.find(:all, :conditions => ['default_context_id is not null']) Hash[*projects.map{ |p| [p.name, p.default_context.name] }.flatten].to_json diff --git a/app/views/layouts/standard.html.erb b/app/views/layouts/standard.html.erb index f5713db2..cf555a73 100644 --- a/app/views/layouts/standard.html.erb +++ b/app/views/layouts/standard.html.erb @@ -6,18 +6,16 @@ 'jquery.autocomplete', :cache => true %> <%= stylesheet_link_tag "print", :media => "print" %> <%= javascript_include_tag 'jquery','jquery-ui','jquery.cookie', - 'jquery.blockUI','jquery.jeditable','jquery.autocomplete', :cache => 'jquery-all' %> + 'jquery.blockUI','jquery.jeditable','jquery.autocomplete', + 'jquery.truncator', :cache => 'jquery-all' %> <%= javascript_include_tag 'hoverIntent','superfish','application', 'accesskey-hints','niftycube','flashobject', :cache => 'tracks' %> <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %> <%= javascript_tag "var SOURCE_VIEW = '#{@source_view}';" %> <%= javascript_tag "var TAG_NAME = '#{@tag_name}';" if @tag_name %>