Class: Webgen::PathHandler::Base::Node
- Defined in:
- lib/webgen/path_handler/base.rb
Overview
This is the Node sub class used by the Base#create_node method if a path handler class does not specify another Node class.
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Node
#acn, #alcn, #children, #cn, #dest_path, #lang, #lcn, #level, #meta_info, #node_info, #parent, #tree
Instance Method Summary collapse
-
#content ⇒ Object
Return the result of the #content method on the associated path handler or
nil
if the associated path handler does not have a #content method. -
#link_to(*args, &block) ⇒ Object
Does exactly the same as Webgen::Node#link_to but replaces the HTML a-tag with a span-tag depending on the configuration option ‘website.link_to_current_page’.
-
#route_to(node, lang = @lang) ⇒ Object
Does exactly the same as Webgen::Node#route_to but also automatically adds the necessary item tracking information.
-
#url ⇒ Object
Return the absolute URL of this node.
Methods inherited from Node
#=~, #[], #initialize, #inspect, #is_ancestor_of?, #is_directory?, #is_file?, #is_fragment?, #is_root?, #proxy_node, #resolve, #to_s, #versions
Constructor Details
This class inherits a constructor from Webgen::Node
Instance Method Details
#content ⇒ Object
Return the result of the #content method on the associated path handler or nil
if the associated path handler does not have a #content method.
65 66 67 |
# File 'lib/webgen/path_handler/base.rb', line 65 def content (@node_info[:path_handler].respond_to?(:content) ? @node_info[:path_handler].content(self) : nil) end |
#link_to(*args, &block) ⇒ Object
Does exactly the same as Webgen::Node#link_to but replaces the HTML a-tag with a span-tag depending on the configuration option ‘website.link_to_current_page’.
54 55 56 57 58 59 60 61 |
# File 'lib/webgen/path_handler/base.rb', line 54 def link_to(*args, &block) result = super if !tree.website.config['website.link_to_current_page'] && args.first == self result.sub!(/<a/, '<span').sub!(/<\/a>/, '</span>'). gsub!(/ (?:href|hreflang)=".*"/, '') end result end |
#route_to(node, lang = @lang) ⇒ Object
Does exactly the same as Webgen::Node#route_to but also automatically adds the necessary item tracking information.
46 47 48 49 50 |
# File 'lib/webgen/path_handler/base.rb', line 46 def route_to(node, lang = @lang) tree.website.ext.item_tracker.add(self, :node_meta_info, node) tree.website.ext.item_tracker.add(self, :node_meta_info, node.proxy_node(lang)) super end |
#url ⇒ Object
Return the absolute URL of this node.
This method uses the configuration option ‘website.base_url’ for constructing the absolute URL.
39 40 41 42 |
# File 'lib/webgen/path_handler/base.rb', line 39 def url node_url = Webgen::Path.url(dest_path, false) node_url.absolute? ? node_url.to_s : File.join(tree.website.config['website.base_url'], dest_path) end |