Sha256: 3ff2535227b0ad881b427029ad289cbf78344dd9696189ec382dcca9d7eb399f

Contents?: true

Size: 1.93 KB

Versions: 11

Compression:

Stored size: 1.93 KB

Contents

# frozen_string_literal: true

module Bridgetown
  class Site
    require_all "bridgetown-core/concerns/site"

    include Configurable
    include Content
    include Extensible
    include Localizable
    include Processable
    include Renderable
    include Writable

    attr_reader   :root_dir, :source, :dest, :cache_dir, :config,
                  :regenerator, :liquid_renderer, :components_load_paths,
                  :includes_load_paths

    # All files not pages/documents or structured data in the source folder
    # @return [Array<StaticFile>]
    attr_accessor :static_files

    # @return [Array<Layout>]
    attr_accessor :layouts

    # @return [Array<Page>]
    attr_accessor :pages

    attr_accessor :exclude, :include, :lsi, :highlighter, :permalink_style,
                  :time, :future, :unpublished, :limit_posts,
                  :keep_files, :baseurl, :data, :file_read_opts,
                  :plugin_manager, :converters, :generators, :reader

    # Public: Initialize a new Site.
    #
    # config - A Hash containing site configuration details.
    def initialize(config)
      self.config = config
      locale

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

      ensure_not_in_dest

      Bridgetown.sites << self
      Bridgetown::Hooks.trigger :site, :after_init, self

      reset   # Processable
      setup   # Extensible
    end

    # Check that the destination dir isn't the source dir or a directory
    # parent to the source dir.
    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
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
bridgetown-core-0.19.3 lib/bridgetown-core/site.rb
bridgetown-core-0.19.2 lib/bridgetown-core/site.rb
bridgetown-core-0.19.1 lib/bridgetown-core/site.rb
bridgetown-core-0.19.0 lib/bridgetown-core/site.rb
bridgetown-core-0.18.6 lib/bridgetown-core/site.rb
bridgetown-core-0.18.5 lib/bridgetown-core/site.rb
bridgetown-core-0.18.4 lib/bridgetown-core/site.rb
bridgetown-core-0.18.3 lib/bridgetown-core/site.rb
bridgetown-core-0.18.2 lib/bridgetown-core/site.rb
bridgetown-core-0.18.1 lib/bridgetown-core/site.rb
bridgetown-core-0.18.0 lib/bridgetown-core/site.rb