diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 5c3d385c..aeae32cc 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -11,7 +11,7 @@ class ApplicationController < ActionController::Base
helper :application
include LoginSystem
- helper_method :current_user, :prefs, :format_date, :markdown
+ helper_method :current_user, :prefs, :format_date
layout proc{ |controller| controller.mobile? ? "mobile" : "standard" }
exempt_from_layout /\.js\.erb$/
diff --git a/app/controllers/todos_controller.rb b/app/controllers/todos_controller.rb
index fc6491a2..19a05d3c 100644
--- a/app/controllers/todos_controller.rb
+++ b/app/controllers/todos_controller.rb
@@ -1242,7 +1242,7 @@ class TodosController < ApplicationController
def todo_feed_content
# TODO: move view stuff into view, also the includes at the top
lambda do |i|
- item_notes = sanitize(markdown( i.notes )) if i.notes?
+ item_notes = i.rendered_notes if i.notes?
due = "
#{t('todos.feeds.due', :date => format_date(i.due))}
\n" if i.due?
done = "#{t('todos.feeds.completed', :date => format_date(i.completed_at))}
\n" if i.completed?
context_link = "#{ i.context.name }"
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index f7a2e696..1f318003 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -189,19 +189,6 @@ module ApplicationHelper
end
end
- def format_note(note)
- note = auto_link_message(note)
- note = markdown(note)
- note = auto_link(note, :link => :urls)
-
- # add onenote and message protocols
- Sanitize::Config::RELAXED[:protocols]['a']['href'] << 'onenote'
- Sanitize::Config::RELAXED[:protocols]['a']['href'] << 'message'
-
- note = Sanitize.clean(note, Sanitize::Config::RELAXED)
- return note
- end
-
def sidebar_html_for_titled_list (list, title)
return content_tag(:h3, title+" (#{list.length})") +
content_tag(:ul, sidebar_html_for_list(list))
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index 758c9c2f..0eb972eb 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -69,7 +69,7 @@ module ProjectsHelper
def summary(project)
project_description = ''
- project_description += sanitize(markdown( project.description )) unless project.description.blank?
+ project_description += Tracks::Utils.render_text( project.description ) unless project.description.blank?
project_description += content_tag(:p,
"#{count_undone_todos_phrase(p)}. " + t('projects.project_state', :state => project.state)
)
diff --git a/app/models/todo.rb b/app/models/todo.rb
index 88687ac1..4f22077e 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -398,10 +398,10 @@ class Todo < ActiveRecord::Base
end
def render_note
- unless notes.nil?
- rendered_notes = Tracks::Utils.render_text(notes)
+ unless self.notes.nil?
+ self.rendered_notes = Tracks::Utils.render_text(notes)
else
- rendered_notes = nil
+ self.rendered_notes = nil
end
end
diff --git a/lib/tracks/utils.rb b/lib/tracks/utils.rb
index 01368a03..86c17751 100644
--- a/lib/tracks/utils.rb
+++ b/lib/tracks/utils.rb
@@ -14,7 +14,7 @@ module Tracks
# do not change string; URL is alreay linked
href
else
- content = content_tag(:a, h(href), :href => h(href))
+ content = helpers.content_tag(:a, h(href), :href => h(href))
end
end
end
@@ -22,7 +22,7 @@ module Tracks
def self.render_text(text)
rendered = Tracks::Utils.auto_link_message(text)
rendered = markdown(rendered)
- rendered = ActionController::Base.helpers.auto_link(rendered, :link => :urls)
+ rendered = helpers.auto_link(rendered, :link => :urls)
# add onenote and message protocols
Sanitize::Config::RELAXED[:protocols]['a']['href'] << 'onenote'
@@ -39,7 +39,13 @@ module Tracks
def self.markdown(text)
RedCloth.new(text).to_html
end
-
+
+ private
+
+ def self.helpers
+ ActionController::Base.helpers
+ end
+
end
end
\ No newline at end of file
diff --git a/test/unit/todo_test.rb b/test/unit/todo_test.rb
index 48ee7c07..bfd8116a 100644
--- a/test/unit/todo_test.rb
+++ b/test/unit/todo_test.rb
@@ -386,4 +386,19 @@ class TodoTest < ActiveSupport::TestCase
assert !recent_created_todos.include?(todo_old)
end
+ def test_notes_are_rendered_on_save
+ user = @completed.user
+ todo = user.todos.create(:description => "test", :context => @completed.context)
+
+ assert_nil todo.notes
+ assert_nil todo.rendered_notes
+
+ todo.notes = "*test*"
+ todo.save!
+ todo.reload
+
+ assert_equal "*test*", todo.notes
+ assert_equal "test
", todo.rendered_notes
+ end
+
end