Class: Awestruct::Extensions::Indexifier

Inherits:
Object
  • Object
show all
Defined in:
lib/awestruct/extensions/indexifier.rb

Instance Method Summary collapse

Constructor Details

#initialize(exclude_regex_paths = []) ⇒ Indexifier

Returns a new instance of Indexifier



5
6
7
8
# File 'lib/awestruct/extensions/indexifier.rb', line 5

def initialize(exclude_regex_paths = [])
  @exclude_regex_paths = exclude_regex_paths
  @exclude_regex_paths << /^(.*\/)?index.html$/
end

Instance Method Details

#execute(site) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/awestruct/extensions/indexifier.rb', line 10

def execute(site)
  site.pages.each do |page|
    if ( page.inhibit_indexifier ||  Regexp.union(@exclude_regex_paths).match(page.output_path) )
      # skip it!
    else
      page.output_path = page.output_path.gsub( /.html$/, '/index.html' )
    end
  end
end