class Object

Public Instance Methods

labeled_field(form, field, options={}) { |<< label| ... } click to toggle source
# File bolton_cms/manage/helpers/helper.rb, line 3
def labeled_field(form, field, options={}, &block)
  error = form.object.errors.include?(field)

  swap = options.delete(:swap) || false

  class_attr = [
    options[:class],
    ('field-error' if error),
    ('control' if swap)
  ].compact

  options[:class] = class_attr.join(' ') if class_attr.size > 0

  content_tag(:p, nil, options) do
    label = form.label(field, { caption: options.delete(:label) || field.to_s.titleize })
    if swap
      yield << label
    else
      label << yield
    end <<
    (error ? content_tag(:span, form.error_message_on(field), class: 'field-error-message') : '')
  end
end
render_active_fragments(page, wrapper_entity=:section) click to toggle source
# File bolton_cms/display/helpers/helper.rb, line 40
def render_active_fragments(page, wrapper_entity=:section)
  output = ''

  page.active_fragments.each do |label|
    if fragment = @page.find_fragment(label)
      output << content_tag(
        wrapper_entity,
        content_tag('h1', label) << render_cms_content(fragment.filter, fragment.body),
        class: "fragment-#{fragment.label.to_slug.normalize.to_s}"
      )
    end
  end

  output.html_safe
end
render_breadcrumbs(page) click to toggle source
# File bolton_cms/display/helpers/helper.rb, line 25
def render_breadcrumbs(page)
  title = page.title

  output = ''

  while page.has_parent?
    page = page.parent
    output << content_tag(:li, link_to(page.title, page.path))
  end

  output << content_tag(:li, content_tag(:strong, title))

  content_tag :nav, content_tag(:ul, output.html_safe), class: 'breadcrumbs'
end
render_children(page) click to toggle source
# File bolton_cms/display/helpers/helper.rb, line 7
def render_children(page)
  content_tag :nav, render_page_links(page.children, page), class: 'children'
end
render_cms_content(filter, content) click to toggle source
# File bolton_cms/display/helpers/helper.rb, line 56
def render_cms_content(filter, content)
  output = case filter
  when :raw
    content
  else
    BoltonCms::MDR.render(content)
  end

  output.html_safe
end
render_site_sections(sections, page=nil) click to toggle source
# File bolton_cms/display/helpers/helper.rb, line 3
def render_site_sections(sections, page=nil)
  content_tag :nav, render_page_links(sections, page), class: 'site-sections'
end
render_tree(object, node_fragment_path, level=1) click to toggle source
# File bolton_cms/manage/helpers/helper.rb, line 27
def render_tree(object, node_fragment_path, level=1)
  content_tag(:ul, class: level > 1 ? 'branch' : 'tree') do
    content_tag(:li, class: "node node-#{object.position}") do
      partial node_fragment_path, locals: { object: object, level: level+1 }
    end
  end
end
stamp(account, date) click to toggle source
# File bolton_cms/manage/helpers/helper.rb, line 35
def stamp(account, date)
  "#{ date.strftime('on %D at %r') } by #{ account.present? ? account.name : '[unknown]' }"
end