Sha256: 7b041c8053c280b3e78fc6058fe81d09cafc56f0719b9985b15edd1b7484f361

Contents?: true

Size: 761 Bytes

Versions: 2

Compression:

Stored size: 761 Bytes

Contents

# -*- encoding: utf-8 -*-

module Genit

  # Modify head link tags.
  class HeadLinkBuilder < BuilderBase
    
    # Public: Build the document head link tags of a particular page.
    #
    # page_name - The string filename of the page.
    #
    # Returns the modified Nokogiri::XML::Document
    def build_for_page page_name
      build page_name, head_links
    end
    
    private
    
    def head_links
      @document.css("head link")
    end
    
    def update link
      @path = link['href']
      return if not_an_internal_link?
      nb = BuilderBase::get_number_of_base_dirs @page_name
      make_relative nb
      link['href'] = @path
    end
    
    def not_an_internal_link?
      @path.nil? or @path =~ URI::regexp
    end
    
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
genit-0.99 lib/genit/builders/head_link_builder.rb
genit-0.9 lib/genit/builders/head_link_builder.rb