-
-
Notifications
You must be signed in to change notification settings - Fork 195
/
notes_helper.rb
33 lines (28 loc) · 1.02 KB
/
notes_helper.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
module NotesHelper
def note_as_html(note, batch: false)
allowed_tags = batch ? batch_notes_allowed_tags : notes_allowed_tags
content = note.original_style? ? note.body : note.rich_body.to_trix_html
sanitize(content, tags: allowed_tags)
end
def render_notes(notes, batch: false, **options)
return unless notes.present?
tag.aside(**options.merge(id: 'notes')) do
Note.sort(notes).each do |note|
note_classes = ['note']
note_classes << "note--style-#{note.style}"
note_classes << "tag-#{note.notable_tag}" if note.notable_tag
concat tag.article note_as_html(note, batch: batch),
id: dom_id(note),
class: note_classes
end
end
end
def notes_allowed_tags
Alaveteli::Application.config.action_view.sanitized_allowed_tags +
%w(th time u font iframe) -
%w(html head body style)
end
def batch_notes_allowed_tags
notes_allowed_tags - %w(pre h1 h2 h3 h4 h5 h6 img blockquote font iframe)
end
end