Sha256: 7f4aa7e10dfd50c459967fedca8574832187fe5d1a074da073440c915560037d

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

module Noa
  module Layout
    module BaseHelper
      def layout_title
        if @title.blank?
          noa_application_name
        else
          "#{@title} | #{noa_application_name}"
        end
      end

      def layout_logo
        content_tag(:h1) do
          link_to_unless_current(noa_application_name, root_path) do
            noa_application_name
          end
        end
      end

      def layout_page_title
        unless @title.blank?
          if defined?(Twitter::Bootstrap::Rails)
            content_tag(:div, content_tag(:h1, @title), class: "page-header")
          else
            content_tag(:h1, @title)
          end
        end
      end

      def layout_copyright(author = nil, href = nil)
        author ||= noa_application_name
        content_tag(:div, id: "copyright") do
          "© #{Time.now.year} ".html_safe + 
          (href ? link_to(author, href) : author)
        end
      end

      def layout_flash
        if defined?(Twitter::Bootstrap::Rails)
          html = Array.new
          flash.each do |key, msg|
            case key.to_s
            when "alert"
              flash_class = "alert-error"
            when "notice"
              flash_class = "alert-info"
            else
              flash_class = key.to_s
            end
            close_button =
              '<button type="button" class="close" data-dismiss="alert">&times;</button>'
            html << content_tag(:div,
              close_button.html_safe + ' ' + msg.html_safe,
              class: ["alert", flash_class, "fade", "in"]
            )
          end
          html.join.html_safe
        else
          html = Array.new
          flash.each do |name, msg|
            html << content_tag(:div, msg, class: name)
          end
          html.join("\n").html_safe
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
noa-layout-0.0.1 app/helpers/noa/layout/base_helper.rb