Module: Utopia

Extended by:
Console
Defined in:
lib/utopia.rb,
lib/utopia/http.rb,
lib/utopia/path.rb,
lib/utopia/setup.rb,
lib/utopia/shell.rb,
lib/utopia/locale.rb,
lib/utopia/logger.rb,
lib/utopia/static.rb,
lib/utopia/command.rb,
lib/utopia/content.rb,
lib/utopia/session.rb,
lib/utopia/version.rb,
lib/utopia/responder.rb,
lib/utopia/controller.rb,
lib/utopia/exceptions.rb,
lib/utopia/middleware.rb,
lib/utopia/redirection.rb,
lib/utopia/command/site.rb,
lib/utopia/content/link.rb,
lib/utopia/content/node.rb,
lib/utopia/content/tags.rb,
lib/utopia/localization.rb,
lib/utopia/path/matcher.rb,
lib/utopia/content/links.rb,
lib/utopia/command/server.rb,
lib/utopia/content/markup.rb,
lib/utopia/content_length.rb,
lib/utopia/controller/base.rb,
lib/utopia/content/document.rb,
lib/utopia/content/response.rb,
lib/utopia/content/namespace.rb,
lib/utopia/exceptions/mailer.rb,
lib/utopia/session/lazy_hash.rb,
lib/utopia/static/local_file.rb,
lib/utopia/static/mime_types.rb,
lib/utopia/controller/actions.rb,
lib/utopia/controller/respond.rb,
lib/utopia/controller/rewrite.rb,
lib/utopia/exceptions/handler.rb,
lib/utopia/command/environment.rb,
lib/utopia/controller/variables.rb,
lib/utopia/session/serialization.rb,
lib/utopia/extensions/array_split.rb,
lib/utopia/extensions/date_comparisons.rb

Overview

Copyright, 2012, by Samuel G. D. Williams. <www.codeotaku.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Defined Under Namespace

Modules: Command, Exceptions, Extensions, HTTP, Redirection Classes: Content, ContentLength, Controller, Locale, Localization, Path, Responder, Session, Setup, Shell, Static

Constant Summary collapse

VERSION =
"2.17.1"
PAGES_PATH =

The default pages path for Content middleware.

'pages'.freeze
VARIABLES_KEY =

This is used for shared controller variables which get consumed by the content middleware.

'utopia.variables'.freeze

Class Method Summary collapse

Class Method Details

.default_path(*arguments) ⇒ Path

The same as default_root but returns an instance of Path.

Returns:

  • (Path)

    The path as requested.



42
43
44
# File 'lib/utopia/middleware.rb', line 42

def self.default_path(*arguments)
	Path[default_root(*arguments)]
end

.default_root(subdirectory = PAGES_PATH, pwd = Dir.pwd) ⇒ Object

The default root directory for middleware to operate within, e.g. the web-site directory. Convention over configuration.

Parameters:

  • subdirectory (String) (defaults to: PAGES_PATH)

    Appended to the default root to make a more specific path.

  • pwd (String) (defaults to: Dir.pwd)

    The working directory for the current site.



36
37
38
# File 'lib/utopia/middleware.rb', line 36

def self.default_root(subdirectory = PAGES_PATH, pwd = Dir.pwd)
	File.expand_path(subdirectory, pwd)
end

.Path(path) ⇒ Object



393
394
395
# File 'lib/utopia/path.rb', line 393

def self.Path(path)
	Path.create(path)
end

.setup(root = nil, **options) ⇒ Object

You can call this method exactly once per process.



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/utopia/setup.rb', line 135

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