Sha256: 39fa6fe9b4571b8a2d4ecf6abf014513b9d4e9266bcc128ab3f6ad89318e2e26

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

module Sunrise
  module Controllers
    module HeadOptions
      # Inclusion hook to make #current_user and #logged_in?
      # available as ActionView helper methods.
      def self.included(base)
        base.send :helper_method, :head_options if base.respond_to? :helper_method
      end
      
      def head_options(record, options = {})
        return if record.nil?
        
        options = { :spliter => Sunrise.title_spliter, :append_title => true }.merge(options)

        header = options[:header] || (record.respond_to?(:header) ? record.header : nil)

        if header && header.has_info?
          @page_keywords ||= header.read(:keywords)
          @page_description ||= header.read(:description)
          @page_title ||= header.read(:title)
        end

        @page_title ||= begin
          view_title = if record.respond_to?(:title)
            record.title
          elsif record.respond_to(:name)
            record.name
          end
          
          page_title = []
	        page_title << options[:title] if options.key?(:title)
          page_title << view_title
          page_title << I18n.t("page.title") if options[:append_title]

          page_title.flatten.compact.uniq.join(options[:spliter])
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sunrise-core-0.2.2 lib/sunrise/controllers/head_options.rb
sunrise-core-0.2.1 lib/sunrise/controllers/head_options.rb
sunrise-core-0.2.0 lib/sunrise/controllers/head_options.rb
sunrise-core-0.1.5 lib/sunrise/controllers/head_options.rb
sunrise-core-0.1.4 lib/sunrise/controllers/head_options.rb
sunrise-core-0.1.3 lib/sunrise/controllers/head_options.rb
sunrise-core-0.1.2 lib/sunrise/controllers/head_options.rb
sunrise-core-0.1.1 lib/sunrise/controllers/head_options.rb
sunrise-core-0.1.0 lib/sunrise/controllers/head_options.rb