Class | Nanoc3::Site |
In: |
lib/nanoc3/base/site.rb
|
Parent: | Object |
The in-memory representation of a nanoc site. It holds references to the following site data:
In addition, each site has a {config} hash which stores the site configuration.
A site also has several helper classes:
The physical representation of a {Nanoc3::Site} is usually a directory that contains a configuration file, site data, a rakefile, a rules file, etc. The way site data is stored depends on the data source.
DEFAULT_DATA_SOURCE_CONFIG | = | { :type => 'filesystem_unified', :items_root => '/', :layouts_root => '/', :config => {} | The default configuration for a data source. A data source‘s configuration overrides these options. | |
DEFAULT_CONFIG | = | { :text_extensions => %w( css erb haml htm html js less markdown md php rb sass txt xhtml xml ), :output_dir => 'output', :data_sources => [ {} ], :index_filenames => [ 'index.html' ], :enable_output_diff => false | The default configuration for a site. A site‘s configuration overrides these options: when a {Nanoc3::Site} is created with a configuration that lacks some options, the default value will be taken from `DEFAULT_CONFIG`. |
config | [R] |
The site configuration. The configuration has the following keys:
The list of data sources consists of hashes with the following keys:
@return [Hash] The site configuration |
config_mtime | [R] | @return [Time] The timestamp when the site configuration was last modified |
preprocessor | [RW] | @return [Proc] The code block that will be executed after all data is loaded but before the site is compiled |
rules_mtime | [R] | @return [Time] The timestamp when the rules were last modified |
Returns this site’s code snippets.
@return [Array<Nanoc3::CodeSnippet>] The list of code snippets in this site
@raise [Nanoc3::Errors::DataNotYetAvailable] if the site data hasn’t been loaded yet (call {load_data} to load the site data)
Returns the compiler for this site. Will create a new compiler if none exists yet.
@return [Nanoc3::Compiler] The compiler for this site
Returns the data sources for this site. Will create a new data source if none exists yet.
@return [Array<Nanoc3::DataSource>] The list of data sources for this site
@raise [Nanoc3::Errors::UnknownDataSource] if the site configuration specifies an unknown data source
Returns this site’s items.
@return [Array<Nanoc3::Item>] The list of items in this site
@raise [Nanoc3::Errors::DataNotYetAvailable] if the site data hasn’t been loaded yet (call {load_data} to load the site data)
Returns this site’s layouts.
@return [Array<Nanoc3::Layouts>] The list of layout in this site
@raise [Nanoc3::Errors::DataNotYetAvailable] if the site data hasn’t been loaded yet (call {load_data} to load the site data)
Loads the site data. This will query the {Nanoc3::DataSource} associated with the site and fetch all site data. The site data is cached, so calling this method will not have any effect the second time, unless the `force` parameter is true.
@param [Boolean] force If true, will force load the site data even if it has been loaded before, to circumvent caching issues
@return [void]