Class: Webgen::SourceHandler::Virtual
- Inherits:
-
Object
- Object
- Webgen::SourceHandler::Virtual
- Includes:
- Base, WebsiteAccess
- Defined in:
- lib/webgen/sourcehandler/virtual.rb
Overview
Handles files which contain specifications for “virtual” nodes, ie. nodes that don’t have real source path.
This can be used, for example, to provide multiple links to the same node.
Instance Method Summary collapse
-
#create_node(parent, path) ⇒ Object
Create all virtual nodes under
parent
which are specified inpath
. -
#initialize ⇒ Virtual
constructor
:nodoc:.
Methods included from WebsiteAccess
Methods included from Base
#content, #node_exists?, #output_path, #page_from_path
Methods included from Base::OutputPathHelpers
Methods included from Loggable
Constructor Details
#initialize ⇒ Virtual
:nodoc:
17 18 19 20 |
# File 'lib/webgen/sourcehandler/virtual.rb', line 17 def initialize # :nodoc: website.blackboard.add_listener(:node_meta_info_changed?, method(:node_meta_info_changed?)) @path_data = {} end |
Instance Method Details
#create_node(parent, path) ⇒ Object
Create all virtual nodes under parent
which are specified in path
.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/webgen/sourcehandler/virtual.rb', line 23 def create_node(parent, path) nodes = [] read_data(path).each do |key, | cache_data = [key, .dup] key = Webgen::Common.absolute_path(key, parent.absolute_lcn) + (key =~ /\/$/ ? '/' : '') temp_parent = create_directories(parent.tree.root, File.dirname(key), path) output_path = .delete('url') || key output_path = (URI::parse(output_path).absolute? || output_path =~ /^\// ? output_path : File.join(temp_parent.absolute_lcn, output_path)) if key =~ /\/$/ nodes << create_directory(temp_parent, key, path, ) else nodes += website.blackboard.invoke(:create_nodes, parent.tree, temp_parent.absolute_lcn, Webgen::Path.new(key, path.source_path), self) do |cn_parent, cn_path| cn_path..update() super(cn_parent, cn_path, output_path) do |n| n.node_info[:sh_virtual_cache_data] = cache_data end end end end nodes.compact end |