class Webgen::PathHandler::Base::Node
This is the Node
sub class used by the Base#create_node
method if a path handler class does not specify another Node
class.
Public Instance Methods
content()
click to toggle source
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.
# File lib/webgen/path_handler/base.rb 64 def content 65 (@node_info[:path_handler].respond_to?(:content) ? @node_info[:path_handler].content(self) : nil) 66 end
link_to(*args, &block)
click to toggle source
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'.
Calls superclass method
Webgen::Node#link_to
# File lib/webgen/path_handler/base.rb 53 def link_to(*args, &block) 54 result = super 55 if !tree.website.config['website.link_to_current_page'] && args.first == self 56 result.sub!(/<a/, '<span').sub!(/<\/a>/, '</span>'). 57 gsub!(/ (?:href|hreflang)=".*"/, '') 58 end 59 result 60 end
route_to(node, lang = @lang)
click to toggle source
Does exactly the same as Webgen::Node#route_to
but also automatically adds the necessary item tracking information.
Calls superclass method
Webgen::Node#route_to
# File lib/webgen/path_handler/base.rb 45 def route_to(node, lang = @lang) 46 tree.website.ext.item_tracker.add(self, :node_meta_info, node) 47 tree.website.ext.item_tracker.add(self, :node_meta_info, node.proxy_node(lang)) 48 super 49 end
url()
click to toggle source
Return the absolute URL of this node.
This method uses the configuration option 'website.base_url' for constructing the absolute URL.
# File lib/webgen/path_handler/base.rb 38 def url 39 node_url = Webgen::Path.url(dest_path, false) 40 node_url.absolute? ? node_url.to_s : File.join(tree.website.config['website.base_url'], dest_path) 41 end