store rendered notes of todos in database to avoid costly rendering when you load a page

This commit is contained in:
Reinier Balt 2012-04-12 11:34:08 +02:00
parent f32e5b256b
commit bb8b5a4c72
6 changed files with 81 additions and 27 deletions

View file

@ -189,24 +189,6 @@ module ApplicationHelper
end
end
AUTO_LINK_MESSAGE_RE = %r{message://<[^>]+>} unless const_defined?(:AUTO_LINK_MESSAGE_RE)
# Converts message:// links to href. This URL scheme is used on Mac OS X
# to link to a mail message in Mail.app.
def auto_link_message(text)
text.gsub(AUTO_LINK_MESSAGE_RE) do
href = $&
left, right = $`, $'
# detect already linked URLs and URLs in the middle of a tag
if left =~ /<[^>]+$/ && right =~ /^[^>]*>/
# do not change string; URL is alreay linked
href
else
content = content_tag(:a, h(href), :href => h(href))
end
end
end
def format_note(note)
note = auto_link_message(note)
note = markdown(note)