Sha256: cc963c30361e4f79bf322094821daf4b1592b18c93aa2a1d2405cbb5988da55f
Contents?: true
Size: 1.3 KB
Versions: 1
Compression:
Stored size: 1.3 KB
Contents
module Humpyard module Elements #### # Humpyard::Elements::TextElement is a model of a text element. class TextElement < ::ActiveRecord::Base acts_as_humpyard_element :system_element => true attr_accessible :content, :html_content require 'globalize' translates :content validates_presence_of :content def html_content(options = {}) if content.blank? html = '' else if Object.const_defined?('RedCloth') html = RedCloth.new(content).to_html else html = content.gsub("\n", "<br />") end end unless html.blank? html = Humpyard.uri_parser.substitute html if options[:parse_uris] html.gsub(/(href="[a-z]*:\/\/)/,'target="blank" \1').html_safe else '' end end def html_content= content if content.blank? self.content = '' else if Object.const_defined?('RedCloth') require 'html_to_textile' self.content = HtmlToTextile.new(content.gsub("\n", ' ')).to_textile else self.content = content.gsub(/<br[^>]*>/, "\n").gsub(/<[^>]*>/, '') end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
humpyard-0.0.1 | app/models/humpyard/elements/text_element.rb |