Class: Bridgetown::Site

Inherits:
Object
  • Object
show all
Includes:
Configurable, Content, Extensible, FastRefreshable, Localizable, Processable, Renderable, SSR, Writable
Defined in:
lib/bridgetown-core/site.rb,
lib/bridgetown-core/concerns/site/ssr.rb,
lib/bridgetown-core/concerns/site/content.rb,
lib/bridgetown-core/concerns/site/writable.rb,
lib/bridgetown-core/concerns/site/extensible.rb,
lib/bridgetown-core/concerns/site/renderable.rb,
lib/bridgetown-core/concerns/site/localizable.rb,
lib/bridgetown-core/concerns/site/processable.rb,
lib/bridgetown-core/concerns/site/configurable.rb,
lib/bridgetown-core/concerns/site/fast_refreshable.rb

Defined Under Namespace

Modules: Configurable, Content, Extensible, FastRefreshable, Localizable, Processable, Renderable, SSR, Writable

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Writable

#cleanup, #each_site_file, #resources_cache_manifest, #write, #write_redirecting_index

Methods included from SSR

#disable_ssr, #enable_ssr, included, #ssr?, #ssr_first_read, #ssr_setup

Methods included from Renderable

#execute_inline_ruby_for_layouts!, #matched_converters_for_convertible, #render, #render_resources, #render_with_locale, #validated_layouts_for, #warn_on_missing_layout

Methods included from Processable

#process, #read, #refresh_layouts_and_data, #reset

Methods included from Localizable

#locale, #locale=

Methods included from FastRefreshable

#fast_refresh

Methods included from Extensible

#find_converter_instance, #generate, #instantiate_subclasses, #on, #setup

Methods included from Content

#add_generated_page, #categories, #collection_names, #collections, #frontend_manifest, #metadata, #resources, #resources_grouped_by_taxonomy, #resources_to_write, #site_payload, #static_files_to_write, #tags, #taxonomies, #taxonomy_types

Methods included from Configurable

#base_path, #collections_path, #config=, #defaults_reader, #destination, #frontend_bundling_path, #frontmatter_defaults, #in_cache_dir, #in_destination_dir, #in_root_dir, #in_source_dir, #root_dir, #source

Constructor Details

#initialize(config, label: :main, loaders_manager: nil) ⇒ Site

Initialize a new Site.

Parameters:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/bridgetown-core/site.rb', line 46

def initialize(config, label: :main, loaders_manager: nil)
  @label = label.to_sym
  self.config = config
  locale

  loaders_manager = if loaders_manager
                      loaders_manager.config = self.config
                      loaders_manager
                    else
                      Bridgetown::Utils::LoadersManager.new(self.config)
                    end
  @loaders_manager = loaders_manager

  @plugin_manager  = PluginManager.new(self)
  @cleaner         = Cleaner.new(self)
  @reader          = Reader.new(self)
  @liquid_renderer = LiquidRenderer.new(self)

  Bridgetown::Cache.base_cache["site_tmp"] = HashWithDotAccess::Hash.new
  ensure_not_in_dest

  Bridgetown::Current.sites[@label] = self
  Bridgetown::Hooks.trigger :site, :after_init, self

  reset   # Processable
  setup   # Extensible
end

Instance Attribute Details

#cache_dirObject (readonly)

Returns the value of attribute cache_dir.



26
27
28
# File 'lib/bridgetown-core/site.rb', line 26

def cache_dir
  @cache_dir
end

#configBridgetown::Configuration (readonly)



18
19
20
# File 'lib/bridgetown-core/site.rb', line 18

def config
  @config
end

#convertersObject

Returns the value of attribute converters.



38
39
40
# File 'lib/bridgetown-core/site.rb', line 38

def converters
  @converters
end

#dataObject

Returns the value of attribute data.



26
27
28
# File 'lib/bridgetown-core/site.rb', line 26

def data
  @data
end

#fast_refresh_orderingObject

Returns the value of attribute fast_refresh_ordering.



38
39
40
# File 'lib/bridgetown-core/site.rb', line 38

def fast_refresh_ordering
  @fast_refresh_ordering
end

#file_read_optsObject

Returns the value of attribute file_read_opts.



38
39
40
# File 'lib/bridgetown-core/site.rb', line 38

def file_read_opts
  @file_read_opts
end

#generated_pagesArray<GeneratedPage>

Returns:



36
37
38
# File 'lib/bridgetown-core/site.rb', line 36

def generated_pages
  @generated_pages
end

#generatorsObject

Returns the value of attribute generators.



38
39
40
# File 'lib/bridgetown-core/site.rb', line 38

def generators
  @generators
end

#labelSymbol (readonly)

Returns:

  • (Symbol)


21
22
23
# File 'lib/bridgetown-core/site.rb', line 21

def label
  @label
end

#layoutsArray<Layout>

Returns:



33
34
35
# File 'lib/bridgetown-core/site.rb', line 33

def layouts
  @layouts
end

#liquid_rendererObject (readonly)

Returns the value of attribute liquid_renderer.



26
27
28
# File 'lib/bridgetown-core/site.rb', line 26

def liquid_renderer
  @liquid_renderer
end

#loaders_managerBridgetown::Utils::LoadersManager (readonly)



24
25
26
# File 'lib/bridgetown-core/site.rb', line 24

def loaders_manager
  @loaders_manager
end

Returns the value of attribute permalink_style.



38
39
40
# File 'lib/bridgetown-core/site.rb', line 38

def permalink_style
  @permalink_style
end

#plugin_managerObject

Returns the value of attribute plugin_manager.



38
39
40
# File 'lib/bridgetown-core/site.rb', line 38

def plugin_manager
  @plugin_manager
end

#readerObject

Returns the value of attribute reader.



38
39
40
# File 'lib/bridgetown-core/site.rb', line 38

def reader
  @reader
end

#signalsObject (readonly)

Returns the value of attribute signals.



26
27
28
# File 'lib/bridgetown-core/site.rb', line 26

def signals
  @signals
end

#static_filesArray<StaticFile>

All files not pages/documents or structured data in the source folder

Returns:



30
31
32
# File 'lib/bridgetown-core/site.rb', line 30

def static_files
  @static_files
end

#timeObject

Returns the value of attribute time.



38
39
40
# File 'lib/bridgetown-core/site.rb', line 38

def time
  @time
end

Instance Method Details

#ensure_not_in_destObject

Check that the destination dir isn't the source dir or a directory parent to the source dir.



93
94
95
96
97
98
99
100
101
# File 'lib/bridgetown-core/site.rb', line 93

def ensure_not_in_dest
  dest_pathname = Pathname.new(dest)
  Pathname.new(source).ascend do |path|
    if path == dest_pathname
      raise Errors::FatalException,
            "Destination directory cannot be or contain the Source directory."
    end
  end
end

#inspectObject



107
108
109
# File 'lib/bridgetown-core/site.rb', line 107

def inspect
  "#<Bridgetown::Site #{.inspect.delete_prefix("{").delete_suffix("}")}>"
end

#tmp_cacheObject



103
104
105
# File 'lib/bridgetown-core/site.rb', line 103

def tmp_cache
  Bridgetown::Cache.base_cache["site_tmp"]
end