Module: TaggableHelper
- Included in:
- Radius::LibraryTags, Radius::TaggableTags
- Defined in:
- app/helpers/taggable_helper.rb
Instance Method Summary collapse
- #available_pointer_pages ⇒ Object
- #clean_html(text) ⇒ Object
- #pointer_option_branch(page, depth = 0) ⇒ Object
- #scrub_html(text) ⇒ Object
- #truncate_words(text = '', options = {}) ⇒ Object
Instance Method Details
#available_pointer_pages ⇒ Object
22 23 24 25 26 27 |
# File 'app/helpers/taggable_helper.rb', line 22 def available_pointer_pages() root = Page.respond_to?(:homepage) ? Page.homepage : Page.find_by_parent_id(nil) = pointer_option_branch(root) .unshift ['<none>', nil] end |
#clean_html(text) ⇒ Object
5 6 7 |
# File 'app/helpers/taggable_helper.rb', line 5 def clean_html(text) Sanitize.clean(text, Sanitize::Config::RELAXED) end |
#pointer_option_branch(page, depth = 0) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/taggable_helper.rb', line 29 def pointer_option_branch(page, depth=0) = [] unless page.virtual? || page.sheet? || page.has_pointer? << ["#{". " * depth}#{h(page.title)}", page.id] page.children.each do |child| += pointer_option_branch(child, depth + 1) end end end |
#scrub_html(text) ⇒ Object
9 10 11 |
# File 'app/helpers/taggable_helper.rb', line 9 def scrub_html(text) Sanitize.clean(text) end |
#truncate_words(text = '', options = {}) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/helpers/taggable_helper.rb', line 13 def truncate_words(text='', ={}) return '' if text.blank? .reverse_merge!(:length => 30, :omission => '…') words = text.split length = [:length].to_i [:omission] = '' unless words.size > length words[0..(length-1)].join(" ") + [:omission] end |