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(path) ⇒ Object
Create all virtual nodes which are specified in
path
. -
#initialize ⇒ Virtual
constructor
:nodoc:.
Methods included from WebsiteAccess
Methods included from Base
#content, #node_exists?, #output_path, #page_from_path, #parent_node
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(path) ⇒ Object
Create all virtual nodes 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 |
# File 'lib/webgen/sourcehandler/virtual.rb', line 23 def create_node(path) nodes = [] read_data(path).each do |key, | cache_data = [key, .dup] key = Webgen::Path.make_absolute(path.parent_path, key) + (key =~ /\/$/ ? '/' : '') temp_parent = create_directories(File.dirname(key), path) output_path = .delete('url') || key output_path = (URI::parse(output_path).absolute? || output_path =~ /^\// ? output_path : File.join(temp_parent.alcn, output_path)) if key =~ /\/$/ nodes << create_directory(key, path, ) else nodes += website.blackboard.invoke(:create_nodes, Webgen::Path.new(key, path.source_path), self) do |cn_path| cn_path..update() super(cn_path, :output_path => output_path) do |n| n.node_info[:sh_virtual_cache_data] = cache_data end end end end nodes.compact end |