Class: Proclaim::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
AASM
Defined in:
app/models/proclaim/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#excerpt_lengthObject



47
48
49
# File 'app/models/proclaim/post.rb', line 47

def excerpt_length
	@excerpt_length || Proclaim.excerpt_length
end

Instance Method Details

#body_plaintextObject



51
52
53
# File 'app/models/proclaim/post.rb', line 51

def body_plaintext
	HTMLEntities.new.decode(Rails::Html::FullSanitizer.new.sanitize(body.gsub(/\r\n?/, ' ')))
end

#excerptObject



55
56
57
58
59
60
61
62
63
# File 'app/models/proclaim/post.rb', line 55

def excerpt
	document = Nokogiri::HTML.fragment(body)

	unless document.text.empty?
		takeExcerptOf first_block_element_text(document)
	else
		""
	end
end

#notifyPostSubscribers(newComment) ⇒ Object



65
66
67
68
69
# File 'app/models/proclaim/post.rb', line 65

def notifyPostSubscribers(newComment)
	subscriptions.each do | subscription |
		subscription.deliver_new_comment_notification_email(newComment)
	end
end