class WaxTasks::Site

Attributes

config[R]

Public Class Methods

new(config = nil) click to toggle source
# File lib/wax_tasks/site.rb, line 11
def initialize(config = nil)
  @config = WaxTasks::Config.new(config || WaxTasks.config_from_file)
end

Public Instance Methods

clobber(name) click to toggle source
# File lib/wax_tasks/site.rb, line 23
def clobber(name)
  collection = @config.find_collection name
  raise WaxTasks::Error::InvalidCollection if collection.nil?

  collection.clobber_pages
  collection.clobber_derivatives

  @config.self.fetch('search', {}).each do |_name, search|
    next unless search.key? 'index'
    index = Utils.safe_join @config.source, search['index']
    next unless File.exist? index
    puts Rainbow("Removing search index #{index}").cyan
    FileUtils.rm index
  end

  puts Rainbow("\nDone ✔").green
end
collections() click to toggle source
# File lib/wax_tasks/site.rb, line 17
def collections
  @config.collections
end
generate_derivatives(name, type) click to toggle source
# File lib/wax_tasks/site.rb, line 70
def generate_derivatives(name, type)
  collection = @config.find_collection name
  raise WaxTasks::Error::InvalidCollection if collection.nil?
  raise WaxTasks::Error::InvalidConfig unless %w[iiif simple].include? type

  records = case type
            when 'iiif'
              collection.write_iiif_derivatives
            when 'simple'
              collection.write_simple_derivatives
            end

  collection.update_metadata records
  puts Rainbow("\nDone ✔").green
end
generate_pages(name) click to toggle source
# File lib/wax_tasks/site.rb, line 43
def generate_pages(name)
  result     = 0
  collection = @config.find_collection name
  raise WaxTasks::Error::InvalidCollection if collection.nil?

  collection.records_from_metadata.each do |record|
    result += record.write_to_page(collection.page_source)
  end

  puts Rainbow("#{result} pages were generated to #{collection.page_source}.").cyan
  puts Rainbow("\nDone ✔").green
end