UtopiaSourceUtopiaContent

class Content

A middleware which serves dynamically generated content based on markup files.

Nested

Definitions

XNODE_EXTENSION = '.xnode'

The file extension for markup nodes on disk.

EXPIRES = 'expires'.freeze

Compatibility with older versions of rack:

def initialize(app, root: Utopia::default_root, namespaces: {})

Implementation

def initialize(app, root: Utopia::default_root, namespaces: {})
	@app = app
	@root = root
	
	@template_cache = Concurrent::Map.new
	@node_cache = Concurrent::Map.new
	
	@links = Links.new(@root)
	
	@namespaces = namespaces
	
	# Default content namespace for dynamic path based lookup:
	@namespaces[CONTENT_NAMESPACE] ||= self.method(:content_tag)
	
	# The core namespace for utopia specific functionality:
	@namespaces[UTOPIA_NAMESPACE] ||= Tags
end

def lookup_tag(qualified_name, node)

Look up a named tag such as <entry /> or <content:page>...

Implementation

def lookup_tag(qualified_name, node)
	namespace, name = XRB::Tag.split(qualified_name)
	
	if library = @namespaces[namespace]
		library.call(name, node)
	end
end

def lookup_node(path, locale = nil)

Implementation

def lookup_node(path, locale = nil)
	resolve_link(
		@links.for(path, locale)
	)
end