Sha256: 8d7e2d9d6c367cab54de5c18d205f887debe430232ca70889b180422e36ead6b

Contents?: true

Size: 978 Bytes

Versions: 9

Compression:

Stored size: 978 Bytes

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2009-2022, by Samuel Williams.

require_relative 'http'
require_relative 'path'

module Utopia
	# The default pages path for {Utopia::Content} middleware.
	PAGES_PATH = 'pages'.freeze
	
	# This is used for shared controller variables which get consumed by the content middleware.
	VARIABLES_KEY = 'utopia.variables'.freeze
	
	# The default root directory for middleware to operate within, e.g. the web-site directory. Convention over configuration.
	# @param subdirectory [String] Appended to the default root to make a more specific path.
	# @param pwd [String] The working directory for the current site.
	def self.default_root(subdirectory = PAGES_PATH, pwd = Dir.pwd)
		File.expand_path(subdirectory, pwd)
	end
	
	# The same as {default_root} but returns an instance of {Path}.
	# @return [Path] The path as requested.
	def self.default_path(*arguments)
		Path[default_root(*arguments)]
	end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
utopia-2.25.0 lib/utopia/middleware.rb
utopia-2.24.4 lib/utopia/middleware.rb
utopia-2.24.3 lib/utopia/middleware.rb
utopia-2.24.1 lib/utopia/middleware.rb
utopia-2.23.0 lib/utopia/middleware.rb
utopia-2.22.2 lib/utopia/middleware.rb
utopia-2.22.1 lib/utopia/middleware.rb
utopia-2.22.0 lib/utopia/middleware.rb
utopia-2.21.0 lib/utopia/middleware.rb