Module: FulltextConcern
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/generators/templates/app/models/concerns/fulltext_concern.rb
Instance Method Summary collapse
-
#fulltext_field_processing ⇒ Object
Méthode d’instance.
- #generate_fulltext_field ⇒ Object
- #htmlize(text, type) ⇒ Object
Instance Method Details
#fulltext_field_processing ⇒ Object
Méthode d’instance
18 19 20 21 |
# File 'lib/generators/templates/app/models/concerns/fulltext_concern.rb', line 18 def fulltext_field_processing # You can preparse with own things here generate_fulltext_field end |
#generate_fulltext_field ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/generators/templates/app/models/concerns/fulltext_concern.rb', line 23 def generate_fulltext_field fields = (self.class.fulltext_fields || []) fields.each{ |f| html, clear = htmlize(self[f], self[f + '_typetext']) self[f + '_fulltext'] = clear } end |
#htmlize(text, type) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/generators/templates/app/models/concerns/fulltext_concern.rb', line 31 def htmlize(text, type) case type #when 'bbcode' then # require 'bb-ruby' # html = text.bbcode_to_html when 'html' then html = text #when 'textile' then # html = RedCloth.new(text).to_html #when 'markdown' then # require 'rdiscount' # html = RDiscount.new(text).to_html #when 'wiki' then # html = WikiCloth::Parser.new({:data => text}).to_html else html end return html, Sanitize.clean(html) end |