textile_article.rb
696 Bytes
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
34
35
36
37
38
39
40
class TextileArticle < TextArticle
  def self.short_description
    _('Text article with Textile markup language')
  end
  def self.description
    _('Accessible alternative for visually impaired users.')
  end
  def to_html(options ={})
    convert_to_html(body)
  end
  def lead(length = nil)
    if abstract.blank?
      super
    else
      convert_to_html(abstract)
    end
  end
  def notifiable?
    true
  end
  def can_display_media_panel?
    true
  end
  protected
  def convert_to_html(textile)
    @@sanitizer ||= HTML::WhiteListSanitizer.new
    converter = RedCloth.new(textile|| '')
    converter.hard_breaks = false
    @@sanitizer.sanitize(converter.to_html)
  end
end