module Utopia
Utopia is a web application framework built on top of Rack.
Nested
Definitions
PAGES_PATH = "pages".freeze
The default pages path for module Utopia::Content middleware.
VARIABLES_KEY = "utopia.variables".freeze
This is used for shared controller variables which get consumed by the content middleware.
def self.default_root(subdirectory = PAGES_PATH, pwd = Dir.pwd)
The default root directory for middleware to operate within, e.g. the web-site directory. Convention over configuration.
Implementation
def self.default_root(subdirectory = PAGES_PATH, pwd = Dir.pwd)
File.expand_path(subdirectory, pwd)
end
def self.default_path(*arguments)
The same as Utopia.default_root but returns an instance of class Utopia::Path.
Implementation
def self.default_path(*arguments)
Path[default_root(*arguments)]
end
def self.setup(root = nil, **options)
You can call this method exactly once per process.
Implementation
def self.setup(root = nil, **options)
if @setup
raise RuntimeError, "Utopia already setup!"
end
# We extract the root from the caller of this method:
if root.nil?
config_root = File.dirname(caller[0])
root = File.dirname(config_root)
end
@setup = Setup.new(root, **options)
@setup.apply!
return @setup
end