class Webgen::Node
Represents a file, a directory or a fragment. A node always belongs to a Tree.
All needed meta and processing information is associated with the node itself. The meta information is available through the []
and meta_info
accessors, the internal processing information through the node_info
accessor.
This class is not directly used. Instead path handlers define sub-classes that provide handler specific methods. See the basic sub-class Webgen::PathHandler::Base::Node
.
Attributes
The absolute canonical name of this node.
The absolute localized canonical name of this node.
The child nodes of this node.
The canonical name of this node.
The full destination path of this node.
The language of this node.
The localized canonical name of this node.
The level of the node. The level specifies how deep the node is in the hierarchy.
Meta information associated with the node. If you need just a value for a meta information key, use the []
method.
Return the node information hash which contains information for processing the node.
The parent node. This is in all but one case a Node
object. The one exception is that the parent of the Tree#dummy_node is a Tree object.
The tree to which this node belongs.
Public Class Methods
Create a new Node
instance.
parent
(immutable)-
The parent node under which this nodes should be created.
cn
(immutable)-
The canonical name for this node. Needs to be of the form 'basename.ext' or 'basename' where
basename
does not contain any dots. Also, thebasename
must not include a language part! dest_path
(immutable)-
The full output path for this node. If this node is a directory, the path must have a trailing slash ('dir/'). If it is a fragment, it has to include a hash sign. This can also be an absolute path like example.com.
meta_info
-
A hash with meta information for the new node.
The language of a node is taken from the meta information lang
and the entry is deleted from the meta information hash. The language cannot be changed afterwards! If no lang
key is found, the node is unlocalized.
Public Instance Methods
Return true
if the alcn
matches the pattern.
See Webgen::Path.matches_pattern?
for more information.
Return the meta information item for key
.
Check if the this node is an ancestor of node
.
The check is performed using only the parent
information of the involved nodes, NOT the actual alcn values!
Check if the node is a directory.
Check if the node is a file.
Check if the node is a fragment.
Check if the node is the root node.
Return a HTML link from this node to the given node.
If the lang
parameter is not used, it defaults to the language of the current node.
You can optionally specify additional attributes for the HTML element in the attr
Hash
. Also, the meta information link_attrs
of the given node
is used, if available, to set attributes. However, the attr
parameter takes precedence over the link_attrs
meta information.
If the special value 'link_text' is present in the attributes, it will be used as the link text; otherwise the title of the node
will be used.
Return the proxy node in language lang
.
This node should be used, for example, when routing to this node. The proxy node is found by using the proxy_path
meta information. This meta information is usually set on directories to specify the node that should be used for the “directory index”.
If the lang
parameter is not used, it defaults to the language of the current node.
Return the node representing the given path
in the given language.
The path can be absolute (i.e. starting with a slash) or relative to the current node. Relative paths are made absolute by using the alcn
of the current node.
If the lang
parameter is not used, it defaults to the language of the current node.
See Tree#resolve_node for detailed information on how the correct node for the path is found and for the msg_on_failure
parameter.
Return the relative path to the given node.
If the lang
parameter is not used, it defaults to the language of the current node.
Return the string representation of the node which is just the alcn
.
Return all versions of this node.