Class: WaxTasks::Site
- Inherits:
-
Object
- Object
- WaxTasks::Site
- Defined in:
- lib/wax_tasks/site.rb
Constant Summary collapse
- IMAGE_DERIVATIVE_DIRECTORY =
'img/derivatives'
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #collections ⇒ Object
- #generate_derivatives(name, type) ⇒ Object
- #generate_pages(name) ⇒ Object
- #generate_static_search(name) ⇒ Object
-
#initialize(config = nil) ⇒ Site
constructor
A new instance of Site.
Constructor Details
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/wax_tasks/site.rb', line 7 def config @config end |
Instance Method Details
#collections ⇒ Object
18 19 20 |
# File 'lib/wax_tasks/site.rb', line 18 def collections @config.collections end |
#generate_derivatives(name, type) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/wax_tasks/site.rb', line 51 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 output_dir = Utils.safe_join @config.source, IMAGE_DERIVATIVE_DIRECTORY, type records = case type when 'iiif' collection.write_iiif_derivatives output_dir when 'simple' collection.write_simple_derivatives output_dir end collection. records puts Rainbow("\nDone ✔").green end |
#generate_pages(name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wax_tasks/site.rb', line 24 def generate_pages(name) result = 0 collection = @config.find_collection name raise WaxTasks::Error::InvalidCollection if collection.nil? collection..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 |
#generate_static_search(name) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/wax_tasks/site.rb', line 39 def generate_static_search(name) search_config = @config.search name index = WaxTasks::Index.new(search_config) puts Rainbow("Generating #{name} search index to #{index.path}").cyan index.write_to @config.source puts Rainbow("\nDone ✔").green end |