Module: SimpleContentManagement::ContentText

Extended by:
ActiveSupport::Concern
Included in:
SimplePage
Defined in:
lib/simple_content_management/content_text.rb

Instance Method Summary collapse

Instance Method Details

#update_content_textObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/simple_content_management/content_text.rb', line 13

def update_content_text
  tmpfile = Tempfile.new "content-text"
  begin
    tmpfile.write self.content_html
    tmpfile.flush
    self.content_text = `lynx -assume_charset=utf-8 -display_charset=utf-8 -dump -force_html #{tmpfile.path}`
    Rails.logger.info self.content_text
  ensure
    tmpfile.close true # `true` also deletes (unlinks) the file
  end
end

#update_content_text!Object



8
9
10
11
# File 'lib/simple_content_management/content_text.rb', line 8

def update_content_text!
  update_content_text
  save
end