Sha256: 50fd0e4d4bd72bfcfd550420091dfa1d5024d7a72404b71c065bc316b6beb319

Contents?: true

Size: 749 Bytes

Versions: 1

Compression:

Stored size: 749 Bytes

Contents

module Kuhsaft
  class TextBrick < Brick
    attr_accessible :text, :read_more_text

    before_save :strip_read_more_text

    def user_can_add_childs?
      false
    end

    def collect_fulltext
      [super, text, read_more_text].join(' ')
    end

    private

    # Clear read_more_text field if it just contains an empty p tag
    #
    # readctor.js injects an almost empty p-tag into empty form fields.
    # However, instead of being really empty, it currently contains the &#8203; (Zero width space)
    # Character.
    def strip_read_more_text
      read_more_text.clear if text_contains_funky_chars
    end

    def text_contains_funky_chars
      read_more_text && read_more_text.strip.hash == -1282209220116339654
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kuhsaft-1.2.11 app/models/kuhsaft/text_brick.rb