Extend RichMessage format to include other data

Uses new Regex to detect:

 @ context
 ~ project
 > tickler-date
 < due-date
 # tag (repeatable)
 * (starred)
This commit is contained in:
Greg Sutcliffe 2013-10-13 22:11:55 +01:00
parent 1441d53808
commit 2f043911c6
7 changed files with 180 additions and 25 deletions

View file

@ -1,6 +1,4 @@
class MessageGateway < ActionMailer::Base
include ActionView::Helpers::SanitizeHelper
extend ActionView::Helpers::SanitizeHelper::ClassMethods
def receive(email)
user = get_receiving_user_from_email_address(email)
@ -85,11 +83,11 @@ class MessageGateway < ActionMailer::Base
end
def get_text_or_nil(text)
return text ? sanitize(text.strip) : nil
return text ? text.strip : nil
end
def get_decoded_text_or_nil(text)
return text ? sanitize(text.decoded.strip) : nil
return text ? text.decoded.strip : nil
end
def get_first_text_plain_part(email)
@ -99,7 +97,7 @@ class MessageGateway < ActionMailer::Base
# remove all parts that are not text/plain
parts.reject{|part| !part.content_type.start_with?("text/plain") }
return parts.count > 0 ? sanitize(parts[0].decoded.strip) : ""
return parts.count > 0 ? parts[0].decoded.strip : ""
end
def get_all_parts(parts)

View file

@ -12,6 +12,7 @@ class Project < ActiveRecord::Base
scope :uncompleted, -> { where("NOT(state = ?)", 'completed') }
scope :with_name_or_description, lambda { |body| where("name LIKE ? OR description LIKE ?", body, body) }
scope :with_namepart, lambda { |body| where("name LIKE ?", body + '%') }
validates_presence_of :name
validates_length_of :name, :maximum => 255