module JavyTool::Breadcrumb::Helpers

Public Instance Methods

foot() { || ... } click to toggle source

add javascript to foot

# File lib/javy_tool/breadcrumb.rb, line 177
def foot
  content_for(:foot) do
    yield.html_safe
  end
end
format_timestamp(ts,format='%Y-%m-%d %H:%M') click to toggle source

format time

# File lib/javy_tool/breadcrumb.rb, line 183
def format_timestamp(ts,format='%Y-%m-%d %H:%M')
  ts.strftime(format)
end
head(head_identity=nil) { || ... } click to toggle source

set head description,keywords etc

# File lib/javy_tool/breadcrumb.rb, line 164
def head(head_identity=nil)
  content_for(:head) do
    case head_identity
    when "description"
      "<meta name=\"description\" content=\"#{yield}\" />\n"
    when "keywords"
      "<meta name=\"keywords\"  content=\"#{yield}\" />\n"
    else
      yield
    end.html_safe
  end
end
notice_message(cls: 'alert-box') click to toggle source

display the flash messages using foundation

# File lib/javy_tool/breadcrumb.rb, line 56
def notice_message(cls: 'alert-box')
  flash_messages = []
  flash.each do |type, message|
    next if message.nil?
    type = :info if type == :notice
    type = :alert if type == :error
    text = content_tag(:div, message.html_safe, class: "#{cls} #{type}")
    flash_messages << text if message
  end
  flash_messages.join("\n").html_safe
end
render_body_tag() click to toggle source
# File lib/javy_tool/breadcrumb.rb, line 48
def render_body_tag
  class_attribute = ["#{controller_name}-controller","#{action_name}-action"].join(" ")
  id_attribute = (@body_id)? " id=\"#{@body_id}-page\"" : ""
  raw(%Q[ <body#{id_attribute} class="#{class_attribute}"> ])
end
render_breadcrumb() click to toggle source
# File lib/javy_tool/breadcrumb.rb, line 72
def render_breadcrumb
  return "" if @breadcrumbs.nil? || @breadcrumbs.size <= 0
  prefix = "".html_safe
  crumb = []#.html_safe

  @breadcrumbs.each_with_index do |c, i|
    breadcrumb_class = []
    breadcrumb_class << "current" if i == (@breadcrumbs.length - 1)

    crumb.push content_tag(:li, c ,:class => breadcrumb_class )
  end
  return prefix + content_tag(:ul, crumb.join("").html_safe, :class => "breadcrumbs")
end
render_page_title() click to toggle source

set SITE_NAME in enviroment.rb set @page_title in controller respectively add<%= render_page_title %> in head

# File lib/javy_tool/breadcrumb.rb, line 43
def render_page_title
  title = @page_title ? "#{@page_title}_#{SITE_NAME}" : SITE_NAME rescue "SITE_NAME"
  content_tag("title", title, nil, false)
end
s(html) click to toggle source
# File lib/javy_tool/breadcrumb.rb, line 68
def s(html)
  sanitize( html, :tags => %w(table thead tbody tr td th ol ul li div span font img sup sub br hr a pre p h1 h2 h3 h4 h5 h6), :attributes => %w(id class style src href size color) )
end
yield_or_default(message, default_message = "") click to toggle source
# File lib/javy_tool/breadcrumb.rb, line 37
def yield_or_default(message, default_message = "")
  message.nil? ? default_message : message
end