Module: ContentBase
Defined Under Namespace
Modules: ClassMethods
Classes: ContentTextHelpers
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#just_changed_published_status ⇒ Object
Also known as:
just_changed_published_status?
Returns the value of attribute just_changed_published_status.
14
15
16
|
# File 'app/models/content_base.rb', line 14
def just_changed_published_status
@just_changed_published_status
end
|
Class Method Details
.included(base) ⇒ Object
4
5
6
|
# File 'app/models/content_base.rb', line 4
def self.included(base)
base.extend ClassMethods
end
|
Instance Method Details
#default_text_filter ⇒ Object
The default text filter. Generally, this is the filter specified by blog.text_filter, but comments may use a different default.
81
82
83
|
# File 'app/models/content_base.rb', line 81
def default_text_filter
blog.text_filter_object
end
|
#excerpt_text(length = 160) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'app/models/content_base.rb', line 62
def excerpt_text(length = 160)
text = if respond_to?(:excerpt) && (excerpt || "") != ""
generate_html(:excerpt, excerpt)
else
html(:all)
end
text = text.strip_html
text.slice(0, length) +
(text.length > length ? "..." : "")
end
|
#generate_html(field, text = nil) ⇒ Object
Generate HTML for a specific field using the text_filter in use for this object.
41
42
43
44
45
46
|
# File 'app/models/content_base.rb', line 41
def generate_html(field, text = nil)
text ||= self[field].to_s
prehtml = html_preprocess(field, text).to_s
html = (text_filter || default_text_filter).filter_text(prehtml) || prehtml
html_postprocess(field, html).to_s
end
|
#html(field = :all) ⇒ Object
Return HTML for some part of this object.
29
30
31
32
33
34
35
36
37
|
# File 'app/models/content_base.rb', line 29
def html(field = :all)
if field == :all
generate_html(:all, content_fields.map { |f| self[f].to_s }.join("\n\n"))
elsif html_map(field)
generate_html(field)
else
raise ArgumentError, "Field #{field.inspect} is not valid for #{self.class}"
end
end
|
#html_map(field) ⇒ Object
58
59
60
|
# File 'app/models/content_base.rb', line 58
def html_map(field)
content_fields.include? field
end
|
#html_postprocess(_field, html) ⇒ Object
49
50
51
52
|
# File 'app/models/content_base.rb', line 49
def html_postprocess(_field, html)
helper = ContentTextHelpers.new
helper.sanitize html
end
|
#html_preprocess(_field, html) ⇒ Object
54
55
56
|
# File 'app/models/content_base.rb', line 54
def html_preprocess(_field, html)
html
end
|
#really_send_notifications ⇒ Object
17
18
19
20
21
22
|
# File 'app/models/content_base.rb', line 17
def really_send_notifications
interested_users.each do |value|
send_notification_to_user(value)
end
true
end
|
#send_notification_to_user(user) ⇒ Object
24
25
26
|
# File 'app/models/content_base.rb', line 24
def send_notification_to_user(user)
notify_user_via_email(user)
end
|
#text_filter ⇒ Object
75
76
77
|
# File 'app/models/content_base.rb', line 75
def text_filter
TextFilter.make_filter(text_filter_name)
end
|