Sha256: 025589c4c3d9e3d40263b7ea53ec9b9348c8da60f2512edf7797dfc45ce86332

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

require 'sanitize'

module TaggableHelper

  def clean_html(text)
    Sanitize.clean(text, Sanitize::Config::RELAXED)
  end

  def scrub_html(text)
    Sanitize.clean(text)
  end

  def truncate_words(text='', options={})
    return '' if text.blank?
    options.reverse_merge!(:length => 30, :omission => '…')
    words = text.split
    length = options[:length].to_i
    options[:omission] = '' unless words.size > length
    words[0..(length-1)].join(" ") + options[:omission]
  end 

  def available_pointer_pages()
    root = Page.respond_to?(:homepage) ? Page.homepage : Page.find_by_parent_id(nil)
    options = pointer_option_branch(root)
    options.unshift ['<none>', nil]
    options
  end
    
  def pointer_option_branch(page, depth=0)
    options = []
    unless page.virtual? || page.sheet? || page.has_pointer?
      options << ["#{". " * depth}#{h(page.title)}", page.id]
      page.children.each do |child|
        options += pointer_option_branch(child, depth + 1)
      end
    end
    options
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
radiant-taggable-extension-2.0.5 app/helpers/taggable_helper.rb
radiant-taggable-extension-2.0.4 app/helpers/taggable_helper.rb
radiant-taggable-extension-2.0.3 app/helpers/taggable_helper.rb
radiant-taggable-extension-2.0.2 app/helpers/taggable_helper.rb
radiant-taggable-extension-2.0.1 app/helpers/taggable_helper.rb
radiant-taggable-extension-2.0.0 app/helpers/taggable_helper.rb