Module: Utopia

Defined in:
lib/utopia.rb,
lib/utopia/http.rb,
lib/utopia/path.rb,
lib/utopia/setup.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/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/extensions/array_split.rb,
lib/utopia/logger/compact_formatter.rb,
lib/utopia/extensions/date_comparisons.rb

Overview

Copyright, 2012, by Samuel G. D. Williams. http://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, Controllers, Exceptions, Extensions, HTTP, Logger, Redirection Classes: Content, ContentLength, Controller, Locale, Localization, Path, Session, Setup, Static

Constant Summary collapse

VERSION =
"2.6.0"
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(*args) ⇒ 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(*args)
	Path[default_root(*args)]
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



377
378
379
# File 'lib/utopia/path.rb', line 377

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

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

The main entry point for config/environment.rb for setting up the site.



103
104
105
106
107
108
109
110
# File 'lib/utopia/setup.rb', line 103

def self.setup(config_root = nil, **options)
	# We extract the directory of the caller to get the path to $root/config
	if config_root.nil?
		config_root = File.dirname(caller[0])
	end
	
	Setup.new(config_root, **options).tap(&:apply)
end